blob: ea519d73ca095afc4aedbc60691430a74d9e6369 [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;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070025 system.model = data.Model;
Sukanya Pandey05388962021-06-10 15:35:21 +053026 system.processorSummaryCount = data.ProcessorSummary?.Count;
Nikhil Ashoka18cde3c2022-01-05 22:21:24 +053027 system.processorSummaryCoreCount = data.ProcessorSummary?.CoreCount;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070028 system.powerState = data.PowerState;
29 system.serialNumber = data.SerialNumber;
Sukanya Pandey05388962021-06-10 15:35:21 +053030 system.healthRollup = data.Status?.HealthRollup;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053031 system.subModel = data.SubModel;
Sukanya Pandey05388962021-06-10 15:35:21 +053032 system.statusState = data.Status?.State;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070033 system.systemType = data.SystemType;
34 state.systems = [system];
Derick Montague602e98a2020-10-21 16:20:00 -050035 },
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070036 },
37 actions: {
38 async getSystem({ commit }) {
39 return await api
Sukanya Pandey05388962021-06-10 15:35:21 +053040 .get('/redfish/v1')
41 .then((response) =>
Ed Tanous81323992024-02-27 11:26:24 -080042 api.get(`${response.data.Systems['@odata.id']}/system`),
Sukanya Pandey05388962021-06-10 15:35:21 +053043 )
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070044 .then(({ data }) => commit('setSystemInfo', data))
Derick Montague602e98a2020-10-21 16:20:00 -050045 .catch((error) => console.log(error));
46 },
Sukanya Pandey05388962021-06-10 15:35:21 +053047 async changeIdentifyLedState({ commit }, ledState) {
48 return await api
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053049 .patch('/redfish/v1/Systems/system', {
50 LocationIndicatorActive: ledState,
51 })
Nikhil Ashokaf11a1902024-05-09 15:17:44 +053052 .then(() => {
53 if (ledState) {
54 return i18n.t('pageInventory.toast.successEnableIdentifyLed');
55 } else {
56 return i18n.t('pageInventory.toast.successDisableIdentifyLed');
57 }
58 })
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053059 .catch((error) => {
Sukanya Pandey05388962021-06-10 15:35:21 +053060 commit('setSystemInfo', this.state.system.systems[0]);
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053061 console.log('error', error);
62 if (ledState) {
63 throw new Error(
Ed Tanous81323992024-02-27 11:26:24 -080064 i18n.t('pageInventory.toast.errorEnableIdentifyLed'),
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053065 );
66 } else {
67 throw new Error(
Ed Tanous81323992024-02-27 11:26:24 -080068 i18n.t('pageInventory.toast.errorDisableIdentifyLed'),
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053069 );
70 }
71 });
72 },
Derick Montague602e98a2020-10-21 16:20:00 -050073 },
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070074};
75
76export default SystemStore;