blob: d96926ea42c510ab30686216aa5eb33c7c787b6c [file] [log] [blame]
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -07001import api from '@/store/api';
Sandeepa Singh78b6b532021-04-09 18:08:22 +05302import i18n from '@/i18n';
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -07003
Sandeepa Singh78b6b532021-04-09 18:08:22 +05304const BmcStore = {
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -07005 namespaced: true,
6 state: {
Derick Montague602e98a2020-10-21 16:20:00 -05007 bmc: null,
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -07008 },
9 getters: {
Derick Montague602e98a2020-10-21 16:20:00 -050010 bmc: (state) => state.bmc,
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070011 },
12 mutations: {
13 setBmcInfo: (state, data) => {
14 const bmc = {};
Sandeepa Singh78b6b532021-04-09 18:08:22 +053015 bmc.dateTime = new Date(data.DateTime);
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070016 bmc.description = data.Description;
17 bmc.firmwareVersion = data.FirmwareVersion;
18 bmc.graphicalConsoleConnectTypes =
19 data.GraphicalConsole.ConnectTypesSupported;
20 bmc.graphicalConsoleEnabled = data.GraphicalConsole.ServiceEnabled;
21 bmc.graphicalConsoleMaxSessions =
22 data.GraphicalConsole.MaxConcurrentSessions;
23 bmc.health = data.Status.Health;
24 bmc.healthRollup = data.Status.HealthRollup;
25 bmc.id = data.Id;
Sandeepa Singh78b6b532021-04-09 18:08:22 +053026 bmc.lastResetTime = new Date(data.LastResetTime);
27 bmc.identifyLed = data.LocationIndicatorActive;
Sneha Patel9f612342021-09-02 12:23:42 -050028 bmc.locationNumber = data.Location?.PartLocation?.ServiceLabel;
Sandeepa Singh78b6b532021-04-09 18:08:22 +053029 bmc.manufacturer = data.manufacturer;
30 bmc.managerType = data.ManagerType;
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070031 bmc.model = data.Model;
Sandeepa Singh78b6b532021-04-09 18:08:22 +053032 bmc.name = data.Name;
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070033 bmc.partNumber = data.PartNumber;
34 bmc.powerState = data.PowerState;
35 bmc.serialConsoleConnectTypes = data.SerialConsole.ConnectTypesSupported;
36 bmc.serialConsoleEnabled = data.SerialConsole.ServiceEnabled;
37 bmc.serialConsoleMaxSessions = data.SerialConsole.MaxConcurrentSessions;
38 bmc.serialNumber = data.SerialNumber;
39 bmc.serviceEntryPointUuid = data.ServiceEntryPointUUID;
Sandeepa Singh78b6b532021-04-09 18:08:22 +053040 bmc.sparePartNumber = data.SparePartNumber;
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070041 bmc.statusState = data.Status.State;
42 bmc.uuid = data.UUID;
Sandeepa Singh78b6b532021-04-09 18:08:22 +053043 bmc.uri = data['@odata.id'];
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070044 state.bmc = bmc;
Derick Montague602e98a2020-10-21 16:20:00 -050045 },
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070046 },
47 actions: {
48 async getBmcInfo({ commit }) {
49 return await api
50 .get('/redfish/v1/Managers/bmc')
51 .then(({ data }) => commit('setBmcInfo', data))
Derick Montague602e98a2020-10-21 16:20:00 -050052 .catch((error) => console.log(error));
53 },
Sandeepa Singh78b6b532021-04-09 18:08:22 +053054 async updateIdentifyLedValue({ dispatch }, led) {
55 const uri = led.uri;
56 const updatedIdentifyLedValue = {
57 LocationIndicatorActive: led.identifyLed,
58 };
59 return await api
60 .patch(uri, updatedIdentifyLedValue)
Nikhil Ashokaf11a1902024-05-09 15:17:44 +053061 .then(() => {
62 dispatch('getBmcInfo');
63 if (led.identifyLed) {
64 return i18n.t('pageInventory.toast.successEnableIdentifyLed');
65 } else {
66 return i18n.t('pageInventory.toast.successDisableIdentifyLed');
67 }
68 })
Sandeepa Singh78b6b532021-04-09 18:08:22 +053069 .catch((error) => {
70 dispatch('getBmcInfo');
71 console.log('error', error);
72 if (led.identifyLed) {
73 throw new Error(
Ed Tanous81323992024-02-27 11:26:24 -080074 i18n.t('pageInventory.toast.errorEnableIdentifyLed'),
Sandeepa Singh78b6b532021-04-09 18:08:22 +053075 );
76 } else {
77 throw new Error(
Ed Tanous81323992024-02-27 11:26:24 -080078 i18n.t('pageInventory.toast.errorDisableIdentifyLed'),
Sandeepa Singh78b6b532021-04-09 18:08:22 +053079 );
80 }
81 });
82 },
Derick Montague602e98a2020-10-21 16:20:00 -050083 },
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070084};
85
Sandeepa Singh78b6b532021-04-09 18:08:22 +053086export default BmcStore;