diff options
author | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2021-02-19 02:24:14 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2021-03-01 16:45:05 +0300 |
commit | 33d755f4e62beff72101f6ca07e4d31b04e13826 (patch) | |
tree | a67d890472f0c7f27951b8e86d472e220dac066e | |
parent | 9a25c80591e8872297f2c33ad9bcd6a97639f04c (diff) | |
download | webui-vue-33d755f4e62beff72101f6ca07e4d31b04e13826.tar.xz |
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 <yoshiemuranaka@gmail.com>
Change-Id: Ib5465ecc30dd1505824bf41c82d33b7655d5e598
18 files changed, 297 insertions, 1092 deletions
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 @@ -<template> - <b-modal - id="modal-update-firmware" - :title="$t('pageFirmware.singleFileUpload.sectionTitleUpdateFirmware')" - :ok-title=" - $t('pageFirmware.singleFileUpload.form.updateFirmware.startUpdate') - " - :cancel-title="$t('global.action.cancel')" - @ok="$emit('ok')" - > - <template v-if="isSingleFileUploadEnabled"> - <p> - {{ $t('pageFirmware.singleFileUpload.modal.updateFirmwareInfo') }} - </p> - <p> - {{ - $t('pageFirmware.singleFileUpload.modal.updateFirmwareInfo2', { - running: runningBmcVersion, - }) - }} - </p> - <p class="m-0"> - {{ $t('pageFirmware.singleFileUpload.modal.updateFirmwareInfo3') }} - </p> - </template> - <template v-else> - {{ $t('pageFirmware.singleFileUpload.modal.updateFirmwareInfoDefault') }} - </template> - </b-modal> -</template> - -<script> -export default { - computed: { - runningBmc() { - return this.$store.getters['firmwareSingleImage/activeBmcFirmware']; - }, - runningBmcVersion() { - return this.runningBmc?.version || '--'; - }, - isSingleFileUploadEnabled() { - return this.$store.getters[ - 'firmwareSingleImage/isSingleFileUploadEnabled' - ]; - }, - }, -}; -</script> 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 @@ -<template> - <b-container fluid="xl"> - <page-title /> - <alerts-server-power - v-if="isServerPowerOffRequired" - :is-host-off="isHostOff" - /> - - <!-- Firmware cards --> - <b-row> - <b-col xl="10"> - <!-- BMC Firmware --> - <bmc-cards :is-page-disabled="isPageDisabled" /> - - <!-- Host Firmware --> - <host-cards v-if="!isSingleFileUploadEnabled" /> - </b-col> - </b-row> - - <!-- Update firmware--> - <page-section - :section-title=" - $t('pageFirmware.singleFileUpload.sectionTitleUpdateFirmware') - " - > - <b-row> - <b-col sm="8" md="6" xl="4"> - <!-- Update form --> - <form-update - :is-host-off="isHostOff" - :is-page-disabled="isPageDisabled" - /> - </b-col> - </b-row> - </page-section> - </b-container> -</template> - -<script> -import AlertsServerPower from './FirmwareAlertServerPower'; -import BmcCards from './FirmwareCardsBmc'; -import FormUpdate from './FirmwareFormUpdate'; -import HostCards from './FirmwareCardsHost'; -import PageSection from '@/components/Global/PageSection'; -import PageTitle from '@/components/Global/PageTitle'; - -import LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin'; - -export default { - name: 'FirmwareSingleImage', - components: { - AlertsServerPower, - BmcCards, - FormUpdate, - HostCards, - PageSection, - PageTitle, - }, - mixins: [LoadingBarMixin], - beforeRouteLeave(to, from, next) { - this.hideLoader(); - next(); - }, - data() { - return { - loading, - isServerPowerOffRequired: - process.env.VUE_APP_SERVER_OFF_REQUIRED === 'true', - }; - }, - computed: { - hostStatus() { - return this.$store.getters['global/hostStatus']; - }, - isHostOff() { - return this.hostStatus === 'off' ? true : false; - }, - isSingleFileUploadEnabled() { - return this.$store.getters[ - 'firmwareSingleImage/isSingleFileUploadEnabled' - ]; - }, - isPageDisabled() { - if (this.isServerPowerOffRequired) { - return !this.isHostOff || this.loading || this.isOperationInProgress; - } - return this.loading || this.isOperationInProgress; - }, - }, - created() { - this.startLoader(); - this.$store - .dispatch('firmwareSingleImage/getFirmwareInformation') - .finally(() => this.endLoader()); - }, -}; -</script> 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 @@ <template> <b-container fluid="xl"> - <page-title :description="$t('pageFirmware.pageDescription')" /> - <b-row class="mb-4"> - <b-col md="10" lg="12" xl="8" class="pr-xl-4"> - <!-- Firmware on BMC --> - <page-section :section-title="$t('pageFirmware.firmwareOnBmc')"> - <b-card-group deck> - <!-- Current FW --> - <b-card header-bg-variant="success"> - <template #header> - <dl class="mb-0"> - <dt>{{ $t('pageFirmware.current') }}</dt> - <dd class="mb-0">{{ bmcFirmwareCurrentVersion }}</dd> - </dl> - </template> - <dl class="my-0"> - <dt>{{ $t('pageFirmware.state') }}:</dt> - <dd>{{ bmcFirmwareCurrentState }}</dd> - </dl> - <template #footer></template> - </b-card> - - <!-- Backup FW --> - <b-card footer-class="p-0"> - <template #header> - <dl class="mb-0"> - <dt>{{ $t('pageFirmware.backup') }}</dt> - <dd class="mb-0">{{ bmcFirmwareBackupVersion }}</dd> - </dl> - </template> - <dl class="my-0"> - <dt>{{ $t('pageFirmware.state') }}:</dt> - <dd>{{ bmcFirmwareBackupState }}</dd> - </dl> - <template #footer> - <b-btn - v-b-modal.modal-reboot-backup-bmc - :disabled="!bmcFirmwareBackupVersion" - variant="link" - size="sm" - > - <icon-switch class="d-none d-sm-inline-block" /> - {{ $t('pageFirmware.makeCurrentVersion') }}</b-btn - > - </template> - </b-card> - </b-card-group> - </page-section> - - <!-- Firmware on Host --> - <page-section :section-title="$t('pageFirmware.firmwareOnHost')"> - <b-card-group deck> - <!-- Current FW --> - <b-card header-bg-variant="success"> - <template #header> - <dl class="mb-0"> - <dt>{{ $t('pageFirmware.current') }}</dt> - <dd class="mb-0">{{ hostFirmwareCurrentVersion }}</dd> - </dl> - </template> - <!-- State --> - <dl class="my-0"> - <dt>{{ $t('pageFirmware.state') }}:</dt> - <dd>{{ hostFirmwareCurrentState }}</dd> - </dl> - </b-card> - - <!-- Backup FW --> - <b-card> - <template #header> - <dl class="mb-0"> - <dt>{{ $t('pageFirmware.backup') }}</dt> - <dd class="mb-0">{{ hostFirmwareBackupVersion }}</dd> - </dl> - </template> - <!-- State --> - <dl class="my-0"> - <dt>{{ $t('pageFirmware.state') }}:</dt> - <dd>{{ hostFirmwareBackupState }}</dd> - </dl> - </b-card> - </b-card-group> - </page-section> - </b-col> - - <!-- Update code --> - <b-col sm="8" xl="4" class="update-code pl-xl-4"> - <page-section :section-title="$t('pageFirmware.updateCode')"> - <b-form @submit.prevent="onSubmitUpload"> - <b-form-group :label="$t('pageFirmware.form.uploadLocation')"> - <b-form-radio v-model="isWorkstationSelected" :value="true"> - {{ $t('pageFirmware.form.workstation') }} - </b-form-radio> - <b-form-radio v-model="isWorkstationSelected" :value="false"> - {{ $t('pageFirmware.form.tftpServer') }} - </b-form-radio> - </b-form-group> - - <!-- Workstation Upload --> - <template v-if="isWorkstationSelected"> - <b-form-group :label="$t('pageFirmware.form.imageFile')"> - <b-form-text id="image-file-help-block"> - {{ $t('pageFirmware.form.onlyTarFilesAccepted') }} - </b-form-text> - <form-file - id="image-file" - accept=".tar" - :state="getValidationState($v.file)" - aria-describedby="image-file-help-block" - @input="onFileUpload($event)" - > - <template #invalid> - <b-form-invalid-feedback role="alert"> - {{ $t('global.form.required') }} - </b-form-invalid-feedback> - </template> - </form-file> - </b-form-group> - </template> - - <!-- TFTP Server Upload --> - <template v-else> - <b-form-group - :label="$t('pageFirmware.form.tftpServerAddress')" - label-for="tftp-ip" - > - <b-form-text id="server-address-help-block"> - {{ $t('pageFirmware.form.tftpServerAddressHelper') }} - </b-form-text> - <b-form-input - id="tftp-id" - v-model="tftpIpAddress" - type="text" - :state="getValidationState($v.tftpIpAddress)" - aria-describedby="server-address-help-block" - @input="$v.tftpIpAddress.$touch()" - /> - <b-form-invalid-feedback role="alert"> - {{ $t('global.form.fieldRequired') }} - </b-form-invalid-feedback> - </b-form-group> - <b-form-group - :label="$t('pageFirmware.form.imageFileName')" - label-for="tftp-file-name" - > - <b-form-input - id="tftp-file-name" - v-model="tftpFileName" - type="text" - :state="getValidationState($v.tftpFileName)" - @input="$v.tftpFileName.$touch()" - /> - <b-form-invalid-feedback role="alert"> - {{ $t('global.form.fieldRequired') }} - </b-form-invalid-feedback> - </b-form-group> - </template> + <page-title /> + <alerts-server-power + v-if="isServerPowerOffRequired" + :is-host-off="isHostOff" + /> - <!-- Info alert --> - <alert variant="info" class="mt-4 mb-5"> - <p class="font-weight-bold mb-1"> - {{ $t('pageFirmware.alert.updateProcess') }} - </p> - <p>{{ $t('pageFirmware.alert.updateProcessInfo') }}</p> - </alert> + <!-- Firmware cards --> + <b-row> + <b-col xl="10"> + <!-- BMC Firmware --> + <bmc-cards :is-page-disabled="isPageDisabled" /> - <b-btn type="submit" variant="primary"> - {{ $t('pageFirmware.form.uploadAndRebootBmcOrHost') }} - </b-btn> - </b-form> - </page-section> + <!-- Host Firmware --> + <host-cards v-if="!isSingleFileUploadEnabled" /> </b-col> </b-row> - <!-- Modals --> - <modal-upload @ok="uploadFirmware" /> - <modal-reboot-backup-bmc - :current="bmcFirmwareCurrentVersion || '--'" - :backup="bmcFirmwareBackupVersion || '--'" - @ok="switchBmcFirmware" - /> + <!-- Update firmware--> + <page-section + :section-title="$t('pageFirmware.sectionTitleUpdateFirmware')" + > + <b-row> + <b-col sm="8" md="6" xl="4"> + <!-- Update form --> + <form-update + :is-host-off="isHostOff" + :is-page-disabled="isPageDisabled" + /> + </b-col> + </b-row> + </page-section> </b-container> </template> <script> -import { requiredIf } from 'vuelidate/lib/validators'; -import { mapGetters } from 'vuex'; -import IconSwitch from '@carbon/icons-vue/es/arrows--horizontal/20'; - +import AlertsServerPower from './FirmwareAlertServerPower'; +import BmcCards from './FirmwareCardsBmc'; +import FormUpdate from './FirmwareFormUpdate'; +import HostCards from './FirmwareCardsHost'; import PageSection from '@/components/Global/PageSection'; import PageTitle from '@/components/Global/PageTitle'; -import Alert from '@/components/Global/Alert'; -import ModalUpload from './FirmwareModalUpload'; -import ModalRebootBackupBmc from './FirmwareModalRebootBackupBmc'; -import FormFile from '@/components/Global/FormFile'; -import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; import LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin'; -import BVToastMixin from '@/components/Mixins/BVToastMixin'; export default { - name: 'Firmware', + name: 'FirmwareSingleImage', components: { - Alert, - IconSwitch, - ModalRebootBackupBmc, - ModalUpload, + AlertsServerPower, + BmcCards, + FormUpdate, + HostCards, PageSection, PageTitle, - FormFile, }, - mixins: [BVToastMixin, LoadingBarMixin, VuelidateMixin], + mixins: [LoadingBarMixin], beforeRouteLeave(to, from, next) { this.hideLoader(); - this.clearRebootTimeout(); next(); }, data() { return { - isWorkstationSelected: true, - file: null, - tftpIpAddress: null, - tftpFileName: null, - timeoutId: null, - loading: loading, + loading, + isServerPowerOffRequired: + process.env.VUE_APP_SERVER_OFF_REQUIRED === 'true', }; }, computed: { - ...mapGetters('firmware', [ - 'bmcFirmwareCurrentVersion', - 'bmcFirmwareCurrentState', - 'bmcFirmwareBackupVersion', - 'bmcFirmwareBackupState', - 'hostFirmwareCurrentVersion', - 'hostFirmwareCurrentState', - 'hostFirmwareBackupVersion', - 'hostFirmwareBackupState', - ]), - }, - watch: { - isWorkstationSelected: function () { - this.$v.$reset(); - this.file = null; - this.tftpIpAddress = null; - this.tftpFileName = null; + hostStatus() { + return this.$store.getters['global/hostStatus']; + }, + isHostOff() { + return this.hostStatus === 'off' ? true : false; + }, + isSingleFileUploadEnabled() { + return this.$store.getters['firmware/isSingleFileUploadEnabled']; + }, + isPageDisabled() { + if (this.isServerPowerOffRequired) { + return !this.isHostOff || this.loading || this.isOperationInProgress; + } + return this.loading || this.isOperationInProgress; }, }, created() { this.startLoader(); - this.$store.dispatch('firmware/getUpdateServiceApplyTime'); this.$store .dispatch('firmware/getFirmwareInformation') .finally(() => this.endLoader()); }, - validations() { - return { - file: { - required: requiredIf(function () { - return this.isWorkstationSelected; - }), - }, - tftpIpAddress: { - required: requiredIf(function () { - return !this.isWorkstationSelected; - }), - }, - tftpFileName: { - required: requiredIf(function () { - return !this.isWorkstationSelected; - }), - }, - }; - }, - methods: { - onFileUpload(file) { - this.file = file; - this.$v.file.$touch(); - }, - uploadFirmware() { - const startTime = this.$options.filters.formatTime(new Date()); - this.setRebootTimeout(360000); //6 minute timeout - this.infoToast( - this.$t('pageFirmware.toast.infoUploadStartTimeMessage', { startTime }), - { title: this.$t('pageFirmware.toast.infoUploadStartTimeTitle') } - ); - if (this.isWorkstationSelected) { - this.dispatchWorkstationUpload(); - } else { - this.dispatchTftpUpload(); - } - }, - dispatchWorkstationUpload() { - this.$store - .dispatch('firmware/uploadFirmware', this.file) - .then((success) => - this.infoToast(success, { - title: this.$t('pageFirmware.toast.successUploadTitle'), - }) - ) - .catch(({ message }) => { - this.errorToast(message); - this.clearRebootTimeout(); - }); - }, - dispatchTftpUpload() { - const data = { - address: this.tftpIpAddress, - filename: this.tftpFileName, - }; - this.$store - .dispatch('firmware/uploadFirmwareTFTP', data) - .then((success) => - this.infoToast(success, { - title: this.$t('pageFirmware.toast.successUploadTitle'), - }) - ) - .catch(({ message }) => { - this.errorToast(message); - this.clearRebootTimeout(); - }); - }, - switchBmcFirmware() { - this.setRebootTimeout(); - this.$store - .dispatch('firmware/switchBmcFirmware') - .then((success) => - this.infoToast(success, { title: this.$t('global.status.success') }) - ) - .catch(({ message }) => { - this.errorToast(message); - this.clearRebootTimeout(); - }); - }, - setRebootTimeout(timeoutMs = 60000) { - // Set a timeout to disable page interactions while - // an upload or BMC reboot is in progress - this.startLoader(); - this.timeoutId = setTimeout(() => { - this.endLoader(); - this.infoToast( - this.$t('pageFirmware.toast.infoRefreshApplicationMessage'), - { - title: this.$t('pageFirmware.toast.infoRefreshApplicationTitle'), - refreshAction: true, - } - ); - }, timeoutMs); - }, - clearRebootTimeout() { - if (this.timeoutId) { - clearTimeout(this.timeoutId); - this.endLoader(); - } - }, - onSubmitUpload() { - this.$v.$touch(); - if (this.$v.$invalid) return; - this.$bvModal.show('modal-upload'); - }, - }, }; </script> - -<style lang="scss" scoped> -.update-code { - border-left: none; - @include media-breakpoint-up(xl) { - border-left: 1px solid gray('300'); - } -} -.card-footer { - height: 40px; -} -.card-body { - padding: 0.75rem 1.25rem; -} -</style> diff --git a/src/env/components/FirmwareSingleImage/FirmwareAlertServerPower.vue b/src/views/Configuration/Firmware/FirmwareAlertServerPower.vue index f7ac0fc9..04713115 100644 --- a/src/env/components/FirmwareSingleImage/FirmwareAlertServerPower.vue +++ b/src/views/Configuration/Firmware/FirmwareAlertServerPower.vue @@ -4,35 +4,25 @@ <!-- Operation in progress alert --> <alert v-if="isOperationInProgress" variant="info" class="mb-5"> <p> - {{ $t('pageFirmware.singleFileUpload.alert.operationInProgress') }} + {{ $t('pageFirmware.alert.operationInProgress') }} </p> </alert> <!-- Power off server warning alert --> <alert v-else-if="!isHostOff" variant="warning" class="mb-5"> <p class="mb-0"> - {{ - $t('pageFirmware.singleFileUpload.alert.serverMustBePoweredOffTo') - }} + {{ $t('pageFirmware.alert.serverMustBePoweredOffTo') }} </p> <ul class="m-0"> <li> - {{ - $t( - 'pageFirmware.singleFileUpload.alert.switchRunningAndBackupImages' - ) - }} + {{ $t('pageFirmware.alert.switchRunningAndBackupImages') }} </li> <li> - {{ $t('pageFirmware.singleFileUpload.alert.updateFirmware') }} + {{ $t('pageFirmware.alert.updateFirmware') }} </li> </ul> <template #action> <b-link to="/control/server-power-operations"> - {{ - $t( - 'pageFirmware.singleFileUpload.alert.viewServerPowerOperations' - ) - }} + {{ $t('pageFirmware.alert.viewServerPowerOperations') }} </b-link> </template> </alert> diff --git a/src/env/components/FirmwareSingleImage/FirmwareCardsBmc.vue b/src/views/Configuration/Firmware/FirmwareCardsBmc.vue index 857adf0f..2f038b9e 100644 --- a/src/env/components/FirmwareSingleImage/FirmwareCardsBmc.vue +++ b/src/views/Configuration/Firmware/FirmwareCardsBmc.vue @@ -6,11 +6,11 @@ <b-card> <template #header> <p class="font-weight-bold m-0"> - {{ $t('pageFirmware.singleFileUpload.cardTitleRunning') }} + {{ $t('pageFirmware.cardTitleRunning') }} </p> </template> <dl class="mb-0"> - <dt>{{ $t('pageFirmware.singleFileUpload.cardBodyVersion') }}</dt> + <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt> <dd class="mb-0">{{ runningVersion }}</dd> </dl> </b-card> @@ -19,11 +19,11 @@ <b-card> <template #header> <p class="font-weight-bold m-0"> - {{ $t('pageFirmware.singleFileUpload.cardTitleBackup') }} + {{ $t('pageFirmware.cardTitleBackup') }} </p> </template> <dl> - <dt>{{ $t('pageFirmware.singleFileUpload.cardBodyVersion') }}</dt> + <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt> <dd> <status-icon v-if="showBackupImageStatus" status="danger" /> <span v-if="showBackupImageStatus" class="sr-only"> @@ -41,7 +41,7 @@ :disabled="isPageDisabled || !backup" > <icon-switch class="d-none d-sm-inline-block" /> - {{ $t('pageFirmware.singleFileUpload.cardActionSwitchToRunning') }} + {{ $t('pageFirmware.cardActionSwitchToRunning') }} </b-btn> </b-card> </b-card-group> @@ -75,23 +75,19 @@ export default { }, computed: { isSingleFileUploadEnabled() { - return this.$store.getters[ - 'firmwareSingleImage/isSingleFileUploadEnabled' - ]; + return this.$store.getters['firmware/isSingleFileUploadEnabled']; }, sectionTitle() { if (this.isSingleFileUploadEnabled) { - return this.$t( - 'pageFirmware.singleFileUpload.sectionTitleBmcCardsCombined' - ); + return this.$t('pageFirmware.sectionTitleBmcCardsCombined'); } - return this.$t('pageFirmware.singleFileUpload.sectionTitleBmcCards'); + return this.$t('pageFirmware.sectionTitleBmcCards'); }, running() { - return this.$store.getters['firmwareSingleImage/activeBmcFirmware']; + return this.$store.getters['firmware/activeBmcFirmware']; }, backup() { - return this.$store.getters['firmwareSingleImage/backupBmcFirmware']; + return this.$store.getters['firmware/backupBmcFirmware']; }, runningVersion() { return this.running?.version || '--'; @@ -113,26 +109,18 @@ export default { this.startLoader(); const timerId = setTimeout(() => { this.endLoader(); - this.infoToast( - this.$t('pageFirmware.singleFileUpload.toast.verifySwitchMessage'), - { - title: this.$t('pageFirmware.singleFileUpload.toast.verifySwitch'), - refreshAction: true, - } - ); + this.infoToast(this.$t('pageFirmware.toast.verifySwitchMessage'), { + title: this.$t('pageFirmware.toast.verifySwitch'), + refreshAction: true, + }); }, 60000); this.$store - .dispatch('firmwareSingleImage/switchFirmwareAndReboot') + .dispatch('firmware/switchBmcFirmwareAndReboot') .then(() => - this.infoToast( - this.$t('pageFirmware.singleFileUpload.toast.rebootStartedMessage'), - { - title: this.$t( - 'pageFirmware.singleFileUpload.toast.rebootStarted' - ), - } - ) + this.infoToast(this.$t('pageFirmware.toast.rebootStartedMessage'), { + title: this.$t('pageFirmware.toast.rebootStarted'), + }) ) .catch(({ message }) => { this.errorToast(message); diff --git a/src/env/components/FirmwareSingleImage/FirmwareCardsHost.vue b/src/views/Configuration/Firmware/FirmwareCardsHost.vue index c47f60f5..b4a8e90d 100644 --- a/src/env/components/FirmwareSingleImage/FirmwareCardsHost.vue +++ b/src/views/Configuration/Firmware/FirmwareCardsHost.vue @@ -1,17 +1,15 @@ <template> - <page-section - :section-title="$t('pageFirmware.singleFileUpload.sectionTitleHostCards')" - > + <page-section :section-title="$t('pageFirmware.sectionTitleHostCards')"> <b-card-group deck> <!-- Running image --> <b-card> <template #header> <p class="font-weight-bold m-0"> - {{ $t('pageFirmware.singleFileUpload.cardTitleRunning') }} + {{ $t('pageFirmware.cardTitleRunning') }} </p> </template> <dl class="mb-0"> - <dt>{{ $t('pageFirmware.singleFileUpload.cardBodyVersion') }}</dt> + <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt> <dd class="mb-0">{{ runningVersion }}</dd> </dl> </b-card> @@ -20,11 +18,11 @@ <b-card> <template #header> <p class="font-weight-bold m-0"> - {{ $t('pageFirmware.singleFileUpload.cardTitleBackup') }} + {{ $t('pageFirmware.cardTitleBackup') }} </p> </template> <dl class="mb-0"> - <dt>{{ $t('pageFirmware.singleFileUpload.cardBodyVersion') }}</dt> + <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt> <dd class="mb-0"> <status-icon v-if="showBackupImageStatus" status="danger" /> <span v-if="showBackupImageStatus" class="sr-only"> @@ -45,10 +43,10 @@ export default { components: { PageSection }, computed: { running() { - return this.$store.getters['firmwareSingleImage/activeHostFirmware']; + return this.$store.getters['firmware/activeHostFirmware']; }, backup() { - return this.$store.getters['firmwareSingleImage/backupHostFirmware']; + return this.$store.getters['firmware/backupHostFirmware']; }, runningVersion() { return this.running?.version || '--'; diff --git a/src/env/components/FirmwareSingleImage/FirmwareFormUpdate.vue b/src/views/Configuration/Firmware/FirmwareFormUpdate.vue index f13b8e00..9f67e8d0 100644 --- a/src/env/components/FirmwareSingleImage/FirmwareFormUpdate.vue +++ b/src/views/Configuration/Firmware/FirmwareFormUpdate.vue @@ -4,39 +4,25 @@ <b-form @submit.prevent="onSubmitUpload"> <b-form-group v-if="isTftpUploadAvailable" - :label=" - $t('pageFirmware.singleFileUpload.form.updateFirmware.fileSource') - " + :label="$t('pageFirmware.form.updateFirmware.fileSource')" :disabled="isPageDisabled" > <b-form-radio v-model="isWorkstationSelected" :value="true"> - {{ - $t( - 'pageFirmware.singleFileUpload.form.updateFirmware.workstation' - ) - }} + {{ $t('pageFirmware.form.updateFirmware.workstation') }} </b-form-radio> <b-form-radio v-model="isWorkstationSelected" :value="false"> - {{ - $t('pageFirmware.singleFileUpload.form.updateFirmware.tftpServer') - }} + {{ $t('pageFirmware.form.updateFirmware.tftpServer') }} </b-form-radio> </b-form-group> <!-- Workstation Upload --> <template v-if="isWorkstationSelected"> <b-form-group - :label=" - $t('pageFirmware.singleFileUpload.form.updateFirmware.imageFile') - " + :label="$t('pageFirmware.form.updateFirmware.imageFile')" label-for="image-file" > <b-form-text id="image-file-help-block"> - {{ - $t( - 'pageFirmware.singleFileUpload.form.updateFirmware.imageFileHelperText' - ) - }} + {{ $t('pageFirmware.form.updateFirmware.imageFileHelperText') }} </b-form-text> <form-file id="image-file" @@ -58,11 +44,7 @@ <!-- TFTP Server Upload --> <template v-else> <b-form-group - :label=" - $t( - 'pageFirmware.singleFileUpload.form.updateFirmware.fileAddress' - ) - " + :label="$t('pageFirmware.form.updateFirmware.fileAddress')" label-for="tftp-address" > <b-form-input @@ -84,9 +66,7 @@ variant="primary" :disabled="isPageDisabled" > - {{ - $t('pageFirmware.singleFileUpload.form.updateFirmware.startUpdate') - }} + {{ $t('pageFirmware.form.updateFirmware.startUpdate') }} </b-btn> <alert v-if="isServerPowerOffRequired && !isHostOff" @@ -96,9 +76,7 @@ > <p class="col-form-label"> {{ - $t( - 'pageFirmware.singleFileUpload.alert.serverMustBePoweredOffToUpdateFirmware' - ) + $t('pageFirmware.alert.serverMustBePoweredOffToUpdateFirmware') }} </p> </alert> @@ -147,7 +125,7 @@ export default { }, computed: { isTftpUploadAvailable() { - return this.$store.getters['firmwareSingleImage/isTftpUploadAvailable']; + return this.$store.getters['firmware/isTftpUploadAvailable']; }, }, watch: { @@ -172,28 +150,22 @@ export default { }; }, created() { - this.$store.dispatch('firmwareSingleImage/getUpdateServiceSettings'); + this.$store.dispatch('firmware/getUpdateServiceSettings'); }, methods: { updateFirmware() { this.startLoader(); const timerId = setTimeout(() => { this.endLoader(); - this.infoToast( - this.$t('pageFirmware.singleFileUpload.toast.verifyUpdateMessage'), - { - title: this.$t('pageFirmware.singleFileUpload.toast.verifyUpdate'), - refreshAction: true, - } - ); + this.infoToast(this.$t('pageFirmware.toast.verifyUpdateMessage'), { + title: this.$t('pageFirmware.toast.verifyUpdate'), + refreshAction: true, + }); }, 360000); - this.infoToast( - this.$t('pageFirmware.singleFileUpload.toast.updateStartedMessage'), - { - title: this.$t('pageFirmware.singleFileUpload.toast.updateStarted'), - timestamp: true, - } - ); + this.infoToast(this.$t('pageFirmware.toast.updateStartedMessage'), { + title: this.$t('pageFirmware.toast.updateStarted'), + timestamp: true, + }); if (this.isWorkstationSelected) { this.dispatchWorkstationUpload(timerId); } else { @@ -202,7 +174,7 @@ export default { }, dispatchWorkstationUpload(timerId) { this.$store - .dispatch('firmwareSingleImage/uploadFirmware', this.file) + .dispatch('firmware/uploadFirmware', this.file) .catch(({ message }) => { this.endLoader(); this.errorToast(message); @@ -211,10 +183,7 @@ export default { }, dispatchTftpUpload(timerId) { this.$store - .dispatch( - 'firmwareSingleImage/uploadFirmwareTFTP', - this.tftpFileAddress - ) + .dispatch('firmware/uploadFirmwareTFTP', this.tftpFileAddress) .catch(({ message }) => { this.endLoader(); this.errorToast(message); 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 @@ -<template> - <b-modal - id="modal-reboot-backup-bmc" - :ok-title="$t('pageFirmware.modal.rebootFromBackup.primaryAction')" - :cancel-title="$t('global.action.cancel')" - :title="$t('pageFirmware.modal.rebootFromBackup.title')" - @ok="$emit('ok')" - > - <p> - {{ $t('pageFirmware.modal.rebootFromBackup.message1', { backup }) }} - </p> - <p> - {{ $t('pageFirmware.modal.rebootFromBackup.message2', { current }) }} - </p> - <p class="font-weight-bold"> - {{ $t('pageFirmware.modal.rebootFromBackup.message3', { backup }) }} - </p> - </b-modal> -</template> - -<script> -export default { - props: { - current: { - type: String, - required: true, - }, - backup: { - type: String, - required: true, - }, - }, -}; -</script> diff --git a/src/env/components/FirmwareSingleImage/FirmwareModalSwitchToRunning.vue b/src/views/Configuration/Firmware/FirmwareModalSwitchToRunning.vue index 56f505d0..dc4a4973 100644 --- a/src/env/components/FirmwareSingleImage/FirmwareModalSwitchToRunning.vue +++ b/src/views/Configuration/Firmware/FirmwareModalSwitchToRunning.vue @@ -1,17 +1,17 @@ <template> <b-modal id="modal-switch-to-running" - :ok-title="$t('pageFirmware.singleFileUpload.modal.switchImages')" + :ok-title="$t('pageFirmware.modal.switchImages')" :cancel-title="$t('global.action.cancel')" - :title="$t('pageFirmware.singleFileUpload.modal.switchRunningImage')" + :title="$t('pageFirmware.modal.switchRunningImage')" @ok="$emit('ok')" > <p> - {{ $t('pageFirmware.singleFileUpload.modal.switchRunningImageInfo') }} + {{ $t('pageFirmware.modal.switchRunningImageInfo') }} </p> <p class="m-0"> {{ - $t('pageFirmware.singleFileUpload.modal.switchRunningImageInfo2', { + $t('pageFirmware.modal.switchRunningImageInfo2', { backup, }) }} 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 @@ +<template> + <b-modal + id="modal-update-firmware" + :title="$t('pageFirmware.sectionTitleUpdateFirmware')" + :ok-title="$t('pageFirmware.form.updateFirmware.startUpdate')" + :cancel-title="$t('global.action.cancel')" + @ok="$emit('ok')" + > + <template v-if="isSingleFileUploadEnabled"> + <p> + {{ $t('pageFirmware.modal.updateFirmwareInfo') }} + </p> + <p> + {{ + $t('pageFirmware.modal.updateFirmwareInfo2', { + running: runningBmcVersion, + }) + }} + </p> + <p class="m-0"> + {{ $t('pageFirmware.modal.updateFirmwareInfo3') }} + </p> + </template> + <template v-else> + {{ $t('pageFirmware.modal.updateFirmwareInfoDefault') }} + </template> + </b-modal> +</template> + +<script> +export default { + computed: { + runningBmc() { + return this.$store.getters['firmware/activeBmcFirmware']; + }, + runningBmcVersion() { + return this.runningBmc?.version || '--'; + }, + isSingleFileUploadEnabled() { + return this.$store.getters['firmware/isSingleFileUploadEnabled']; + }, + }, +}; +</script> 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 @@ -<template> - <b-modal - id="modal-upload" - ok-variant="danger" - :title="$t('pageFirmware.modal.uploadAndRebootBmcOrHost.title')" - :ok-title="$t('pageFirmware.modal.uploadAndRebootBmcOrHost.primaryAction')" - :cancel-title="$t('global.action.cancel')" - @ok="$emit('ok')" - > - <p> - {{ $t('pageFirmware.modal.uploadAndRebootBmcOrHost.message1') }} - </p> - <p> - {{ $t('pageFirmware.modal.uploadAndRebootBmcOrHost.message2') }} - </p> - <p class="font-weight-bold"> - {{ $t('pageFirmware.modal.uploadAndRebootBmcOrHost.message3') }} - </p> - </b-modal> -</template> 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, |