diff options
author | Leo Xu <yongquanx@nvidia.com> | 2024-07-29 05:54:18 +0300 |
---|---|---|
committer | jwestover <jwestover@nvidia.com> | 2024-09-10 23:42:16 +0300 |
commit | e2c716a91f3cf130427600c26ae58de0f9750f2a (patch) | |
tree | 866e575670b779f53a35e522d47ea3ba57a585fe | |
parent | 8876eceffa71ed8b28a856c48a8acb18167c9340 (diff) | |
download | webui-vue-e2c716a91f3cf130427600c26ae58de0f9750f2a.tar.xz |
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>
-rw-r--r-- | src/store/modules/Operations/FirmwareStore.js | 31 | ||||
-rw-r--r-- | src/views/Operations/Firmware/FirmwareFormUpdate.vue | 4 |
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); |