From 33d755f4e62beff72101f6ca07e4d31b04e13826 Mon Sep 17 00:00:00 2001 From: Yoshie Muranaka Date: Thu, 18 Feb 2021 15:24:14 -0800 Subject: Update the default firmware page - Minor updates made to the general layout and styles - Changes to some page copy - Moves update firmware form to bottom of page - Adds dynamic TFTP upload option - Adds dynamic card layout for BMC and host firmwre - 2 cards for combined - 4 cards for separate - Removes FirmwareSingleImage components that were used for IBM builds Signed-off-by: Yoshie Muranaka Change-Id: Ib5465ecc30dd1505824bf41c82d33b7655d5e598 --- .../FirmwareAlertServerPower.vue | 60 ---- .../FirmwareSingleImage/FirmwareCardsBmc.vue | 145 -------- .../FirmwareSingleImage/FirmwareCardsHost.vue | 75 ---- .../FirmwareSingleImage/FirmwareFormUpdate.vue | 235 ------------- .../FirmwareModalSwitchToRunning.vue | 31 -- .../FirmwareModalUpdateFirmware.vue | 48 --- .../FirmwareSingleImage/FirmwareSingleImage.vue | 97 ----- src/env/components/FirmwareSingleImage/index.js | 2 - src/env/router/ibm.js | 4 +- .../FirmwareSingleImageStore.js | 195 ---------- src/env/store/ibm.js | 3 - src/locales/en-US.json | 138 +++----- src/store/modules/Configuration/FirmwareStore.js | 222 +++++------- src/views/Configuration/Firmware/Firmware.vue | 391 +++------------------ .../Firmware/FirmwareAlertServerPower.vue | 50 +++ .../Configuration/Firmware/FirmwareCardsBmc.vue | 133 +++++++ .../Configuration/Firmware/FirmwareCardsHost.vue | 73 ++++ .../Configuration/Firmware/FirmwareFormUpdate.vue | 204 +++++++++++ .../Firmware/FirmwareModalRebootBackupBmc.vue | 34 -- .../Firmware/FirmwareModalSwitchToRunning.vue | 31 ++ .../Firmware/FirmwareModalUpdateFirmware.vue | 44 +++ .../Configuration/Firmware/FirmwareModalUpload.vue | 20 -- src/views/Overview/Overview.vue | 28 +- 23 files changed, 734 insertions(+), 1529 deletions(-) delete mode 100644 src/env/components/FirmwareSingleImage/FirmwareAlertServerPower.vue delete mode 100644 src/env/components/FirmwareSingleImage/FirmwareCardsBmc.vue delete mode 100644 src/env/components/FirmwareSingleImage/FirmwareCardsHost.vue delete mode 100644 src/env/components/FirmwareSingleImage/FirmwareFormUpdate.vue delete mode 100644 src/env/components/FirmwareSingleImage/FirmwareModalSwitchToRunning.vue delete mode 100644 src/env/components/FirmwareSingleImage/FirmwareModalUpdateFirmware.vue delete mode 100644 src/env/components/FirmwareSingleImage/FirmwareSingleImage.vue delete mode 100644 src/env/components/FirmwareSingleImage/index.js delete mode 100644 src/env/store/FirmwareSingleImage/FirmwareSingleImageStore.js create mode 100644 src/views/Configuration/Firmware/FirmwareAlertServerPower.vue create mode 100644 src/views/Configuration/Firmware/FirmwareCardsBmc.vue create mode 100644 src/views/Configuration/Firmware/FirmwareCardsHost.vue create mode 100644 src/views/Configuration/Firmware/FirmwareFormUpdate.vue delete mode 100644 src/views/Configuration/Firmware/FirmwareModalRebootBackupBmc.vue create mode 100644 src/views/Configuration/Firmware/FirmwareModalSwitchToRunning.vue create mode 100644 src/views/Configuration/Firmware/FirmwareModalUpdateFirmware.vue delete mode 100644 src/views/Configuration/Firmware/FirmwareModalUpload.vue diff --git a/src/env/components/FirmwareSingleImage/FirmwareAlertServerPower.vue b/src/env/components/FirmwareSingleImage/FirmwareAlertServerPower.vue deleted file mode 100644 index f7ac0fc9..00000000 --- a/src/env/components/FirmwareSingleImage/FirmwareAlertServerPower.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - diff --git a/src/env/components/FirmwareSingleImage/FirmwareCardsBmc.vue b/src/env/components/FirmwareSingleImage/FirmwareCardsBmc.vue deleted file mode 100644 index 857adf0f..00000000 --- a/src/env/components/FirmwareSingleImage/FirmwareCardsBmc.vue +++ /dev/null @@ -1,145 +0,0 @@ - - - diff --git a/src/env/components/FirmwareSingleImage/FirmwareCardsHost.vue b/src/env/components/FirmwareSingleImage/FirmwareCardsHost.vue deleted file mode 100644 index c47f60f5..00000000 --- a/src/env/components/FirmwareSingleImage/FirmwareCardsHost.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - - - diff --git a/src/env/components/FirmwareSingleImage/FirmwareFormUpdate.vue b/src/env/components/FirmwareSingleImage/FirmwareFormUpdate.vue deleted file mode 100644 index f13b8e00..00000000 --- a/src/env/components/FirmwareSingleImage/FirmwareFormUpdate.vue +++ /dev/null @@ -1,235 +0,0 @@ - - - diff --git a/src/env/components/FirmwareSingleImage/FirmwareModalSwitchToRunning.vue b/src/env/components/FirmwareSingleImage/FirmwareModalSwitchToRunning.vue deleted file mode 100644 index 56f505d0..00000000 --- a/src/env/components/FirmwareSingleImage/FirmwareModalSwitchToRunning.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/src/env/components/FirmwareSingleImage/FirmwareModalUpdateFirmware.vue b/src/env/components/FirmwareSingleImage/FirmwareModalUpdateFirmware.vue deleted file mode 100644 index d6c52f9c..00000000 --- a/src/env/components/FirmwareSingleImage/FirmwareModalUpdateFirmware.vue +++ /dev/null @@ -1,48 +0,0 @@ - - - diff --git a/src/env/components/FirmwareSingleImage/FirmwareSingleImage.vue b/src/env/components/FirmwareSingleImage/FirmwareSingleImage.vue deleted file mode 100644 index 2e601bd4..00000000 --- a/src/env/components/FirmwareSingleImage/FirmwareSingleImage.vue +++ /dev/null @@ -1,97 +0,0 @@ - - - diff --git a/src/env/components/FirmwareSingleImage/index.js b/src/env/components/FirmwareSingleImage/index.js deleted file mode 100644 index 06f31f91..00000000 --- a/src/env/components/FirmwareSingleImage/index.js +++ /dev/null @@ -1,2 +0,0 @@ -import FirmwareSingleImage from './FirmwareSingleImage.vue'; -export default FirmwareSingleImage; diff --git a/src/env/router/ibm.js b/src/env/router/ibm.js index 969146cb..c4e1a698 100644 --- a/src/env/router/ibm.js +++ b/src/env/router/ibm.js @@ -4,6 +4,7 @@ import ClientSessions from '@/views/AccessControl/ClientSessions'; import ConsoleLayout from '@/layouts/ConsoleLayout.vue'; import DateTimeSettings from '@/views/Configuration/DateTimeSettings'; import EventLogs from '@/views/Health/EventLogs'; +import Firmware from '@/views/Configuration/Firmware'; import HardwareStatus from '@/views/Health/HardwareStatus'; import Ldap from '@/views/AccessControl/Ldap'; import LocalUserManagement from '@/views/AccessControl/LocalUserManagement'; @@ -26,7 +27,6 @@ import SslCertificates from '@/views/AccessControl/SslCertificates'; import i18n from '@/i18n'; // Custom components -import FirmwareSingleImage from '../components/FirmwareSingleImage'; import Dumps from '../components/Dumps'; const routes = [ @@ -168,7 +168,7 @@ const routes = [ { path: '/configuration/firmware', name: 'firmware', - component: FirmwareSingleImage, + component: Firmware, meta: { title: i18n.t('appPageTitle.firmware'), }, diff --git a/src/env/store/FirmwareSingleImage/FirmwareSingleImageStore.js b/src/env/store/FirmwareSingleImage/FirmwareSingleImageStore.js deleted file mode 100644 index ae4d6333..00000000 --- a/src/env/store/FirmwareSingleImage/FirmwareSingleImageStore.js +++ /dev/null @@ -1,195 +0,0 @@ -import api from '@/store/api'; -import i18n from '@/i18n'; - -const FirmwareSingleImageStore = { - namespaced: true, - state: { - bmcFirmware: [], - hostFirmware: [], - bmcActiveFirmwareId: null, - hostActiveFirmwareId: null, - applyTime: null, - tftpAvailable: false, - }, - getters: { - isTftpUploadAvailable: (state) => state.tftpAvailable, - isSingleFileUploadEnabled: (state) => state.hostFirmware.length === 0, - activeBmcFirmware: (state) => { - return state.bmcFirmware.find( - (firmware) => firmware.id === state.bmcActiveFirmwareId - ); - }, - activeHostFirmware: (state) => { - return state.hostFirmware.find( - (firmware) => firmware.id === state.hostActiveFirmwareId - ); - }, - backupBmcFirmware: (state) => { - return state.bmcFirmware.find( - (firmware) => firmware.id !== state.bmcActiveFirmwareId - ); - }, - backupHostFirmware: (state) => { - return state.hostFirmware.find( - (firmware) => firmware.id !== state.hostActiveFirmwareId - ); - }, - bmcFirmwareCurrentVersion: (_, getters) => - getters.activeBmcFirmware?.version, //this getter is needed for the Overview page, - }, - mutations: { - setActiveBmcFirmwareId: (state, id) => (state.bmcActiveFirmwareId = id), - setActiveHostFirmwareId: (state, id) => (state.hostActiveFirmwareId = id), - setBmcFirmware: (state, firmware) => (state.bmcFirmware = firmware), - setHostFirmware: (state, firmware) => (state.hostFirmware = firmware), - setApplyTime: (state, applyTime) => (state.applyTime = applyTime), - setTftpUploadAvailable: (state, tftpAvailable) => - (state.tftpAvailable = tftpAvailable), - }, - actions: { - async getFirmwareInformation({ dispatch }) { - dispatch('getActiveHostFirmware'); - dispatch('getActiveBmcFirmware'); - return await dispatch('getFirmwareInventory'); - }, - getActiveBmcFirmware({ commit }) { - return api - .get('/redfish/v1/Managers/bmc') - .then(({ data: { Links } }) => { - const id = Links?.ActiveSoftwareImage['@odata.id'].split('/').pop(); - commit('setActiveBmcFirmwareId', id); - }) - .catch((error) => console.log(error)); - }, - getActiveHostFirmware({ commit }) { - return api - .get('/redfish/v1/Systems/system/Bios') - .then(({ data: { Links } }) => { - const id = Links?.ActiveSoftwareImage['@odata.id'].split('/').pop(); - commit('setActiveHostFirmwareId', id); - }) - .catch((error) => console.log(error)); - }, - async getFirmwareInventory({ commit }) { - const inventoryList = await api - .get('/redfish/v1/UpdateService/FirmwareInventory') - .then(({ data: { Members = [] } = {} }) => - Members.map((item) => api.get(item['@odata.id'])) - ) - .catch((error) => console.log(error)); - await api - .all(inventoryList) - .then((response) => { - const bmcFirmware = []; - const hostFirmware = []; - response.forEach(({ data }) => { - const firmwareType = data?.RelatedItem?.[0]?.['@odata.id'] - .split('/') - .pop(); - const item = { - version: data?.Version, - id: data?.Id, - location: data?.['@odata.id'], - status: data?.Status?.Health, - }; - if (firmwareType === 'bmc') { - bmcFirmware.push(item); - } else if (firmwareType === 'Bios') { - hostFirmware.push(item); - } - }); - commit('setBmcFirmware', bmcFirmware); - commit('setHostFirmware', hostFirmware); - }) - .catch((error) => { - console.log(error); - }); - }, - getUpdateServiceSettings({ commit }) { - api - .get('/redfish/v1/UpdateService') - .then(({ data }) => { - const applyTime = - data.HttpPushUriOptions.HttpPushUriApplyTime.ApplyTime; - const allowableActions = - data?.Actions?.['#UpdateService.SimpleUpdate']?.[ - 'TransferProtocol@Redfish.AllowableValues' - ]; - - commit('setApplyTime', applyTime); - if (allowableActions.includes('TFTP')) { - commit('setTftpUploadAvailable', true); - } - }) - .catch((error) => console.log(error)); - }, - setApplyTimeImmediate({ commit }) { - const data = { - HttpPushUriOptions: { - HttpPushUriApplyTime: { - ApplyTime: 'Immediate', - }, - }, - }; - return api - .patch('/redfish/v1/UpdateService', data) - .then(() => commit('setApplyTime', 'Immediate')) - .catch((error) => console.log(error)); - }, - async uploadFirmware({ state, dispatch }, image) { - if (state.applyTime !== 'Immediate') { - // ApplyTime must be set to Immediate before making - // request to update firmware - await dispatch('setApplyTimeImmediate'); - } - return await api - .post('/redfish/v1/UpdateService', image, { - headers: { 'Content-Type': 'application/octet-stream' }, - }) - .catch((error) => { - console.log(error); - throw new Error(i18n.t('pageFirmware.toast.errorUploadAndReboot')); - }); - }, - async uploadFirmwareTFTP({ state, dispatch }, fileAddress) { - const data = { - TransferProtocol: 'TFTP', - ImageURI: fileAddress, - }; - if (state.applyTime !== 'Immediate') { - // ApplyTime must be set to Immediate before making - // request to update firmware - await dispatch('setApplyTimeImmediate'); - } - return await api - .post( - '/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate', - data - ) - .catch((error) => { - console.log(error); - throw new Error(i18n.t('pageFirmware.toast.errorUploadAndReboot')); - }); - }, - async switchFirmwareAndReboot({ getters }) { - const backupLoaction = getters.backupBmcFirmware.location; - const data = { - Links: { - ActiveSoftwareImage: { - '@odata.id': backupLoaction, - }, - }, - }; - return await api - .patch('/redfish/v1/Managers/bmc', data) - .catch((error) => { - console.log(error); - throw new Error( - i18n.t('pageFirmware.singleFileUpload.toast.errorSwitchImages') - ); - }); - }, - }, -}; - -export default FirmwareSingleImageStore; diff --git a/src/env/store/ibm.js b/src/env/store/ibm.js index e19dd48c..980236fc 100644 --- a/src/env/store/ibm.js +++ b/src/env/store/ibm.js @@ -1,11 +1,8 @@ import store from '@/store'; -import FirmwareSingleImageStore from './FirmwareSingleImage/FirmwareSingleImageStore'; import DumpsStore from './Dumps/DumpsStore'; store.unregisterModule('virtualMedia'); -store.unregisterModule('firmware'); -store.registerModule('firmwareSingleImage', FirmwareSingleImageStore); store.registerModule('dumps', DumpsStore); export default store; diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 714027bb..745fcba8 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -261,110 +261,54 @@ } }, "pageFirmware": { - "backup": "Backup:", - "bmcStatus": "BMC status", - "current": "Current:", - "firmwareOnBmc": "Firmware on BMC", - "firmwareOnHost": "Firmware on host", - "hostStatus": "Host status", - "makeCurrentVersion": "Make current version", - "pageDescription": "Update firmware by uploading a BMC or Host image file from your workstation or TFTP server", - "running": "Running", - "state": "State", - "updateCode": "Update code", + "cardActionSwitchToRunning": "Switch to running", + "cardBodyVersion": "Version", + "cardTitleBackup": "Backup image", + "cardTitleRunning": "Running image", + "sectionTitleBmcCards": "BMC", + "sectionTitleBmcCardsCombined": "BMC and server", + "sectionTitleHostCards": "Host", + "sectionTitleUpdateFirmware": "Update firmware", "alert": { - "updateProcess": "Update process", - "updateProcessInfo": "The new image will be uploaded and activated. After that, the BMC or host will reboot automatically to run from the new image." + "operationInProgress": "Server power operation in progress.", + "serverMustBePoweredOffTo": "Server must be powered off to:", + "serverMustBePoweredOffToUpdateFirmware": "Server must be powered off to update firmware", + "switchRunningAndBackupImages": "Switch running and backup images", + "updateFirmware": "Update firmware", + "viewServerPowerOperations": "View server power operations" }, "form": { - "imageFile": "Image file", - "imageFileName": "Image file name", - "onlyTarFilesAccepted": "Only .tar files accepted", - "tftpServer": "TFTP server", - "tftpServerAddress": "TFTP server address", - "tftpServerAddressHelper": "IP address or FQDN", - "uploadAndRebootBmc": "Upload and reboot BMC", - "uploadAndRebootBmcOrHost": "Upload and reboot BMC or host", - "uploadLocation": "Upload location", - "workstation": "Workstation" + "updateFirmware": { + "fileAddress": "File address", + "fileSource": "File source", + "imageFile": "Image file", + "imageFileHelperText": "Only .tar files accepted", + "startUpdate": "Start update", + "tftpServer": "TFTP server", + "workstation": "Workstation" + } }, "modal": { - "connectionToBmcWillBeLost": "Connection to BMC will be lost", - "rebootFromBackup": { - "message1": "A BMC reboot is required before the system can run the backup image %{backup}. The reboot will cause a disconnection, and may require logging in again.", - "message2": "The current firmware image %{current} will be moved to backup. During the reboot, server cannot be powered back on.", - "message3": "Are you sure you want to reboot the BMC from backup image %{backup}?", - "primaryAction": "Reboot BMC from backup image", - "title": "@:pageFirmware.modal.connectionToBmcWillBeLost" - }, - "uploadAndRebootBmcOrHost": { - "message1": "A BMC or host reboot is required before the system can run the new firmware image. The reboot will cause a disconnection, and may require logging in again.", - "message2": "The backup image will be permanently deleted.", - "message3": "Are you sure you want to upload the new firmware image and reboot the BMC or host?", - "primaryAction": "Upload and reboot BMC or host", - "title": "Connection to BMC or host will be lost" - } + "switchImages": "Switch images", + "switchRunningImage": "Switch running image", + "switchRunningImageInfo": "A BMC reboot is required to run the backup image. The application might be unresponsive during this time.", + "switchRunningImageInfo2": "Are you sure you want to switch to the backup image (%{backup})?", + "updateFirmwareInfo": "The BMC will reboot during the update process. The server cannot be powered on until the update is finished.", + "updateFirmwareInfo2": "The running image (%{running}) will be copied to backup. The backup image will be deleted.", + "updateFirmwareInfo3": "Are you sure you want to proceed with the update?", + "updateFirmwareInfoDefault": "The new image will be uploaded and activated. After that, the BMC or host will reboot automatically to run from the new image." }, "toast": { - "errorRebootFromBackup": "Error rebooting from backup image.", - "errorUploadAndReboot": "Error uploading image.", - "infoRefreshApplicationMessage": "Refresh the application to confirm the code update has completed and was successful.", - "infoRefreshApplicationTitle": "Verify code update", - "infoUploadStartTimeMessage": "Start time: %{startTime}", - "infoUploadStartTimeTitle": "Upload started", - "successRebootFromBackup": "Successfully started reboot from backup image.", - "successUploadMessage": "The upload was successful. During code update, the BMC will be not be responsive. Wait for the code update notification before making any changes.", - "successUploadTitle": "Code update started" - }, - "singleFileUpload": { - "cardActionSwitchToRunning": "Switch to running", - "cardBodyVersion": "Version", - "cardTitleBackup": "Backup image", - "cardTitleRunning": "Running image", - "sectionTitleBmcCards": "BMC", - "sectionTitleBmcCardsCombined": "BMC and server", - "sectionTitleHostCards": "Host", - "sectionTitleUpdateFirmware": "Update firmware", - "alert": { - "operationInProgress": "Server power operation in progress.", - "serverMustBePoweredOffTo": "Server must be powered off to:", - "serverMustBePoweredOffToUpdateFirmware": "Server must be powered off to update firmware", - "switchRunningAndBackupImages": "Switch running and backup images", - "updateFirmware": "Update firmware", - "viewServerPowerOperations": "View server power operations" - }, - "form": { - "updateFirmware": { - "fileAddress": "File address", - "fileSource": "File source", - "imageFile": "Image file", - "imageFileHelperText": "Only .tar files accepted", - "startUpdate": "Start update", - "tftpServer": "TFTP server", - "workstation": "Workstation" - } - }, - "modal": { - "switchImages": "Switch images", - "switchRunningImage": "Switch running image", - "switchRunningImageInfo": "A BMC reboot is required to run the backup image. The application might be unresponsive during this time.", - "switchRunningImageInfo2": "Are you sure you want to switch to the backup image (%{backup})?", - "updateFirmwareInfo": "The BMC will reboot during the update process. The server cannot be powered on until the update is finished.", - "updateFirmwareInfo2": "The running image (%{running}) will be copied to backup. The backup image will be deleted.", - "updateFirmwareInfo3": "Are you sure you want to proceed with the update?", - "updateFirmwareInfoDefault": "The new image will be uploaded and activated. After that, the BMC or host will reboot automatically to run from the new image." - }, - "toast": { - "errorSwitchImages": "Error switching running and backup images.", - "rebootStarted": "Reboot started", - "rebootStartedMessage": "Successfully started reboot from backup image.", - "updateStarted": "Update started", - "updateStartedMessage": "Wait for the firmware update notification before making any changes.", - "verifySwitch": "Verify switch", - "verifySwitchMessage": "Refresh the application to verify the running and backup images switched.", - "verifyUpdate": "Verify update", - "verifyUpdateMessage": "Refresh the application to verify firmware updated successfully" - } + "errorSwitchImages": "Error switching running and backup images.", + "errorUpdateFirmware": "Error starting firmware update.", + "rebootStarted": "Reboot started", + "rebootStartedMessage": "Successfully started reboot from backup image.", + "updateStarted": "Update started", + "updateStartedMessage": "Wait for the firmware update notification before making any changes.", + "verifySwitch": "Verify switch", + "verifySwitchMessage": "Refresh the application to verify the running and backup images switched.", + "verifyUpdate": "Verify update", + "verifyUpdateMessage": "Refresh the application to verify firmware updated successfully" } }, "pageHardwareStatus": { diff --git a/src/store/modules/Configuration/FirmwareStore.js b/src/store/modules/Configuration/FirmwareStore.js index 59a421d8..3b4bd853 100644 --- a/src/store/modules/Configuration/FirmwareStore.js +++ b/src/store/modules/Configuration/FirmwareStore.js @@ -1,156 +1,123 @@ 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: { - bmcFirmware: { - currentVersion: null, - currentState: null, - currentLocation: null, - backupVersion: null, - backupState: null, - backupLocation: null, - }, - hostFirmware: { - currentVersion: null, - currentState: null, - currentLocation: null, - backupVersion: null, - backupState: null, - backupLocation: null, - }, + bmcFirmware: [], + hostFirmware: [], + bmcActiveFirmwareId: null, + hostActiveFirmwareId: null, applyTime: null, + tftpAvailable: false, }, getters: { - 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: { - setBmcFirmwareCurrent: (state, { version, location, status }) => { - state.bmcFirmware.currentVersion = version; - state.bmcFirmware.currentState = status; - state.bmcFirmware.currentLocation = location; + isTftpUploadAvailable: (state) => state.tftpAvailable, + isSingleFileUploadEnabled: (state) => state.hostFirmware.length === 0, + activeBmcFirmware: (state) => { + return state.bmcFirmware.find( + (firmware) => firmware.id === state.bmcActiveFirmwareId + ); }, - setBmcFirmwareBackup: (state, { version, location, status }) => { - state.bmcFirmware.backupVersion = version; - state.bmcFirmware.backupState = status; - state.bmcFirmware.backupLocation = location; + activeHostFirmware: (state) => { + return state.hostFirmware.find( + (firmware) => firmware.id === state.hostActiveFirmwareId + ); }, - setHostFirmwareCurrent: (state, { version, location, status }) => { - state.hostFirmware.currentVersion = version; - state.hostFirmware.currentState = status; - state.hostFirmware.currentLocation = location; + backupBmcFirmware: (state) => { + return state.bmcFirmware.find( + (firmware) => firmware.id !== state.bmcActiveFirmwareId + ); }, - setHostFirmwareBackup: (state, { version, location, status }) => { - state.hostFirmware.backupVersion = version; - state.hostFirmware.backupState = status; - state.hostFirmware.backupLocation = location; + backupHostFirmware: (state) => { + return state.hostFirmware.find( + (firmware) => firmware.id !== state.hostActiveFirmwareId + ); }, + }, + mutations: { + setActiveBmcFirmwareId: (state, id) => (state.bmcActiveFirmwareId = id), + setActiveHostFirmwareId: (state, id) => (state.hostActiveFirmwareId = id), + setBmcFirmware: (state, firmware) => (state.bmcFirmware = firmware), + setHostFirmware: (state, firmware) => (state.hostFirmware = firmware), setApplyTime: (state, applyTime) => (state.applyTime = applyTime), + setTftpUploadAvailable: (state, tftpAvailable) => + (state.tftpAvailable = tftpAvailable), }, actions: { async getFirmwareInformation({ dispatch }) { - return await api.all([ - dispatch('getBmcFirmware'), - dispatch('getHostFirmware'), - ]); + dispatch('getActiveHostFirmware'); + dispatch('getActiveBmcFirmware'); + return await dispatch('getFirmwareInventory'); }, - async getBmcFirmware({ commit }) { - return await api + getActiveBmcFirmware({ commit }) { + return api .get('/redfish/v1/Managers/bmc') .then(({ data: { Links } }) => { - const currentLocation = Links.ActiveSoftwareImage['@odata.id']; - // Check SoftwareImages list for not ActiveSoftwareImage id - 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, - }); + const id = Links?.ActiveSoftwareImage['@odata.id'].split('/').pop(); + commit('setActiveBmcFirmwareId', id); }) .catch((error) => console.log(error)); }, - async getHostFirmware({ commit }) { - return await api + getActiveHostFirmware({ commit }) { + return 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 }; + const id = Links?.ActiveSoftwareImage['@odata.id'].split('/').pop(); + commit('setActiveHostFirmwareId', id); }) - .then(async ({ currentLocation, backupLocation }) => { - const currentData = await api.get(currentLocation); - let backupData = {}; - - if (backupLocation) { - backupData = await api.get(backupLocation); - } - - commit('setHostFirmwareCurrent', { - version: currentData?.data?.Version, - location: currentData?.data?.['@odata.id'], - status: currentData?.data?.Status?.State, - }); - commit('setHostFirmwareBackup', { - version: backupData.data?.Version, - location: backupData.data?.['@odata.id'], - status: backupData.data?.Status?.State, + .catch((error) => console.log(error)); + }, + async getFirmwareInventory({ commit }) { + const inventoryList = await api + .get('/redfish/v1/UpdateService/FirmwareInventory') + .then(({ data: { Members = [] } = {} }) => + Members.map((item) => api.get(item['@odata.id'])) + ) + .catch((error) => console.log(error)); + await api + .all(inventoryList) + .then((response) => { + const bmcFirmware = []; + const hostFirmware = []; + response.forEach(({ data }) => { + const firmwareType = data?.RelatedItem?.[0]?.['@odata.id'] + .split('/') + .pop(); + const item = { + version: data?.Version, + id: data?.Id, + location: data?.['@odata.id'], + status: data?.Status?.Health, + }; + if (firmwareType === 'bmc') { + bmcFirmware.push(item); + } else if (firmwareType === 'Bios') { + hostFirmware.push(item); + } }); + commit('setBmcFirmware', bmcFirmware); + commit('setHostFirmware', hostFirmware); }) - .catch((error) => console.log(error)); + .catch((error) => { + console.log(error); + }); }, - getUpdateServiceApplyTime({ commit }) { + getUpdateServiceSettings({ commit }) { api .get('/redfish/v1/UpdateService') .then(({ data }) => { const applyTime = data.HttpPushUriOptions.HttpPushUriApplyTime.ApplyTime; + const allowableActions = + data?.Actions?.['#UpdateService.SimpleUpdate']?.[ + 'TransferProtocol@Redfish.AllowableValues' + ]; + commit('setApplyTime', applyTime); + if (allowableActions.includes('TFTP')) { + commit('setTftpUploadAvailable', true); + } }) .catch((error) => console.log(error)); }, @@ -177,17 +144,15 @@ const FirmwareStore = { .post('/redfish/v1/UpdateService', image, { headers: { 'Content-Type': 'application/octet-stream' }, }) - .then(() => dispatch('getSystemFirwareVersion')) - .then(() => i18n.t('pageFirmware.toast.successUploadMessage')) .catch((error) => { console.log(error); - throw new Error(i18n.t('pageFirmware.toast.errorUploadAndReboot')); + throw new Error(i18n.t('pageFirmware.toast.errorUpdateFirmware')); }); }, - async uploadFirmwareTFTP({ state, dispatch }, { address, filename }) { + async uploadFirmwareTFTP({ state, dispatch }, fileAddress) { const data = { TransferProtocol: 'TFTP', - ImageURI: `${address}/${filename}`, + ImageURI: fileAddress, }; if (state.applyTime !== 'Immediate') { // ApplyTime must be set to Immediate before making @@ -199,15 +164,13 @@ const FirmwareStore = { '/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate', data ) - .then(() => dispatch('getSystemFirwareVersion')) - .then(() => i18n.t('pageFirmware.toast.successUploadMessage')) .catch((error) => { console.log(error); - throw new Error(i18n.t('pageFirmware.toast.errorUploadAndReboot')); + throw new Error(i18n.t('pageFirmware.toast.errorUpdateFirmware')); }); }, - async switchBmcFirmware({ state }) { - const backupLocation = state.bmcFirmware.backupLocation; + async switchBmcFirmwareAndReboot({ getters }) { + const backupLocation = getters.backupBmcFirmware.location; const data = { Links: { ActiveSoftwareImage: { @@ -217,10 +180,9 @@ const FirmwareStore = { }; return await api .patch('/redfish/v1/Managers/bmc', data) - .then(() => i18n.t('pageFirmware.toast.successRebootFromBackup')) .catch((error) => { console.log(error); - throw new Error(i18n.t('pageFirmware.toast.errorRebootFromBackup')); + throw new Error(i18n.t('pageFirmware.toast.errorSwitchImages')); }); }, }, diff --git a/src/views/Configuration/Firmware/Firmware.vue b/src/views/Configuration/Firmware/Firmware.vue index 5001702a..e27c8a26 100644 --- a/src/views/Configuration/Firmware/Firmware.vue +++ b/src/views/Configuration/Firmware/Firmware.vue @@ -1,378 +1,93 @@ - - diff --git a/src/views/Configuration/Firmware/FirmwareAlertServerPower.vue b/src/views/Configuration/Firmware/FirmwareAlertServerPower.vue new file mode 100644 index 00000000..04713115 --- /dev/null +++ b/src/views/Configuration/Firmware/FirmwareAlertServerPower.vue @@ -0,0 +1,50 @@ + + + diff --git a/src/views/Configuration/Firmware/FirmwareCardsBmc.vue b/src/views/Configuration/Firmware/FirmwareCardsBmc.vue new file mode 100644 index 00000000..2f038b9e --- /dev/null +++ b/src/views/Configuration/Firmware/FirmwareCardsBmc.vue @@ -0,0 +1,133 @@ + + + diff --git a/src/views/Configuration/Firmware/FirmwareCardsHost.vue b/src/views/Configuration/Firmware/FirmwareCardsHost.vue new file mode 100644 index 00000000..b4a8e90d --- /dev/null +++ b/src/views/Configuration/Firmware/FirmwareCardsHost.vue @@ -0,0 +1,73 @@ + + + + + diff --git a/src/views/Configuration/Firmware/FirmwareFormUpdate.vue b/src/views/Configuration/Firmware/FirmwareFormUpdate.vue new file mode 100644 index 00000000..9f67e8d0 --- /dev/null +++ b/src/views/Configuration/Firmware/FirmwareFormUpdate.vue @@ -0,0 +1,204 @@ + + + diff --git a/src/views/Configuration/Firmware/FirmwareModalRebootBackupBmc.vue b/src/views/Configuration/Firmware/FirmwareModalRebootBackupBmc.vue deleted file mode 100644 index 305bb6cb..00000000 --- a/src/views/Configuration/Firmware/FirmwareModalRebootBackupBmc.vue +++ /dev/null @@ -1,34 +0,0 @@ - - - diff --git a/src/views/Configuration/Firmware/FirmwareModalSwitchToRunning.vue b/src/views/Configuration/Firmware/FirmwareModalSwitchToRunning.vue new file mode 100644 index 00000000..dc4a4973 --- /dev/null +++ b/src/views/Configuration/Firmware/FirmwareModalSwitchToRunning.vue @@ -0,0 +1,31 @@ + + + diff --git a/src/views/Configuration/Firmware/FirmwareModalUpdateFirmware.vue b/src/views/Configuration/Firmware/FirmwareModalUpdateFirmware.vue new file mode 100644 index 00000000..18355217 --- /dev/null +++ b/src/views/Configuration/Firmware/FirmwareModalUpdateFirmware.vue @@ -0,0 +1,44 @@ + + + diff --git a/src/views/Configuration/Firmware/FirmwareModalUpload.vue b/src/views/Configuration/Firmware/FirmwareModalUpload.vue deleted file mode 100644 index 3425904f..00000000 --- a/src/views/Configuration/Firmware/FirmwareModalUpload.vue +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/src/views/Overview/Overview.vue b/src/views/Overview/Overview.vue index 1d2da441..2436e393 100644 --- a/src/views/Overview/Overview.vue +++ b/src/views/Overview/Overview.vue @@ -104,13 +104,6 @@ export default { PageSection, }, mixins: [LoadingBarMixin], - data() { - return { - firmwareStoreModuleName: this.$store.hasModule('firmwareSingleImage') - ? 'firmwareSingleImage' - : 'firmware', - }; - }, computed: { ...mapState({ server: (state) => state.system.systems[0], @@ -129,15 +122,18 @@ export default { if (this.server) return this.server.serialNumber || '--'; return '--'; }, - hostFirmwareVersion() { - if (this.server) return this.server.firmwareVersion || '--'; - return '--'; - }, }), + activeHostFirmware() { + return this.$store.getters[`firmware/activeHostFirmware`]; + }, + hostFirmwareVersion() { + return this.activeHostFirmware?.version || '--'; + }, + activeBmcFirmware() { + return this.$store.getters[`firmware/activeBmcFirmware`]; + }, bmcFirmwareVersion() { - return this.$store.getters[ - `${this.firmwareStoreModuleName}/bmcFirmwareCurrentVersion` - ]; + return this.activeBmcFirmware?.version || '--'; }, }, created() { @@ -153,9 +149,7 @@ export default { }); Promise.all([ this.$store.dispatch('system/getSystem'), - this.$store.dispatch( - `${this.firmwareStoreModuleName}/getFirmwareInformation` - ), + this.$store.dispatch(`firmware/getFirmwareInformation`), this.$store.dispatch('powerControl/getPowerControl'), quicklinksPromise, networkPromise, -- cgit v1.2.3