blob: d4aef193ebd51d4338de62945d0f92aa32e60610 [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"
SurenNeware978807d2020-09-03 18:35:21 +0530109 :disabled="isPageDisabled"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700110 :state="getValidationState($v.file)"
SurenNeware978807d2020-09-03 18:35:21 +0530111 aria-describedby="image-file-help-block"
112 @input="onFileUpload($event)"
113 >
114 <template #invalid>
115 <b-form-invalid-feedback role="alert">
116 <template>
117 {{ $t('global.form.required') }}
118 </template>
119 </b-form-invalid-feedback>
120 </template>
121 </form-file>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700122 </b-form-group>
123 </template>
124
125 <!-- TFTP Server Upload -->
126 <template v-else>
127 <b-form-group
SurenNeware64c20a52020-10-07 20:30:34 +0530128 :label="$t('pageFirmware.form.tftpServerAddress')"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700129 label-for="tftp-ip"
130 >
SurenNeware64c20a52020-10-07 20:30:34 +0530131 <b-form-text id="server-address-help-block">
132 {{ $t('pageFirmware.form.tftpServerAddressHelper') }}
133 </b-form-text>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700134 <b-form-input
135 id="tftp-id"
136 v-model="tftpIpAddress"
137 type="text"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700138 :state="getValidationState($v.tftpIpAddress)"
139 :disabled="isPageDisabled"
SurenNeware64c20a52020-10-07 20:30:34 +0530140 aria-describedby="server-address-help-block"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700141 @input="$v.tftpIpAddress.$touch()"
142 />
143 <b-form-invalid-feedback role="alert">
144 {{ $t('global.form.fieldRequired') }}
145 </b-form-invalid-feedback>
146 </b-form-group>
147 <b-form-group
148 :label="$t('pageFirmware.form.imageFileName')"
149 label-for="tftp-file-name"
150 >
151 <b-form-input
152 id="tftp-file-name"
153 v-model="tftpFileName"
154 type="text"
155 :state="getValidationState($v.tftpFileName)"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700156 @input="$v.tftpFileName.$touch()"
157 />
158 <b-form-invalid-feedback role="alert">
159 {{ $t('global.form.fieldRequired') }}
160 </b-form-invalid-feedback>
161 </b-form-group>
162 </template>
163
164 <!-- Info alert -->
165 <alert variant="info" class="mt-4 mb-5">
166 <p class="font-weight-bold mb-1">
167 {{ $t('pageFirmware.alert.updateProcess') }}
168 </p>
169 <p>{{ $t('pageFirmware.alert.updateProcessInfo') }}</p>
170 </alert>
Derick Montaguead48a0c2020-10-30 08:48:09 -0500171
172 <b-btn type="submit" variant="primary">
173 {{ $t('pageFirmware.form.uploadAndRebootBmcOrHost') }}
174 </b-btn>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700175 </b-form>
176 </page-section>
177 </b-col>
178 </b-row>
179
180 <!-- Modals -->
181 <modal-upload @ok="uploadFirmware" />
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700182 <modal-reboot-backup-bmc
183 :current="bmcFirmwareCurrentVersion || '--'"
184 :backup="bmcFirmwareBackupVersion || '--'"
185 @ok="switchBmcFirmware"
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700186 />
187 </b-container>
188</template>
189
190<script>
191import { requiredIf } from 'vuelidate/lib/validators';
192import { mapGetters } from 'vuex';
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700193import IconSwitch from '@carbon/icons-vue/es/arrows--horizontal/20';
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700194
195import PageSection from '@/components/Global/PageSection';
196import PageTitle from '@/components/Global/PageTitle';
197import Alert from '@/components/Global/Alert';
198import ModalUpload from './FirmwareModalUpload';
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700199import ModalRebootBackupBmc from './FirmwareModalRebootBackupBmc';
SurenNeware978807d2020-09-03 18:35:21 +0530200import FormFile from '@/components/Global/FormFile';
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700201
202import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js';
SurenNewareba91c492020-10-27 14:18:54 +0530203import LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin';
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700204import BVToastMixin from '@/components/Mixins/BVToastMixin';
205
206export default {
207 name: 'Firmware',
208 components: {
209 Alert,
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700210 IconSwitch,
211 ModalRebootBackupBmc,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700212 ModalUpload,
213 PageSection,
Derick Montague602e98a2020-10-21 16:20:00 -0500214 PageTitle,
SurenNeware978807d2020-09-03 18:35:21 +0530215 FormFile,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700216 },
217 mixins: [BVToastMixin, LoadingBarMixin, VuelidateMixin],
Derick Montague602e98a2020-10-21 16:20:00 -0500218 beforeRouteLeave(to, from, next) {
219 this.hideLoader();
220 this.clearRebootTimeout();
221 next();
222 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700223 data() {
224 return {
225 isWorkstationSelected: true,
226 file: null,
227 tftpIpAddress: null,
228 tftpFileName: null,
Derick Montague602e98a2020-10-21 16:20:00 -0500229 timeoutId: null,
SurenNeware978807d2020-09-03 18:35:21 +0530230 isPageDisabled: null,
SurenNewareba91c492020-10-27 14:18:54 +0530231 loading: loading,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700232 };
233 },
234 computed: {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700235 ...mapGetters('firmware', [
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700236 'bmcFirmwareCurrentVersion',
237 'bmcFirmwareCurrentState',
238 'bmcFirmwareBackupVersion',
239 'bmcFirmwareBackupState',
240 'hostFirmwareCurrentVersion',
241 'hostFirmwareCurrentState',
242 'hostFirmwareBackupVersion',
Derick Montague602e98a2020-10-21 16:20:00 -0500243 'hostFirmwareBackupState',
244 ]),
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700245 },
246 watch: {
Derick Montague602e98a2020-10-21 16:20:00 -0500247 isWorkstationSelected: function () {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700248 this.$v.$reset();
249 this.file = null;
250 this.tftpIpAddress = null;
251 this.tftpFileName = null;
Derick Montague602e98a2020-10-21 16:20:00 -0500252 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700253 },
254 created() {
255 this.startLoader();
256 this.$store.dispatch('firmware/getUpdateServiceApplyTime');
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700257 this.$store
258 .dispatch('firmware/getFirmwareInformation')
259 .finally(() => this.endLoader());
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700260 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700261 validations() {
262 return {
263 file: {
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 tftpIpAddress: {
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 }),
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700272 },
273 tftpFileName: {
Derick Montague602e98a2020-10-21 16:20:00 -0500274 required: requiredIf(function () {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700275 return !this.isWorkstationSelected;
Derick Montague602e98a2020-10-21 16:20:00 -0500276 }),
277 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700278 };
279 },
280 methods: {
SurenNeware978807d2020-09-03 18:35:21 +0530281 onFileUpload(file) {
282 this.file = file;
283 this.$v.file.$touch();
284 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700285 uploadFirmware() {
286 const startTime = this.$options.filters.formatTime(new Date());
287 this.setRebootTimeout(360000); //6 minute timeout
288 this.infoToast(
289 this.$t('pageFirmware.toast.infoUploadStartTimeMessage', { startTime }),
290 this.$t('pageFirmware.toast.infoUploadStartTimeTitle')
291 );
292 if (this.isWorkstationSelected) {
293 this.dispatchWorkstationUpload();
294 } else {
295 this.dispatchTftpUpload();
296 }
297 },
298 dispatchWorkstationUpload() {
299 this.$store
300 .dispatch('firmware/uploadFirmware', this.file)
Derick Montague602e98a2020-10-21 16:20:00 -0500301 .then((success) =>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700302 this.infoToast(
303 success,
304 this.$t('pageFirmware.toast.successUploadTitle')
305 )
306 )
307 .catch(({ message }) => {
308 this.errorToast(message);
309 this.clearRebootTimeout();
310 });
311 },
312 dispatchTftpUpload() {
313 const data = {
314 address: this.tftpIpAddress,
Derick Montague602e98a2020-10-21 16:20:00 -0500315 filename: this.tftpFileName,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700316 };
317 this.$store
318 .dispatch('firmware/uploadFirmwareTFTP', data)
Derick Montague602e98a2020-10-21 16:20:00 -0500319 .then((success) =>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700320 this.infoToast(
321 success,
322 this.$t('pageFirmware.toast.successUploadTitle')
323 )
324 )
325 .catch(({ message }) => {
326 this.errorToast(message);
327 this.clearRebootTimeout();
328 });
329 },
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700330 switchBmcFirmware() {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700331 this.setRebootTimeout();
332 this.$store
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700333 .dispatch('firmware/switchBmcFirmware')
Derick Montague602e98a2020-10-21 16:20:00 -0500334 .then((success) =>
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700335 this.infoToast(success, this.$t('global.status.success'))
336 )
337 .catch(({ message }) => {
338 this.errorToast(message);
339 this.clearRebootTimeout();
340 });
341 },
342 setRebootTimeout(timeoutMs = 60000) {
343 // Set a timeout to disable page interactions while
344 // an upload or BMC reboot is in progress
345 this.startLoader();
346 this.timeoutId = setTimeout(() => {
347 this.endLoader();
348 this.infoToast(
349 this.$t('pageFirmware.toast.infoRefreshApplicationMessage'),
350 this.$t('pageFirmware.toast.infoRefreshApplicationTitle')
351 );
352 }, timeoutMs);
353 },
354 clearRebootTimeout() {
355 if (this.timeoutId) {
356 clearTimeout(this.timeoutId);
357 this.endLoader();
358 }
359 },
360 onSubmitUpload() {
361 this.$v.$touch();
362 if (this.$v.$invalid) return;
363 this.$bvModal.show('modal-upload');
Derick Montague602e98a2020-10-21 16:20:00 -0500364 },
365 },
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700366};
367</script>
368
369<style lang="scss" scoped>
370.update-code {
371 border-left: none;
372 @include media-breakpoint-up(xl) {
373 border-left: 1px solid gray('300');
374 }
375}
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700376.card-footer {
Dixsie Wolmers30f11f82020-11-10 16:07:56 -0600377 height: 40px;
Yoshie Muranaka98bb24e2020-10-06 10:00:19 -0700378}
379.card-body {
380 padding: 0.75rem 1.25rem;
381}
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700382</style>