summaryrefslogtreecommitdiff
path: root/src/store/modules/GlobalStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/store/modules/GlobalStore.js')
-rw-r--r--src/store/modules/GlobalStore.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js
index 8cf2e8eb..80d9c1a3 100644
--- a/src/store/modules/GlobalStore.js
+++ b/src/store/modules/GlobalStore.js
@@ -1,10 +1,31 @@
import api from '../api';
+const HOST_STATE = {
+ on: 'xyz.openbmc_project.State.Host.HostState.Running',
+ off: 'xyz.openbmc_project.State.Host.HostState.Off',
+ error: 'xyz.openbmc_project.State.Host.HostState.Quiesced',
+ diagnosticMode: 'xyz.openbmc_project.State.Host.HostState.DiagnosticMode'
+};
+
+const hostStateMapper = hostState => {
+ switch (hostState) {
+ case HOST_STATE.on:
+ return 'on';
+ case HOST_STATE.off:
+ return 'off';
+ case HOST_STATE.error:
+ return 'error';
+ // TODO: Add mapping for DiagnosticMode
+ default:
+ return 'unreachable';
+ }
+};
+
const GlobalStore = {
namespaced: true,
state: {
hostName: '--',
- hostStatus: null
+ hostStatus: 'unreachable'
},
getters: {
hostName(state) {
@@ -17,6 +38,9 @@ const GlobalStore = {
mutations: {
setHostName(state, hostName) {
state.hostName = hostName;
+ },
+ setHostStatus(state, hostState) {
+ state.hostStatus = hostStateMapper(hostState);
}
},
actions: {
@@ -28,6 +52,15 @@ const GlobalStore = {
commit('setHostName', hostName);
})
.catch(error => console.log(error));
+ },
+ getHostStatus({ commit }) {
+ api
+ .get('/xyz/openbmc_project/state/host0/attr/CurrentHostState')
+ .then(response => {
+ const hostState = response.data.data;
+ commit('setHostStatus', hostState);
+ })
+ .catch(error => console.log(error));
}
}
};