Add support for MultipartHttpPushUri in fw push
According to the Redfish Firmware Update Whitepaper [1]
due to the vendor-specific details of this operation,
HttpPushUri has been deprecated in favor of multipartHTTP push
updates.
Availability of update methods is determined from the UpdateService
response.
If MultipartHttpPushUri is found it will be preferred over HttpPushUri
Tested:
-Firmware update by performed via MultipartHttpPushUri
[1]: https://www.dmtf.org/sites/default/files/standards/documents/DSP2062_1.0.1.pdf
Change-Id: I184a889514d5f9f9598f35b2281404335bc0bc82
Signed-off-by: Leo Xu <yongquanx@nvidia.com>
diff --git a/src/store/modules/Operations/FirmwareStore.js b/src/store/modules/Operations/FirmwareStore.js
index ca3ed52..6c216da 100644
--- a/src/store/modules/Operations/FirmwareStore.js
+++ b/src/store/modules/Operations/FirmwareStore.js
@@ -9,6 +9,7 @@
bmcActiveFirmwareId: null,
hostActiveFirmwareId: null,
applyTime: null,
+ multipartHttpPushUri: null,
httpPushUri: null,
},
getters: {
@@ -41,6 +42,8 @@
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 @@
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 @@
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 4c302df..28d1104 100644
--- a/src/views/Operations/Firmware/FirmwareFormUpdate.vue
+++ b/src/views/Operations/Firmware/FirmwareFormUpdate.vue
@@ -100,7 +100,9 @@
},
dispatchWorkstationUpload(timerId) {
this.$store
- .dispatch('firmware/uploadFirmware', this.file)
+ .dispatch('firmware/uploadFirmware', {
+ image: this.file,
+ })
.catch(({ message }) => {
this.endLoader();
this.errorToast(message);