diff options
author | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2020-12-08 00:04:11 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2021-01-05 22:54:01 +0300 |
commit | f415a0898b6f1f5cee8aa43259e8aedf07d395aa (patch) | |
tree | c4cb17fba51d9d4c6caa266081f07b95778abf9d /src/env/store | |
parent | 22d4d527af48d87ca70a8766bacc5b1ec0cfe9b7 (diff) | |
download | webui-vue-f415a0898b6f1f5cee8aa43259e8aedf07d395aa.tar.xz |
Add DumpsStore API calls
Ties in API requests to the Dumps page and adds ability to:
- Create new System or BMC dump
- Delete single or multiple BMC dumps. Uses ClearLog service to
delete all and DELETE request for single dump deletion
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: Iae928fa3b8fab00e549c33c0ab914a4b04de0f40
Diffstat (limited to 'src/env/store')
-rw-r--r-- | src/env/store/Dumps/DumpsStore.js | 91 |
1 files changed, 88 insertions, 3 deletions
diff --git a/src/env/store/Dumps/DumpsStore.js b/src/env/store/Dumps/DumpsStore.js index 45f446c0..3b91354b 100644 --- a/src/env/store/Dumps/DumpsStore.js +++ b/src/env/store/Dumps/DumpsStore.js @@ -1,4 +1,5 @@ -import api from '@/store/api'; +import api, { getResponseCount } from '@/store/api'; +import i18n from '@/i18n'; const DumpsStore = { namespaced: true, @@ -6,16 +7,17 @@ const DumpsStore = { bmcDumps: [], }, getters: { - allDumps: (state) => state.bmcDumps, + bmcDumps: (state) => state.bmcDumps, }, mutations: { setBmcDumps: (state, dumps) => { state.bmcDumps = dumps.map((dump) => ({ + data: dump.AdditionalDataURI, dateTime: new Date(dump.Created), dumpType: dump.Name, id: dump.Id, + location: dump['@odata.id'], size: dump.AdditionalDataSizeBytes, - data: dump.AdditionalDataURI, })); }, }, @@ -26,6 +28,89 @@ const DumpsStore = { .then(({ data = {} }) => commit('setBmcDumps', data.Members || [])) .catch((error) => console.log(error)); }, + async createBmcDump() { + return await api + .post( + '/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData', + { + DiagnosticDataType: 'Manager', + OEMDiagnosticDataType: '', + } + ) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pageDumps.toast.errorStartBmcDump')); + }); + }, + async createSystemDump() { + return await api + .post( + '/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.CollectDiagnosticData', + { + DiagnosticDataType: 'OEM', + OEMDiagnosticDataType: 'System', + } + ) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pageDumps.toast.errorStartSystemDump')); + }); + }, + async deleteDumps({ dispatch }, dumps) { + const promises = dumps.map(({ location }) => + api.delete(location).catch((error) => { + console.log(error); + return error; + }) + ); + return await api + .all(promises) + .then((response) => { + dispatch('getBmcDumps'); + return response; + }) + .then( + api.spread((...responses) => { + const { successCount, errorCount } = getResponseCount(responses); + const toastMessages = []; + + if (successCount) { + const message = i18n.tc( + 'pageDumps.toast.successDeleteDump', + successCount + ); + toastMessages.push({ type: 'success', message }); + } + + if (errorCount) { + const message = i18n.tc( + 'pageDumps.toast.errorDeleteDump', + errorCount + ); + toastMessages.push({ type: 'error', message }); + } + + return toastMessages; + }) + ); + }, + async deleteAllDumps({ commit, state }) { + const totalDumpCount = state.bmcDumps.length; + return await api + .post( + '/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog' + ) + .then(() => { + commit('setBmcDumps', []); + return i18n.tc('pageDumps.toast.successDeleteDump', totalDumpCount); + }) + .catch((error) => { + console.log(error); + throw new Error( + i18n.tc('pageDumps.toast.errorDeleteDump', totalDumpCount) + ); + }); + }, }, }; |