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) |
Nikhil Ashoka | f11a190 | 2024-05-09 15:17:44 +0530 | [diff] [blame] | 61 | .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 Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 69 | .catch((error) => { |
| 70 | dispatch('getBmcInfo'); |
| 71 | console.log('error', error); |
| 72 | if (led.identifyLed) { |
| 73 | throw new Error( |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 74 | i18n.t('pageInventory.toast.errorEnableIdentifyLed'), |
Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 75 | ); |
| 76 | } else { |
| 77 | throw new Error( |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 78 | i18n.t('pageInventory.toast.errorDisableIdentifyLed'), |
Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 79 | ); |
| 80 | } |
| 81 | }); |
| 82 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 83 | }, |
Yoshie Muranaka | 54c6bfc | 2020-06-12 08:29:42 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
Sandeepa Singh | 78b6b53 | 2021-04-09 18:08:22 +0530 | [diff] [blame] | 86 | export default BmcStore; |