blob: a1394f1ee498406a407f42540c25e794d1163adf [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;
Sukanya Pandey05388962021-06-10 15:35:21 +053019 system.health = data.Status?.Health;
Nikhil Ashoka18cde3c2022-01-05 22:21:24 +053020 system.totalSystemMemoryGiB = data.MemorySummary?.TotalSystemMemoryGiB;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070021 system.id = data.Id;
SurenNewarebbf896c2021-01-27 21:50:22 +053022 system.locationIndicatorActive = data.LocationIndicatorActive;
Sneha Patel9f612342021-09-02 12:23:42 -050023 system.locationNumber = data.Location?.PartLocation?.ServiceLabel;
Yoshie Muranakac687f102020-06-02 12:01:27 -070024 system.manufacturer = data.Manufacturer;
Sukanya Pandey05388962021-06-10 15:35:21 +053025 system.memorySummaryHealth = data.MemorySummary?.Status.Health;
26 system.memorySummaryHealthRollup =
27 data.MemorySummary?.Status?.HealthRollup;
28 system.memorySummaryState = data.MemorySummary?.Status?.State;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070029 system.model = data.Model;
Sukanya Pandey05388962021-06-10 15:35:21 +053030 system.processorSummaryCount = data.ProcessorSummary?.Count;
Nikhil Ashoka18cde3c2022-01-05 22:21:24 +053031 system.processorSummaryCoreCount = data.ProcessorSummary?.CoreCount;
Sukanya Pandey05388962021-06-10 15:35:21 +053032 system.processorSummaryHealth = data.ProcessorSummary?.Status?.Health;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053033 system.processorSummaryHealthRoll =
Sukanya Pandey05388962021-06-10 15:35:21 +053034 data.ProcessorSummary?.Status.HealthRollup;
35 system.processorSummaryState = data.ProcessorSummary?.Status?.State;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070036 system.powerState = data.PowerState;
37 system.serialNumber = data.SerialNumber;
Sukanya Pandey05388962021-06-10 15:35:21 +053038 system.healthRollup = data.Status?.HealthRollup;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053039 system.subModel = data.SubModel;
Sukanya Pandey05388962021-06-10 15:35:21 +053040 system.statusState = data.Status?.State;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070041 system.systemType = data.SystemType;
42 state.systems = [system];
Derick Montague602e98a2020-10-21 16:20:00 -050043 },
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070044 },
45 actions: {
46 async getSystem({ commit }) {
47 return await api
Sukanya Pandey05388962021-06-10 15:35:21 +053048 .get('/redfish/v1')
49 .then((response) =>
50 api.get(`${response.data.Systems['@odata.id']}/system`)
51 )
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070052 .then(({ data }) => commit('setSystemInfo', data))
Derick Montague602e98a2020-10-21 16:20:00 -050053 .catch((error) => console.log(error));
54 },
Sukanya Pandey05388962021-06-10 15:35:21 +053055 async changeIdentifyLedState({ commit }, ledState) {
56 return await api
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053057 .patch('/redfish/v1/Systems/system', {
58 LocationIndicatorActive: ledState,
59 })
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053060 .catch((error) => {
Sukanya Pandey05388962021-06-10 15:35:21 +053061 commit('setSystemInfo', this.state.system.systems[0]);
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053062 console.log('error', error);
63 if (ledState) {
64 throw new Error(
Sukanya Pandey05388962021-06-10 15:35:21 +053065 i18n.t('pageInventory.toast.errorEnableIdentifyLed')
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053066 );
67 } else {
68 throw new Error(
Sukanya Pandey05388962021-06-10 15:35:21 +053069 i18n.t('pageInventory.toast.errorDisableIdentifyLed')
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053070 );
71 }
72 });
73 },
Derick Montague602e98a2020-10-21 16:20:00 -050074 },
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070075};
76
77export default SystemStore;