diff options
author | Dixsie Wolmers <dixsie@ibm.com> | 2020-01-23 04:47:56 +0300 |
---|---|---|
committer | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2020-01-29 01:18:05 +0300 |
commit | f65ee346bedb1811e88b12542abce0d18bb5fc32 (patch) | |
tree | 04b0a5cc2096a48b9c2b15dc571a1db680802c89 /src/store/modules/Configuration | |
parent | dc04feb5596a85619e98d2d594b065e92c8b8fa4 (diff) | |
download | webui-vue-f65ee346bedb1811e88b12542abce0d18bb5fc32.tar.xz |
Add store modules needed to support overview view
- Update overview page to get data from store
Signed-off-by: Dixsie Wolmers <dixsie@ibm.com>
Signed-off-by: Derick Montague <derick.montague@ibm.com>
Change-Id: Id2fcad660efc0da5c7b878e872355bf5773c7ed7
Diffstat (limited to 'src/store/modules/Configuration')
-rw-r--r-- | src/store/modules/Configuration/FirmwareStore.js | 60 | ||||
-rw-r--r-- | src/store/modules/Configuration/NetworkSettingsStore.js | 48 |
2 files changed, 108 insertions, 0 deletions
diff --git a/src/store/modules/Configuration/FirmwareStore.js b/src/store/modules/Configuration/FirmwareStore.js new file mode 100644 index 00000000..5185a138 --- /dev/null +++ b/src/store/modules/Configuration/FirmwareStore.js @@ -0,0 +1,60 @@ +import api from '../../api'; + +const FirmwareStore = { + namespaced: true, + state: { + firmwareInfo: null, + bmcActiveVersion: '--', + hostActiveVersion: '--' + }, + getters: { + firmwareInfo: state => state.firmwareInfo, + bmcActiveVersion: state => state.bmcActiveVersion, + hostActiveVersion: state => state.hostActiveVersion + }, + mutations: { + setFirmwareInfo: (state, firmwareInfo) => + (state.firmwareInfo = firmwareInfo), + setBmcActiveVersion: (state, bmcActiveVersion) => + (state.bmcActiveVersion = bmcActiveVersion), + setHostActiveVersion: (state, hostActiveVersion) => + (state.hostActiveVersion = hostActiveVersion) + }, + actions: { + getFirmwareInfo({ commit }) { + api + .get('/xyz/openbmc_project/software/enumerate') + .then(response => { + const firmwareInfo = response.data.data; + const functionalImages = + firmwareInfo['/xyz/openbmc_project/software/functional'].endpoints; + for (let key in firmwareInfo) { + /** + * If "Functional" activation status is + * functional, else it is "activation" + * github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Software/Activation.interface.yaml + */ + if (firmwareInfo[key].hasOwnProperty('Version')) { + let activationStatus = ''; + const imageType = firmwareInfo[key].Purpose.split('.').pop(); + if (functionalImages.includes(key)) { + activationStatus = 'Functional'; + } + // Get BMC and Host active Versions + if (activationStatus == 'Functional' && imageType == 'BMC') { + commit('setBmcActiveVersion', firmwareInfo[key].Version); + } + if (activationStatus == 'Functional' && imageType == 'Host') { + commit('setHostActiveVersion', firmwareInfo[key].Version); + } + } + } + }) + .catch(error => { + console.log(error); + }); + } + } +}; + +export default FirmwareStore; diff --git a/src/store/modules/Configuration/NetworkSettingsStore.js b/src/store/modules/Configuration/NetworkSettingsStore.js new file mode 100644 index 00000000..ee58a77b --- /dev/null +++ b/src/store/modules/Configuration/NetworkSettingsStore.js @@ -0,0 +1,48 @@ +import api from '../../api'; + +const NetworkSettingsStore = { + namespaced: true, + state: { + networkData: null, + ipAddress: '--', + macAddress: '--' + }, + getters: { + networkData: state => state.networkData, + ipAddress: state => state.ipAddress, + macAddress: state => state.macAddress + }, + mutations: { + setNetworkData: (state, networkData) => (state.networkData = networkData), + setIpAddress: (state, ipAddress) => (state.ipAddress = ipAddress), + setMacAddress: (state, macAddress) => (state.macAddress = macAddress) + }, + actions: { + getNetworkData({ commit }) { + api + .get('/xyz/openbmc_project/network/enumerate') + .then(response => { + const networkData = response.data.data; + const ipAddresses = []; + const interfaceId = /eth[0-9]/; + for (let key in networkData) { + if (key.includes('ipv4')) { + ipAddresses.push(networkData[key].Address); + } + if ( + key.match(interfaceId) && + networkData[key].MACAddress !== undefined + ) { + commit('setMacAddress', networkData[key].MACAddress); + } + } + commit('setIpAddress', ipAddresses); + }) + .catch(error => { + console.log('Network Data:', error); + }); + } + } +}; + +export default NetworkSettingsStore; |