Skip to content

Commit

Permalink
Merge branch '1110' of github.com:ibm-openbmc/webui-vue into 1110
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwari-nishant committed Aug 19, 2024
2 parents 70880e3 + 65bd39b commit b1598ce
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 135 deletions.
1 change: 0 additions & 1 deletion .env.ibm
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ CUSTOM_APP_NAV=true
CUSTOM_ROUTER=true
CUSTOM_STORE=true
VUE_APP_SERVER_OFF_REQUIRED=true
VUE_APP_TFTP_SERVER=false
VUE_APP_ACF_UPLOAD_REQUIRED=true
2 changes: 0 additions & 2 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,6 @@
"imageFile": "Image file",
"manageAccessKeys": "Manage access keys",
"startUpdate": "Start update",
"tftpServer": "TFTP server",
"tftpServerInfo": "<server_ip>/<file_name>.tar",
"workstation": "Workstation"
}
},
Expand Down
63 changes: 31 additions & 32 deletions src/store/modules/Operations/FirmwareStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const FirmwareStore = {
bmcActiveFirmwareId: null,
hostActiveFirmwareId: null,
applyTime: null,
tftpAvailable: false,
firmwareBootSide: null,
lowestSupportedFirmwareVersion: '',
showAlert: false,
},
getters: {
isTftpUploadAvailable: (state) => state.tftpAvailable,
isSingleFileUploadEnabled: (state) => state.hostFirmware.length === 0,
activeBmcFirmware: (state) => {
return state.bmcFirmware.find(
Expand All @@ -36,6 +36,9 @@ const FirmwareStore = {
);
},
firmwareBootSide: (state) => state.firmwareBootSide,
lowestSupportedFirmwareVersion: (state) =>
state.lowestSupportedFirmwareVersion,
showAlert: (state) => state.showAlert,
},
mutations: {
setActiveBmcFirmwareId: (state, id) => (state.bmcActiveFirmwareId = id),
Expand All @@ -45,12 +48,36 @@ const FirmwareStore = {
setBmcFirmware: (state, firmware) => (state.bmcFirmware = firmware),
setHostFirmware: (state, firmware) => (state.hostFirmware = firmware),
setApplyTime: (state, applyTime) => (state.applyTime = applyTime),
setTftpUploadAvailable: (state, tftpAvailable) =>
(state.tftpAvailable = tftpAvailable),
setFirmwareBootSide: (state, firmwareBootSide) =>
(state.firmwareBootSide = firmwareBootSide),
setLowestSupportedFirmwareVersion: (
state,
lowestSupportedFirmwareVersion
) =>
(state.lowestSupportedFirmwareVersion = lowestSupportedFirmwareVersion),
setShowAlert: (state, showAlert) => (state.showAlert = showAlert),
},
actions: {
async getLowestSupportedFirmwareVersion({ commit, state }) {
await api.get('/redfish/v1/Managers/bmc').then((response) =>
api
.get(response.data.Links.ActiveSoftwareImage['@odata.id'])
.then((response) => {
let lowestSupportedFirmware;
if (Object.keys(response.data).includes('LowestSupportedVersion')) {
state.showAlert = true;
lowestSupportedFirmware = response.data.LowestSupportedVersion;
} else {
state.showAlert = false;
}
commit(
'setLowestSupportedFirmwareVersion',
lowestSupportedFirmware
);
})
);
return this.lowestSupportedFirmwareVersion;
},
async getFirmwareInformation({ dispatch }) {
dispatch('getActiveHostFirmware');
dispatch('getActiveBmcFirmware');
Expand Down Expand Up @@ -124,15 +151,7 @@ const FirmwareStore = {
.then(({ data }) => {
const applyTime =
data.HttpPushUriOptions.HttpPushUriApplyTime.ApplyTime;
const allowableActions =
data?.Actions?.['#UpdateService.SimpleUpdate']?.[
'[email protected]'
];

commit('setApplyTime', applyTime);
if (allowableActions?.includes('TFTP')) {
commit('setTftpUploadAvailable', true);
}
})
.catch((error) => console.log(error));
},
Expand Down Expand Up @@ -164,26 +183,6 @@ const FirmwareStore = {
throw new Error(i18n.t('pageFirmware.toast.errorUploadFirmware'));
});
},
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.errorUpdateFirmware'));
});
},
async switchBmcFirmwareAndReboot({ getters }) {
const backupLocation = getters.backupBmcFirmware.location;
const data = {
Expand Down
39 changes: 36 additions & 3 deletions src/views/Operations/Firmware/Firmware.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@
</b-row>

<!-- Update firmware-->
<page-section
:section-title="$t('pageFirmware.sectionTitleUpdateFirmware')"
>
<page-section :section-title="$t('pageFirmware.sectionTitleUpdateFirmware')"
><b-row>
<b-col sm="14" md="10" xl="6">
<alert :show="showAlert" variant="info" class="mb-5">
<p class="mb-0 p1">{{ $t('global.toast.minMifMessage') }}:</p>
<p class="font-weight-bold p2">
{{ lowestSupportedFirmwareVersion }}
</p>
</alert>
</b-col>
</b-row>
<b-row>
<b-col class="mb-4" sm="8" md="6" xl="4">
<!-- Update form -->
Expand All @@ -50,6 +58,7 @@ 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 LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin';
Expand All @@ -63,6 +72,7 @@ export default {
HostCards,
PageSection,
PageTitle,
Alert,
},
mixins: [LoadingBarMixin],
beforeRouteLeave(to, from, next) {
Expand All @@ -74,6 +84,8 @@ export default {
loading,
isServerPowerOffRequired:
process.env.VUE_APP_SERVER_OFF_REQUIRED === 'true',
lowestSupportedFirmwareVersion: '',
showAlert: false,
};
},
computed: {
Expand All @@ -99,6 +111,18 @@ export default {
this.$store.dispatch('licenses/getLicenses'),
this.$store.dispatch('firmware/getFirmwareInformation'),
this.$store.dispatch('firmware/getFirmwareBootSide'),
this.$store
.dispatch('firmware/getLowestSupportedFirmwareVersion')
.then(() => {
this.lowestSupportedFirmwareVersion = this.$store.getters[
'firmware/lowestSupportedFirmwareVersion'
];
}),
this.$store
.dispatch('firmware/getLowestSupportedFirmwareVersion')
.then(() => {
this.showAlert = this.$store.getters['firmware/showAlert'];
}),
]).finally(() => this.endLoader());
},
methods: {
Expand All @@ -108,3 +132,12 @@ export default {
},
};
</script>
<style scoped>
.p1 {
display: inline-block;
}
.p2 {
margin-left: 5px;
display: inline-block;
}
</style>
117 changes: 20 additions & 97 deletions src/views/Operations/Firmware/FirmwareFormUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,26 @@
<div>
<div class="form-background p-3">
<b-form @submit.prevent="onSubmitUpload">
<!-- Workstation Upload -->
<b-form-group
v-if="isTftpUploadAvailable && tftpServer"
:label="$t('pageFirmware.form.updateFirmware.fileSource')"
:disabled="isPageDisabled"
:label="$t('pageFirmware.form.updateFirmware.imageFile')"
label-for="image-file"
>
<b-form-radio v-model="isWorkstationSelected" :value="true">
{{ $t('pageFirmware.form.updateFirmware.workstation') }}
</b-form-radio>
<b-form-radio v-model="isWorkstationSelected" :value="false">
{{ $t('pageFirmware.form.updateFirmware.tftpServer') }}
<span
><info-tooltip
class="info-icon"
:title="$t('pageFirmware.form.updateFirmware.tftpServerInfo')"
/></span>
</b-form-radio>
</b-form-group>

<!-- Workstation Upload -->
<template v-if="isWorkstationSelected">
<b-form-group
:label="$t('pageFirmware.form.updateFirmware.imageFile')"
label-for="image-file"
<form-file
id="image-file"
:disabled="isPageDisabled"
accept=".tar"
:state="getValidationState($v.file)"
aria-describedby="image-file-help-block"
@input="onFileUpload($event)"
>
<form-file
id="image-file"
:disabled="isPageDisabled"
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-if="tftpServer">
<b-form-group
:label="$t('pageFirmware.form.updateFirmware.fileAddress')"
label-for="tftp-address"
>
<b-form-input
id="tftp-address"
v-model="tftpFileAddress"
type="text"
:state="getValidationState($v.tftpFileAddress)"
:disabled="isPageDisabled"
@input="$v.tftpFileAddress.$touch()"
/>
<b-form-invalid-feedback role="alert">
<template v-if="!$v.tftpFileAddress.required">
{{ $t('global.form.fieldRequired') }}
</template>
</b-form-invalid-feedback>
</b-form-group>
</template>
<template #invalid>
<b-form-invalid-feedback role="alert">
{{ $t('global.form.required') }}
</b-form-invalid-feedback>
</template>
</form-file>
</b-form-group>
<b-btn
data-test-id="firmware-button-startUpdate"
type="submit"
Expand All @@ -81,18 +39,16 @@
</template>

<script>
import { requiredIf } from 'vuelidate/lib/validators';
import { required } from 'vuelidate/lib/validators';
import BVToastMixin from '@/components/Mixins/BVToastMixin';
import LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin';
import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js';
import InfoTooltip from '@/components/Global/InfoTooltip';
import FormFile from '@/components/Global/FormFile';
import ModalUpdateFirmware from './FirmwareModalUpdateFirmware';
export default {
name: 'FormUpdate',
components: {
InfoTooltip,
FormFile,
ModalUpdateFirmware,
},
Expand All @@ -107,12 +63,9 @@ export default {
data() {
return {
loading,
isWorkstationSelected: true,
file: null,
tftpFileAddress: null,
isServerPowerOffRequired:
process.env.VUE_APP_SERVER_OFF_REQUIRED === 'true',
tftpServer: process.env.VUE_APP_TFTP_SERVER === 'true',
};
},
computed: {
Expand All @@ -122,31 +75,16 @@ export default {
bootProgress() {
return this.$store.getters['global/bootProgress'];
},
isTftpUploadAvailable() {
return this.$store.getters['firmware/isTftpUploadAvailable'];
},
},
watch: {
isWorkstationSelected: function () {
this.$v.$reset();
this.file = null;
this.tftpFileAddress = null;
},
loading: function (value) {
this.$emit('loadingStatus', value);
},
},
validations() {
return {
file: {
required: requiredIf(function () {
return this.isWorkstationSelected;
}),
},
tftpFileAddress: {
required: requiredIf(function () {
return !this.isWorkstationSelected;
}),
required: required,
},
};
},
Expand All @@ -168,11 +106,7 @@ export default {
timestamp: true,
}
);
if (this.isWorkstationSelected) {
this.dispatchWorkstationUpload(activateFirmware);
} else {
this.dispatchTftpUpload(activateFirmware);
}
this.dispatchWorkstationUpload(activateFirmware);
};
// Step 2 - Activation
Expand Down Expand Up @@ -301,17 +235,6 @@ export default {
this.errorToast(message);
});
},
dispatchTftpUpload(activateFirmware) {
this.$store
.dispatch('firmware/uploadFirmwareTFTP', this.tftpFileAddress)
.then(({ data }) => {
activateFirmware(data);
})
.catch(({ message }) => {
this.endLoader();
this.errorToast(message);
});
},
onSubmitUpload() {
this.$v.$touch();
if (this.$v.$invalid) return;
Expand Down

0 comments on commit b1598ce

Please sign in to comment.