blob: c042a83a5c788cc7a810cd79060ec3f0de02c07b [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)
61 .then(() => dispatch('getBmcInfo'))
62 .catch((error) => {
63 dispatch('getBmcInfo');
64 console.log('error', error);
65 if (led.identifyLed) {
66 throw new Error(
Sandeepa Singh7affc522021-07-06 16:29:10 +053067 i18n.t('pageInventory.toast.errorEnableIdentifyLed')
Sandeepa Singh78b6b532021-04-09 18:08:22 +053068 );
69 } else {
70 throw new Error(
Sandeepa Singh7affc522021-07-06 16:29:10 +053071 i18n.t('pageInventory.toast.errorDisableIdentifyLed')
Sandeepa Singh78b6b532021-04-09 18:08:22 +053072 );
73 }
74 });
75 },
Derick Montague602e98a2020-10-21 16:20:00 -050076 },
Yoshie Muranaka54c6bfc2020-06-12 08:29:42 -070077};
78
Sandeepa Singh78b6b532021-04-09 18:08:22 +053079export default BmcStore;