1import api from '@/store/api'; 2import i18n from '@/i18n'; 3 4const BmcStore = { 5 namespaced: true, 6 state: { 7 bmc: null, 8 }, 9 getters: { 10 bmc: (state) => state.bmc, 11 }, 12 mutations: { 13 setBmcInfo: (state, data) => { 14 const bmc = {}; 15 bmc.dateTime = new Date(data.DateTime); 16 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; 26 bmc.lastResetTime = new Date(data.LastResetTime); 27 bmc.identifyLed = data.LocationIndicatorActive; 28 bmc.locationNumber = data.Location?.PartLocation?.ServiceLabel; 29 bmc.manufacturer = data.manufacturer; 30 bmc.managerType = data.ManagerType; 31 bmc.model = data.Model; 32 bmc.name = data.Name; 33 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; 40 bmc.sparePartNumber = data.SparePartNumber; 41 bmc.statusState = data.Status.State; 42 bmc.uuid = data.UUID; 43 bmc.uri = data['@odata.id']; 44 state.bmc = bmc; 45 }, 46 }, 47 actions: { 48 async getBmcInfo({ commit }) { 49 return await api 50 .get('/redfish/v1/Managers/bmc') 51 .then(({ data }) => commit('setBmcInfo', data)) 52 .catch((error) => console.log(error)); 53 }, 54 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( 67 i18n.t('pageInventory.toast.errorEnableIdentifyLed'), 68 ); 69 } else { 70 throw new Error( 71 i18n.t('pageInventory.toast.errorDisableIdentifyLed'), 72 ); 73 } 74 }); 75 }, 76 }, 77}; 78 79export default BmcStore; 80