From e8cb2c6a81e8abb75cb63c10c29008d868e7fef2 Mon Sep 17 00:00:00 2001 From: Nikhil Ashoka Date: Wed, 4 Jan 2023 15:45:20 +0530 Subject: Added DHCP enable/disable feature - DHCP toggle for enablement was not present, It is now added in the Networks page. - DHCP when enabled, if there is no address, it picks up an address on its own.When it is disabled, we need to manually configure it. Signed-off-by: Nikhil Ashoka Change-Id: I32a9e0df28e6609945f3757a6bd69dc66a86f480 --- src/store/modules/Settings/NetworkStore.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/store/modules') diff --git a/src/store/modules/Settings/NetworkStore.js b/src/store/modules/Settings/NetworkStore.js index 125eca7a..5c78d10a 100644 --- a/src/store/modules/Settings/NetworkStore.js +++ b/src/store/modules/Settings/NetworkStore.js @@ -40,6 +40,7 @@ const NetworkStore = { dhcpAddress: IPv4Addresses.filter( (ipv4) => ipv4.AddressOrigin === 'DHCP' ), + dhcpEnabled: DHCPv4.DHCPEnabled, hostname: HostName, macAddress: MACAddress, linkStatus: LinkStatus, @@ -87,6 +88,32 @@ const NetworkStore = { console.log('Network Data:', error); }); }, + async saveDhcpEnabledState({ state, dispatch }, dhcpState) { + const data = { + DHCPv4: { + DHCPEnabled: dhcpState, + }, + }; + return api + .patch( + `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`, + data + ) + .then(dispatch('getEthernetData')) + .then(() => { + return i18n.t('pageNetwork.toast.successSaveNetworkSettings', { + setting: i18n.t('pageNetwork.dhcp'), + }); + }) + .catch((error) => { + console.log(error); + throw new Error( + i18n.t('pageNetwork.toast.errorSaveNetworkSettings', { + setting: i18n.t('pageNetwork.dhcp'), + }) + ); + }); + }, async saveDomainNameState({ commit, state }, domainState) { commit('setDomainNameState', domainState); const data = { -- cgit v1.2.3