blob: b4ee3847147512f929e69c2b40afa64cf3480e9c [file] [log] [blame]
Yoshie Muranaka56ee7692020-05-28 13:28:29 -07001import api from '@/store/api';
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +05302import i18n from '@/i18n';
Yoshie Muranaka56ee7692020-05-28 13:28:29 -07003
4const SystemStore = {
5 namespaced: true,
6 state: {
Derick Montague602e98a2020-10-21 16:20:00 -05007 systems: [],
Yoshie Muranaka56ee7692020-05-28 13:28:29 -07008 },
9 getters: {
Derick Montague602e98a2020-10-21 16:20:00 -050010 systems: (state) => state.systems,
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070011 },
12 mutations: {
13 setSystemInfo: (state, data) => {
14 const system = {};
15 system.assetTag = data.AssetTag;
16 system.description = data.Description;
Yoshie Muranakac687f102020-06-02 12:01:27 -070017 system.firmwareVersion = data.BiosVersion;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053018 system.hardwareType = data.Name;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070019 system.health = data.Status.Health;
20 system.id = data.Id;
SurenNewarebbf896c2021-01-27 21:50:22 +053021 system.locationIndicatorActive = data.LocationIndicatorActive;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053022 system.locationNumber = data.LocationNumber;
Yoshie Muranakac687f102020-06-02 12:01:27 -070023 system.manufacturer = data.Manufacturer;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053024 system.memorySummaryHealth = data.MemorySummary.Status.Health;
25 system.memorySummaryHealthRollup = data.MemorySummary.Status.HealthRollup;
26 system.memorySummaryState = data.MemorySummary.Status.State;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070027 system.model = data.Model;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053028 system.processorSummaryCount = data.ProcessorSummary.Count;
29 system.processorSummaryHealth = data.ProcessorSummary.Status.Health;
30 system.processorSummaryHealthRoll =
31 data.ProcessorSummary.Status.HealthRollup;
32 system.processorSummaryState = data.ProcessorSummary.Status.State;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070033 system.powerState = data.PowerState;
34 system.serialNumber = data.SerialNumber;
35 system.healthRollup = data.Status.HealthRollup;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053036 system.subModel = data.SubModel;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070037 system.statusState = data.Status.State;
38 system.systemType = data.SystemType;
39 state.systems = [system];
Derick Montague602e98a2020-10-21 16:20:00 -050040 },
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070041 },
42 actions: {
43 async getSystem({ commit }) {
44 return await api
45 .get('/redfish/v1/Systems/system')
46 .then(({ data }) => commit('setSystemInfo', data))
Derick Montague602e98a2020-10-21 16:20:00 -050047 .catch((error) => console.log(error));
48 },
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053049 changeIdentifyLedState({ dispatch }, ledState) {
50 api
51 .patch('/redfish/v1/Systems/system', {
52 LocationIndicatorActive: ledState,
53 })
54 .then(() => dispatch('getSystem'))
55 .catch((error) => {
56 dispatch('getSystem');
57 console.log('error', error);
58 if (ledState) {
59 throw new Error(
60 i18n.t('pageHardwareStatus.toast.errorTurnOnIdentifyLed')
61 );
62 } else {
63 throw new Error(
64 i18n.t('pageHardwareStatus.toast.errorTurnOffIdentifyLed')
65 );
66 }
67 });
68 },
Derick Montague602e98a2020-10-21 16:20:00 -050069 },
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070070};
71
72export default SystemStore;