summaryrefslogtreecommitdiff
path: root/src/store/modules/Health
diff options
context:
space:
mode:
Diffstat (limited to 'src/store/modules/Health')
-rw-r--r--src/store/modules/Health/DumpsStore.js117
-rw-r--r--src/store/modules/Health/EventLogStore.js222
2 files changed, 0 insertions, 339 deletions
diff --git a/src/store/modules/Health/DumpsStore.js b/src/store/modules/Health/DumpsStore.js
deleted file mode 100644
index 3b91354b..00000000
--- a/src/store/modules/Health/DumpsStore.js
+++ /dev/null
@@ -1,117 +0,0 @@
-import api, { getResponseCount } from '@/store/api';
-import i18n from '@/i18n';
-
-const DumpsStore = {
- namespaced: true,
- state: {
- bmcDumps: [],
- },
- getters: {
- 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,
- }));
- },
- },
- actions: {
- async getBmcDumps({ commit }) {
- return await api
- .get('/redfish/v1/Managers/bmc/LogServices/Dump/Entries')
- .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)
- );
- });
- },
- },
-};
-
-export default DumpsStore;
diff --git a/src/store/modules/Health/EventLogStore.js b/src/store/modules/Health/EventLogStore.js
deleted file mode 100644
index c9bd82fd..00000000
--- a/src/store/modules/Health/EventLogStore.js
+++ /dev/null
@@ -1,222 +0,0 @@
-import api, { getResponseCount } from '@/store/api';
-import i18n from '@/i18n';
-
-const getHealthStatus = (events, loadedEvents) => {
- let status = loadedEvents ? 'OK' : '';
- for (const event of events) {
- if (event.severity === 'Warning') {
- status = 'Warning';
- }
- if (event.severity === 'Critical') {
- status = 'Critical';
- break;
- }
- }
- return status;
-};
-
-// TODO: High priority events should also check if Log
-// is resolved when the property is available in Redfish
-const getHighPriorityEvents = (events) =>
- events.filter(({ severity }) => severity === 'Critical');
-
-const EventLogStore = {
- namespaced: true,
- state: {
- allEvents: [],
- loadedEvents: false,
- },
- getters: {
- allEvents: (state) => state.allEvents,
- highPriorityEvents: (state) => getHighPriorityEvents(state.allEvents),
- healthStatus: (state) =>
- getHealthStatus(state.allEvents, state.loadedEvents),
- },
- mutations: {
- setAllEvents: (state, allEvents) => (
- (state.allEvents = allEvents), (state.loadedEvents = true)
- ),
- },
- actions: {
- async getEventLogData({ commit }) {
- return await api
- .get('/redfish/v1/Systems/system/LogServices/EventLog/Entries')
- .then(({ data: { Members = [] } = {} }) => {
- const eventLogs = Members.map((log) => {
- const {
- Id,
- Severity,
- Created,
- EntryType,
- Message,
- Name,
- Modified,
- Resolved,
- AdditionalDataURI,
- } = log;
- return {
- id: Id,
- severity: Severity,
- date: new Date(Created),
- type: EntryType,
- description: Message,
- name: Name,
- modifiedDate: new Date(Modified),
- uri: log['@odata.id'],
- filterByStatus: Resolved ? 'Resolved' : 'Unresolved',
- status: Resolved, //true or false
- additionalDataUri: AdditionalDataURI,
- };
- });
- commit('setAllEvents', eventLogs);
- })
- .catch((error) => {
- console.log('Event Log Data:', error);
- });
- },
- async deleteAllEventLogs({ dispatch }, data) {
- return await api
- .post(
- '/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.ClearLog'
- )
- .then(() => dispatch('getEventLogData'))
- .then(() => i18n.tc('pageEventLogs.toast.successDelete', data.length))
- .catch((error) => {
- console.log(error);
- throw new Error(
- i18n.tc('pageEventLogs.toast.errorDelete', data.length)
- );
- });
- },
- async deleteEventLogs({ dispatch }, uris = []) {
- const promises = uris.map((uri) =>
- api.delete(uri).catch((error) => {
- console.log(error);
- return error;
- })
- );
- return await api
- .all(promises)
- .then((response) => {
- dispatch('getEventLogData');
- return response;
- })
- .then(
- api.spread((...responses) => {
- const { successCount, errorCount } = getResponseCount(responses);
- const toastMessages = [];
-
- if (successCount) {
- const message = i18n.tc(
- 'pageEventLogs.toast.successDelete',
- successCount
- );
- toastMessages.push({ type: 'success', message });
- }
-
- if (errorCount) {
- const message = i18n.tc(
- 'pageEventLogs.toast.errorDelete',
- errorCount
- );
- toastMessages.push({ type: 'error', message });
- }
-
- return toastMessages;
- })
- );
- },
- async resolveEventLogs({ dispatch }, logs) {
- const promises = logs.map((log) =>
- api.patch(log.uri, { Resolved: true }).catch((error) => {
- console.log(error);
- return error;
- })
- );
- return await api
- .all(promises)
- .then((response) => {
- dispatch('getEventLogData');
- return response;
- })
- .then(
- api.spread((...responses) => {
- const { successCount, errorCount } = getResponseCount(responses);
- const toastMessages = [];
- if (successCount) {
- const message = i18n.tc(
- 'pageEventLogs.toast.successResolveLogs',
- successCount
- );
- toastMessages.push({ type: 'success', message });
- }
- if (errorCount) {
- const message = i18n.tc(
- 'pageEventLogs.toast.errorResolveLogs',
- errorCount
- );
- toastMessages.push({ type: 'error', message });
- }
- return toastMessages;
- })
- );
- },
- async unresolveEventLogs({ dispatch }, logs) {
- const promises = logs.map((log) =>
- api.patch(log.uri, { Resolved: false }).catch((error) => {
- console.log(error);
- return error;
- })
- );
- return await api
- .all(promises)
- .then((response) => {
- dispatch('getEventLogData');
- return response;
- })
- .then(
- api.spread((...responses) => {
- const { successCount, errorCount } = getResponseCount(responses);
- const toastMessages = [];
- if (successCount) {
- const message = i18n.tc(
- 'pageEventLogs.toast.successUnresolveLogs',
- successCount
- );
- toastMessages.push({ type: 'success', message });
- }
- if (errorCount) {
- const message = i18n.tc(
- 'pageEventLogs.toast.errorUnresolveLogs',
- errorCount
- );
- toastMessages.push({ type: 'error', message });
- }
- return toastMessages;
- })
- );
- },
- // Single log entry
- async updateEventLogStatus({ dispatch }, log) {
- const updatedEventLogStatus = log.status;
- return await api
- .patch(log.uri, { Resolved: updatedEventLogStatus })
- .then(() => {
- dispatch('getEventLogData');
- })
- .then(() => {
- if (log.status) {
- return i18n.tc('pageEventLogs.toast.successResolveLogs', 1);
- } else {
- return i18n.tc('pageEventLogs.toast.successUnresolveLogs', 1);
- }
- })
- .catch((error) => {
- console.log(error);
- throw new Error(i18n.t('pageEventLogs.toast.errorLogStatusUpdate'));
- });
- },
- },
-};
-
-export default EventLogStore;