diff options
author | Dixsie Wolmers <dixsie@ibm.com> | 2020-02-26 20:23:52 +0300 |
---|---|---|
committer | Gunnar Mills <gmills@us.ibm.com> | 2020-03-06 22:53:35 +0300 |
commit | 4c69f5b7658337b8d621c3c26aa30708848e63ed (patch) | |
tree | fd50689fbd5781b9b86c68ce0866b6403955764d /src/store/modules/Control/PowerControlStore.js | |
parent | c85395f21d7e27ba16f4b9005e7f2f2452cdd7f8 (diff) | |
download | webui-vue-4c69f5b7658337b8d621c3c26aa30708848e63ed.tar.xz |
Move power control to redfish
Replaces power cap store and power consumption store with power control store
and uses redfish.
Signed-off-by: Dixsie Wolmers <dixsie@ibm.com>
Change-Id: I5cce223da17373bcae3e7c6736a4580e1bd8ae00
Diffstat (limited to 'src/store/modules/Control/PowerControlStore.js')
-rw-r--r-- | src/store/modules/Control/PowerControlStore.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/store/modules/Control/PowerControlStore.js b/src/store/modules/Control/PowerControlStore.js new file mode 100644 index 00000000..63ede2d4 --- /dev/null +++ b/src/store/modules/Control/PowerControlStore.js @@ -0,0 +1,39 @@ +import api from '../../api'; + +const PowerControlStore = { + namespaced: true, + state: { + powerCapValue: null, + powerConsumptionValue: null + }, + getters: { + powerCapValue: state => state.powerCapValue, + powerConsumptionValue: state => state.powerConsumptionValue + }, + mutations: { + setPowerCapValue: (state, powerCapValue) => + (state.powerCapValue = powerCapValue), + setPowerConsumptionValue: (state, powerConsumptionValue) => + (state.powerConsumptionValue = powerConsumptionValue) + }, + actions: { + getPowerControl({ commit }) { + api + .get('/redfish/v1/Chassis/chassis/Power') + .then(response => { + const powerControl = response.data.PowerControl; + const powerCap = powerControl[0].PowerLimit.LimitInWatts; + // If system is powered off, power consumption does not exist in the PowerControl + const powerConsumption = powerControl[0].PowerConsumedWatts || null; + + commit('setPowerCapValue', powerCap); + commit('setPowerConsumptionValue', powerConsumption); + }) + .catch(error => { + console.log('Power control', error); + }); + } + } +}; + +export default PowerControlStore; |