summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/store/modules/Operations/FirmwareStore.js31
-rw-r--r--src/views/Operations/Firmware/FirmwareFormUpdate.vue4
2 files changed, 33 insertions, 2 deletions
diff --git a/src/store/modules/Operations/FirmwareStore.js b/src/store/modules/Operations/FirmwareStore.js
index ca3ed523..6c216da8 100644
--- a/src/store/modules/Operations/FirmwareStore.js
+++ b/src/store/modules/Operations/FirmwareStore.js
@@ -9,6 +9,7 @@ const FirmwareStore = {
bmcActiveFirmwareId: null,
hostActiveFirmwareId: null,
applyTime: null,
+ multipartHttpPushUri: null,
httpPushUri: null,
},
getters: {
@@ -41,6 +42,8 @@ const FirmwareStore = {
setHostFirmware: (state, firmware) => (state.hostFirmware = firmware),
setApplyTime: (state, applyTime) => (state.applyTime = applyTime),
setHttpPushUri: (state, httpPushUri) => (state.httpPushUri = httpPushUri),
+ setMultipartHttpPushUri: (state, multipartHttpPushUri) =>
+ (state.multipartHttpPushUri = multipartHttpPushUri),
},
actions: {
async getFirmwareInformation({ dispatch }) {
@@ -110,10 +113,21 @@ const FirmwareStore = {
commit('setApplyTime', applyTime);
const httpPushUri = data.HttpPushUri;
commit('setHttpPushUri', httpPushUri);
+ const multipartHttpPushUri = data.MultipartHttpPushUri;
+ commit('setMultipartHttpPushUri', multipartHttpPushUri);
})
.catch((error) => console.log(error));
},
- async uploadFirmware({ state }, image) {
+ async uploadFirmware({ state, dispatch }, params) {
+ if (state.multipartHttpPushUri != null) {
+ return dispatch('uploadFirmwareMultipartHttpPush', params);
+ } else if (state.httpPushUri != null) {
+ return dispatch('uploadFirmwareHttpPush', params);
+ } else {
+ console.log('Do not support firmware push update');
+ }
+ },
+ async uploadFirmwareHttpPush({ state }, { image }) {
return await api
.post(state.httpPushUri, image, {
headers: { 'Content-Type': 'application/octet-stream' },
@@ -123,6 +137,21 @@ const FirmwareStore = {
throw new Error(i18n.t('pageFirmware.toast.errorUpdateFirmware'));
});
},
+ async uploadFirmwareMultipartHttpPush({ state }, { image, targets }) {
+ const formData = new FormData();
+ formData.append('UpdateFile', image);
+ let params = {};
+ if (targets != null && targets.length > 0) params.Targets = targets;
+ formData.append('UpdateParameters', JSON.stringify(params));
+ return await api
+ .post(state.multipartHttpPushUri, formData, {
+ headers: { 'Content-Type': 'multipart/form-data' },
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageFirmware.toast.errorUpdateFirmware'));
+ });
+ },
async switchBmcFirmwareAndReboot({ getters }) {
const backupLocation = getters.backupBmcFirmware.location;
const data = {
diff --git a/src/views/Operations/Firmware/FirmwareFormUpdate.vue b/src/views/Operations/Firmware/FirmwareFormUpdate.vue
index 4c302df6..28d1104d 100644
--- a/src/views/Operations/Firmware/FirmwareFormUpdate.vue
+++ b/src/views/Operations/Firmware/FirmwareFormUpdate.vue
@@ -100,7 +100,9 @@ export default {
},
dispatchWorkstationUpload(timerId) {
this.$store
- .dispatch('firmware/uploadFirmware', this.file)
+ .dispatch('firmware/uploadFirmware', {
+ image: this.file,
+ })
.catch(({ message }) => {
this.endLoader();
this.errorToast(message);