blob: 5001702ad0f17198ff5edce7277185fe6d530677 [file] [log] [blame]
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -07001<template>
2 <b-container fluid="xl">
3 <page-title :description="$t('pageFirmware.pageDescription')" />
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -07004 <b-row class="mb-4">
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -07005 <b-col md="10" lg="12" xl="8" class="pr-xl-4">
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -07006 <!-- Firmware on BMC -->
7 <page-section :section-title="$t('pageFirmware.firmwareOnBmc')">
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -07008 <b-card-group deck>
9 <!-- Current FW -->
10 <b-card header-bg-variant="success">
Derick Montague602e98a2020-10-21 16:20:00 -050011 <template #header>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070012 <dl class="mb-0">
13 <dt>{{ $t('pageFirmware.current') }}</dt>
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -070014 <dd class="mb-0">{{ bmcFirmwareCurrentVersion }}</dd>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070015 </dl>
16 </template>
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -070017 <dl class="my-0">
18 <dt>{{ $t('pageFirmware.state') }}:</dt>
19 <dd>{{ bmcFirmwareCurrentState }}</dd>
20 </dl>
Derick Montague602e98a2020-10-21 16:20:00 -050021 <template #footer></template>
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -070022 </b-card>
23
24 <!-- Backup FW -->
25 <b-card footer-class="p-0">
Derick Montague602e98a2020-10-21 16:20:00 -050026 <template #header>
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -070027 <dl class="mb-0">
28 <dt>{{ $t('pageFirmware.backup') }}</dt>
29 <dd class="mb-0">{{ bmcFirmwareBackupVersion }}</dd>
30 </dl>
31 </template>
32 <dl class="my-0">
33 <dt>{{ $t('pageFirmware.state') }}:</dt>
34 <dd>{{ bmcFirmwareBackupState }}</dd>
35 </dl>
Derick Montague602e98a2020-10-21 16:20:00 -050036 <template #footer>
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -070037 <b-btn
38 v-b-modal.modal-reboot-backup-bmc
39 :disabled="!bmcFirmwareBackupVersion"
40 variant="link"
41 size="sm"
42 >
43 <icon-switch class="d-none d-sm-inline-block" />
44 {{ $t('pageFirmware.makeCurrentVersion') }}</b-btn
45 >
46 </template>
47 </b-card>
48 </b-card-group>
49 </page-section>
50
51 <!-- Firmware on Host -->
52 <page-section :section-title="$t('pageFirmware.firmwareOnHost')">
53 <b-card-group deck>
54 <!-- Current FW -->
55 <b-card header-bg-variant="success">
Derick Montague602e98a2020-10-21 16:20:00 -050056 <template #header>
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -070057 <dl class="mb-0">
58 <dt>{{ $t('pageFirmware.current') }}</dt>
59 <dd class="mb-0">{{ hostFirmwareCurrentVersion }}</dd>
60 </dl>
61 </template>
62 <!-- State -->
63 <dl class="my-0">
64 <dt>{{ $t('pageFirmware.state') }}:</dt>
65 <dd>{{ hostFirmwareCurrentState }}</dd>
66 </dl>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070067 </b-card>
68
69 <!-- Backup FW -->
70 <b-card>
Derick Montague602e98a2020-10-21 16:20:00 -050071 <template #header>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070072 <dl class="mb-0">
73 <dt>{{ $t('pageFirmware.backup') }}</dt>
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -070074 <dd class="mb-0">{{ hostFirmwareBackupVersion }}</dd>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070075 </dl>
76 </template>
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -070077 <!-- State -->
78 <dl class="my-0">
79 <dt>{{ $t('pageFirmware.state') }}:</dt>
80 <dd>{{ hostFirmwareBackupState }}</dd>
81 </dl>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070082 </b-card>
83 </b-card-group>
84 </page-section>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070085 </b-col>
86
87 <!-- Update code -->
88 <b-col sm="8" xl="4" class="update-code pl-xl-4">
89 <page-section :section-title="$t('pageFirmware.updateCode')">
90 <b-form @submit.prevent="onSubmitUpload">
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -070091 <b-form-group :label="$t('pageFirmware.form.uploadLocation')">
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070092 <b-form-radio v-model="isWorkstationSelected" :value="true">
93 {{ $t('pageFirmware.form.workstation') }}
94 </b-form-radio>
95 <b-form-radio v-model="isWorkstationSelected" :value="false">
96 {{ $t('pageFirmware.form.tftpServer') }}
97 </b-form-radio>
98 </b-form-group>
99
100 <!-- Workstation Upload -->
101 <template v-if="isWorkstationSelected">
SurenNeware978807d2020-09-03 18:35:21 +0530102 <b-form-group :label="$t('pageFirmware.form.imageFile')">
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700103 <b-form-text id="image-file-help-block">
104 {{ $t('pageFirmware.form.onlyTarFilesAccepted') }}
105 </b-form-text>
SurenNeware978807d2020-09-03 18:35:21 +0530106 <form-file
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700107 id="image-file"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700108 accept=".tar"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700109 :state="getValidationState($v.file)"
SurenNeware978807d2020-09-03 18:35:21 +0530110 aria-describedby="image-file-help-block"
111 @input="onFileUpload($event)"
112 >
113 <template #invalid>
114 <b-form-invalid-feedback role="alert">
Yoshie Muranaka00f5b792020-12-07 07:28:50 -0800115 {{ $t('global.form.required') }}
SurenNeware978807d2020-09-03 18:35:21 +0530116 </b-form-invalid-feedback>
117 </template>
118 </form-file>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700119 </b-form-group>
120 </template>
121
122 <!-- TFTP Server Upload -->
123 <template v-else>
124 <b-form-group
SurenNeware64c20a52020-10-07 20:30:34 +0530125 :label="$t('pageFirmware.form.tftpServerAddress')"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700126 label-for="tftp-ip"
127 >
SurenNeware64c20a52020-10-07 20:30:34 +0530128 <b-form-text id="server-address-help-block">
129 {{ $t('pageFirmware.form.tftpServerAddressHelper') }}
130 </b-form-text>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700131 <b-form-input
132 id="tftp-id"
133 v-model="tftpIpAddress"
134 type="text"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700135 :state="getValidationState($v.tftpIpAddress)"
SurenNeware64c20a52020-10-07 20:30:34 +0530136 aria-describedby="server-address-help-block"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700137 @input="$v.tftpIpAddress.$touch()"
138 />
139 <b-form-invalid-feedback role="alert">
140 {{ $t('global.form.fieldRequired') }}
141 </b-form-invalid-feedback>
142 </b-form-group>
143 <b-form-group
144 :label="$t('pageFirmware.form.imageFileName')"
145 label-for="tftp-file-name"
146 >
147 <b-form-input
148 id="tftp-file-name"
149 v-model="tftpFileName"
150 type="text"
151 :state="getValidationState($v.tftpFileName)"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700152 @input="$v.tftpFileName.$touch()"
153 />
154 <b-form-invalid-feedback role="alert">
155 {{ $t('global.form.fieldRequired') }}
156 </b-form-invalid-feedback>
157 </b-form-group>
158 </template>
159
160 <!-- Info alert -->
161 <alert variant="info" class="mt-4 mb-5">
162 <p class="font-weight-bold mb-1">
163 {{ $t('pageFirmware.alert.updateProcess') }}
164 </p>
165 <p>{{ $t('pageFirmware.alert.updateProcessInfo') }}</p>
166 </alert>
Derick Montaguead48a0c2020-10-30 08:48:09 -0500167
168 <b-btn type="submit" variant="primary">
169 {{ $t('pageFirmware.form.uploadAndRebootBmcOrHost') }}
170 </b-btn>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700171 </b-form>
172 </page-section>
173 </b-col>
174 </b-row>
175
176 <!-- Modals -->
177 <modal-upload @ok="uploadFirmware" />
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700178 <modal-reboot-backup-bmc
179 :current="bmcFirmwareCurrentVersion || '--'"
180 :backup="bmcFirmwareBackupVersion || '--'"
181 @ok="switchBmcFirmware"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700182 />
183 </b-container>
184</template>
185
186<script>
187import { requiredIf } from 'vuelidate/lib/validators';
188import { mapGetters } from 'vuex';
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700189import IconSwitch from '@carbon/icons-vue/es/arrows--horizontal/20';
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700190
191import PageSection from '@/components/Global/PageSection';
192import PageTitle from '@/components/Global/PageTitle';
193import Alert from '@/components/Global/Alert';
194import ModalUpload from './FirmwareModalUpload';
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700195import ModalRebootBackupBmc from './FirmwareModalRebootBackupBmc';
SurenNeware978807d2020-09-03 18:35:21 +0530196import FormFile from '@/components/Global/FormFile';
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700197
198import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js';
SurenNewareba91c492020-10-27 14:18:54 +0530199import LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin';
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700200import BVToastMixin from '@/components/Mixins/BVToastMixin';
201
202export default {
203 name: 'Firmware',
204 components: {
205 Alert,
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700206 IconSwitch,
207 ModalRebootBackupBmc,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700208 ModalUpload,
209 PageSection,
Derick Montague602e98a2020-10-21 16:20:00 -0500210 PageTitle,
SurenNeware978807d2020-09-03 18:35:21 +0530211 FormFile,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700212 },
213 mixins: [BVToastMixin, LoadingBarMixin, VuelidateMixin],
Derick Montague602e98a2020-10-21 16:20:00 -0500214 beforeRouteLeave(to, from, next) {
215 this.hideLoader();
216 this.clearRebootTimeout();
217 next();
218 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700219 data() {
220 return {
221 isWorkstationSelected: true,
222 file: null,
223 tftpIpAddress: null,
224 tftpFileName: null,
Derick Montague602e98a2020-10-21 16:20:00 -0500225 timeoutId: null,
SurenNewareba91c492020-10-27 14:18:54 +0530226 loading: loading,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700227 };
228 },
229 computed: {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700230 ...mapGetters('firmware', [
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700231 'bmcFirmwareCurrentVersion',
232 'bmcFirmwareCurrentState',
233 'bmcFirmwareBackupVersion',
234 'bmcFirmwareBackupState',
235 'hostFirmwareCurrentVersion',
236 'hostFirmwareCurrentState',
237 'hostFirmwareBackupVersion',
Derick Montague602e98a2020-10-21 16:20:00 -0500238 'hostFirmwareBackupState',
239 ]),
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700240 },
241 watch: {
Derick Montague602e98a2020-10-21 16:20:00 -0500242 isWorkstationSelected: function () {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700243 this.$v.$reset();
244 this.file = null;
245 this.tftpIpAddress = null;
246 this.tftpFileName = null;
Derick Montague602e98a2020-10-21 16:20:00 -0500247 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700248 },
249 created() {
250 this.startLoader();
251 this.$store.dispatch('firmware/getUpdateServiceApplyTime');
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700252 this.$store
253 .dispatch('firmware/getFirmwareInformation')
254 .finally(() => this.endLoader());
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700255 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700256 validations() {
257 return {
258 file: {
Derick Montague602e98a2020-10-21 16:20:00 -0500259 required: requiredIf(function () {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700260 return this.isWorkstationSelected;
Derick Montague602e98a2020-10-21 16:20:00 -0500261 }),
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700262 },
263 tftpIpAddress: {
Derick Montague602e98a2020-10-21 16:20:00 -0500264 required: requiredIf(function () {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700265 return !this.isWorkstationSelected;
Derick Montague602e98a2020-10-21 16:20:00 -0500266 }),
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700267 },
268 tftpFileName: {
Derick Montague602e98a2020-10-21 16:20:00 -0500269 required: requiredIf(function () {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700270 return !this.isWorkstationSelected;
Derick Montague602e98a2020-10-21 16:20:00 -0500271 }),
272 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700273 };
274 },
275 methods: {
SurenNeware978807d2020-09-03 18:35:21 +0530276 onFileUpload(file) {
277 this.file = file;
278 this.$v.file.$touch();
279 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700280 uploadFirmware() {
281 const startTime = this.$options.filters.formatTime(new Date());
282 this.setRebootTimeout(360000); //6 minute timeout
283 this.infoToast(
284 this.$t('pageFirmware.toast.infoUploadStartTimeMessage', { startTime }),
Yoshie Muranakaf92e2962021-02-09 12:41:53 -0800285 { title: this.$t('pageFirmware.toast.infoUploadStartTimeTitle') }
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700286 );
287 if (this.isWorkstationSelected) {
288 this.dispatchWorkstationUpload();
289 } else {
290 this.dispatchTftpUpload();
291 }
292 },
293 dispatchWorkstationUpload() {
294 this.$store
295 .dispatch('firmware/uploadFirmware', this.file)
Derick Montague602e98a2020-10-21 16:20:00 -0500296 .then((success) =>
Yoshie Muranakaf92e2962021-02-09 12:41:53 -0800297 this.infoToast(success, {
298 title: this.$t('pageFirmware.toast.successUploadTitle'),
299 })
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700300 )
301 .catch(({ message }) => {
302 this.errorToast(message);
303 this.clearRebootTimeout();
304 });
305 },
306 dispatchTftpUpload() {
307 const data = {
308 address: this.tftpIpAddress,
Derick Montague602e98a2020-10-21 16:20:00 -0500309 filename: this.tftpFileName,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700310 };
311 this.$store
312 .dispatch('firmware/uploadFirmwareTFTP', data)
Derick Montague602e98a2020-10-21 16:20:00 -0500313 .then((success) =>
Yoshie Muranakaf92e2962021-02-09 12:41:53 -0800314 this.infoToast(success, {
315 title: this.$t('pageFirmware.toast.successUploadTitle'),
316 })
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700317 )
318 .catch(({ message }) => {
319 this.errorToast(message);
320 this.clearRebootTimeout();
321 });
322 },
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700323 switchBmcFirmware() {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700324 this.setRebootTimeout();
325 this.$store
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700326 .dispatch('firmware/switchBmcFirmware')
Derick Montague602e98a2020-10-21 16:20:00 -0500327 .then((success) =>
Yoshie Muranakaf92e2962021-02-09 12:41:53 -0800328 this.infoToast(success, { title: this.$t('global.status.success') })
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700329 )
330 .catch(({ message }) => {
331 this.errorToast(message);
332 this.clearRebootTimeout();
333 });
334 },
335 setRebootTimeout(timeoutMs = 60000) {
336 // Set a timeout to disable page interactions while
337 // an upload or BMC reboot is in progress
338 this.startLoader();
339 this.timeoutId = setTimeout(() => {
340 this.endLoader();
341 this.infoToast(
342 this.$t('pageFirmware.toast.infoRefreshApplicationMessage'),
Yoshie Muranakaf92e2962021-02-09 12:41:53 -0800343 {
344 title: this.$t('pageFirmware.toast.infoRefreshApplicationTitle'),
345 refreshAction: true,
346 }
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700347 );
348 }, timeoutMs);
349 },
350 clearRebootTimeout() {
351 if (this.timeoutId) {
352 clearTimeout(this.timeoutId);
353 this.endLoader();
354 }
355 },
356 onSubmitUpload() {
357 this.$v.$touch();
358 if (this.$v.$invalid) return;
359 this.$bvModal.show('modal-upload');
Derick Montague602e98a2020-10-21 16:20:00 -0500360 },
361 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700362};
363</script>
364
365<style lang="scss" scoped>
366.update-code {
367 border-left: none;
368 @include media-breakpoint-up(xl) {
369 border-left: 1px solid gray('300');
370 }
371}
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700372.card-footer {
Dixsie Wolmers30f11f82020-11-10 16:07:56 -0600373 height: 40px;
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700374}
375.card-body {
376 padding: 0.75rem 1.25rem;
377}
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700378</style>