diff options
author | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2020-10-06 20:00:19 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2020-10-30 23:50:56 +0300 |
commit | 98bb24ebe5411a25440f9748168b72272304d50e (patch) | |
tree | 59e757e37ac028952372db152094083e1b2f8cde /src/store | |
parent | 59569d8f93842933e8b135cc13a9c15e0278af4c (diff) | |
download | webui-vue-98bb24ebe5411a25440f9748168b72272304d50e.tar.xz |
Add two file firmware update
Adds the ability to upload separate Host and BMC firmware images through
the GUI. By default, the two file firmware update page will be shown.
Changes to the .env configurations will enable the single file upload
page. The IBM env is configured to allow single file firmware update.
Two file upload features:
- File upload through local workstation or tftp server
- Reboot from backup BMC image
- Does not have ability to reboot from backup host image
- Does not implement checks in GUI for host status, which is the
same as what we have in phosphor-webui
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: Ibf2a2d9ffc3952dd5a5454c723350c61d9f91c3e
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/modules/Configuration/FirmwareStore.js | 142 |
1 files changed, 105 insertions, 37 deletions
diff --git a/src/store/modules/Configuration/FirmwareStore.js b/src/store/modules/Configuration/FirmwareStore.js index d9d3cfb8..c99e7eb8 100644 --- a/src/store/modules/Configuration/FirmwareStore.js +++ b/src/store/modules/Configuration/FirmwareStore.js @@ -1,57 +1,126 @@ import api from '@/store/api'; import i18n from '@/i18n'; +/** + * Get backup firmware image from SoftwareImages + * The backup is whichever image is not the current + * or "ActiveSoftwareImage" + * @param {Array} list + * @param {String} currentLocation + */ +function getBackupFirmwareLocation(list, currentLocation) { + return list + .map(item => item['@odata.id']) + .find(location => { + const id = location.split('/').pop(); + const currentId = currentLocation.split('/').pop(); + return id !== currentId; + }); +} + const FirmwareStore = { namespaced: true, state: { - activeFirmware: { - version: '--', - id: null, - location: null + bmcFirmware: { + currentVersion: null, + currentState: null, + currentLocation: null, + backupVersion: null, + backupState: null, + backupLocation: null }, - backupFirmware: { - version: '--', - id: null, - location: null, - status: '--' + hostFirmware: { + currentVersion: null, + currentState: null, + currentLocation: null, + backupVersion: null, + backupState: null, + backupLocation: null }, applyTime: null }, getters: { - systemFirmwareVersion: state => state.activeFirmware.version, - backupFirmwareVersion: state => state.backupFirmware.version, - backupFirmwareStatus: state => state.backupFirmware.status, - isRebootFromBackupAvailable: state => - state.backupFirmware.id ? true : false + bmcFirmwareCurrentVersion: state => state.bmcFirmware.currentVersion, + bmcFirmwareCurrentState: state => state.bmcFirmware.currentState, + bmcFirmwareBackupVersion: state => state.bmcFirmware.backupVersion, + bmcFirmwareBackupState: state => state.bmcFirmware.backupState, + hostFirmwareCurrentVersion: state => state.hostFirmware.currentVersion, + hostFirmwareCurrentState: state => state.hostFirmware.currentState, + hostFirmwareBackupVersion: state => state.hostFirmware.backupVersion, + hostFirmwareBackupState: state => state.hostFirmware.backupState }, mutations: { - setActiveFirmware: (state, { version, id, location }) => { - state.activeFirmware.version = version; - state.activeFirmware.id = id; - state.activeFirmware.location = location; + setBmcFirmwareCurrent: (state, { version, location, status }) => { + state.bmcFirmware.currentVersion = version; + state.bmcFirmware.currentState = status; + state.bmcFirmware.currentLocation = location; + }, + setBmcFirmwareBackup: (state, { version, location, status }) => { + state.bmcFirmware.backupVersion = version; + state.bmcFirmware.backupState = status; + state.bmcFirmware.backupLocation = location; }, - setBackupFirmware: (state, { version, id, location, status }) => { - state.backupFirmware.version = version; - state.backupFirmware.id = id; - state.backupFirmware.location = location; - state.backupFirmware.status = status; + setHostFirmwareCurrent: (state, { version, location, status }) => { + state.hostFirmware.currentVersion = version; + state.hostFirmware.currentState = status; + state.hostFirmware.currentLocation = location; + }, + setHostFirmwareBackup: (state, { version, location, status }) => { + state.hostFirmware.backupVersion = version; + state.hostFirmware.backupState = status; + state.hostFirmware.backupLocation = location; }, setApplyTime: (state, applyTime) => (state.applyTime = applyTime) }, actions: { - async getSystemFirwareVersion({ commit }) { + async getFirmwareInformation({ dispatch }) { + return await api.all([ + dispatch('getBmcFirmware'), + dispatch('getHostFirmware') + ]); + }, + async getBmcFirmware({ commit }) { return await api .get('/redfish/v1/Managers/bmc') .then(({ data: { Links } }) => { const currentLocation = Links.ActiveSoftwareImage['@odata.id']; // Check SoftwareImages list for not ActiveSoftwareImage id - const backupLocation = Links.SoftwareImages.map( - item => item['@odata.id'] - ).find(location => { - const id = location.split('/').pop(); - const currentId = currentLocation.split('/').pop(); - return id !== currentId; + const backupLocation = getBackupFirmwareLocation( + Links.SoftwareImages, + currentLocation + ); + return { currentLocation, backupLocation }; + }) + .then(async ({ currentLocation, backupLocation }) => { + const currentData = await api.get(currentLocation); + let backupData = {}; + + if (backupLocation) { + backupData = await api.get(backupLocation); + } + + commit('setBmcFirmwareCurrent', { + version: currentData?.data?.Version, + location: currentData?.data?.['@odata.id'], + status: currentData?.data?.Status?.State + }); + commit('setBmcFirmwareBackup', { + version: backupData.data?.Version, + location: backupData.data?.['@odata.id'], + status: backupData.data?.Status?.State }); + }) + .catch(error => console.log(error)); + }, + async getHostFirmware({ commit }) { + return await api + .get('/redfish/v1/Systems/system/Bios') + .then(({ data: { Links } }) => { + const currentLocation = Links.ActiveSoftwareImage['@odata.id']; + const backupLocation = getBackupFirmwareLocation( + Links.SoftwareImages, + currentLocation + ); return { currentLocation, backupLocation }; }) .then(async ({ currentLocation, backupLocation }) => { @@ -62,14 +131,13 @@ const FirmwareStore = { backupData = await api.get(backupLocation); } - commit('setActiveFirmware', { + commit('setHostFirmwareCurrent', { version: currentData?.data?.Version, - id: currentData?.data?.Id, - location: currentData?.data?.['@odata.id'] + location: currentData?.data?.['@odata.id'], + status: currentData?.data?.Status?.State }); - commit('setBackupFirmware', { + commit('setHostFirmwareBackup', { version: backupData.data?.Version, - id: backupData.data?.Id, location: backupData.data?.['@odata.id'], status: backupData.data?.Status?.State }); @@ -138,8 +206,8 @@ const FirmwareStore = { throw new Error(i18n.t('pageFirmware.toast.errorUploadAndReboot')); }); }, - async switchFirmwareAndReboot({ state }) { - const backupLoaction = state.backupFirmware.location; + async swtichBmcFirmware({ state }) { + const backupLoaction = state.bmcFirmware.backupLoaction; const data = { Links: { ActiveSoftwareImage: { |