| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 1 | import api from '@/store/api'; | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 2 | import i18n from '@/i18n'; | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 3 |  | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 4 | const BmcStore = { | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 5 | namespaced: true, | 
|  | 6 | state: { | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 7 | bmc: null, | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 8 | }, | 
|  | 9 | getters: { | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 10 | bmc: (state) => state.bmc, | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 11 | }, | 
|  | 12 | mutations: { | 
|  | 13 | setBmcInfo: (state, data) => { | 
|  | 14 | const bmc = {}; | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 15 | bmc.dateTime = new Date(data.DateTime); | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 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; | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 26 | bmc.lastResetTime = new Date(data.LastResetTime); | 
|  | 27 | bmc.identifyLed = data.LocationIndicatorActive; | 
| Sneha Patel | 9f61234 | 2021-09-02 12:23:42 -0500 | [diff] [blame] | 28 | bmc.locationNumber = data.Location?.PartLocation?.ServiceLabel; | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 29 | bmc.manufacturer = data.manufacturer; | 
|  | 30 | bmc.managerType = data.ManagerType; | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 31 | bmc.model = data.Model; | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 32 | bmc.name = data.Name; | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 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; | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 40 | bmc.sparePartNumber = data.SparePartNumber; | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 41 | bmc.statusState = data.Status.State; | 
|  | 42 | bmc.uuid = data.UUID; | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 43 | bmc.uri = data['@odata.id']; | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 44 | state.bmc = bmc; | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 45 | }, | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 46 | }, | 
|  | 47 | actions: { | 
|  | 48 | async getBmcInfo({ commit }) { | 
|  | 49 | return await api | 
|  | 50 | .get('/redfish/v1/Managers/bmc') | 
|  | 51 | .then(({ data }) => commit('setBmcInfo', data)) | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 52 | .catch((error) => console.log(error)); | 
|  | 53 | }, | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 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( | 
| Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 67 | i18n.t('pageInventory.toast.errorEnableIdentifyLed') | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 68 | ); | 
|  | 69 | } else { | 
|  | 70 | throw new Error( | 
| Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 71 | i18n.t('pageInventory.toast.errorDisableIdentifyLed') | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 72 | ); | 
|  | 73 | } | 
|  | 74 | }); | 
|  | 75 | }, | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 76 | }, | 
| Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 77 | }; | 
|  | 78 |  | 
| Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 79 | export default BmcStore; |