1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
import api from '@/store/api';
import i18n from '@/i18n';
const PoliciesStore = {
namespaced: true,
state: {
sshProtocolEnabled: false,
ipmiProtocolEnabled: false,
},
getters: {
sshProtocolEnabled: (state) => state.sshProtocolEnabled,
ipmiProtocolEnabled: (state) => state.ipmiProtocolEnabled,
},
mutations: {
setSshProtocolEnabled: (state, sshProtocolEnabled) =>
(state.sshProtocolEnabled = sshProtocolEnabled),
setIpmiProtocolEnabled: (state, ipmiProtocolEnabled) =>
(state.ipmiProtocolEnabled = ipmiProtocolEnabled),
},
actions: {
async getNetworkProtocolStatus({ commit }) {
return await api
.get('/redfish/v1/Managers/bmc/NetworkProtocol')
.then((response) => {
const sshProtocol = response.data.SSH.ProtocolEnabled;
const ipmiProtocol = response.data.IPMI.ProtocolEnabled;
commit('setSshProtocolEnabled', sshProtocol);
commit('setIpmiProtocolEnabled', ipmiProtocol);
})
.catch((error) => console.log(error));
},
async saveIpmiProtocolState({ commit }, protocolEnabled) {
commit('setIpmiProtocolEnabled', protocolEnabled);
const ipmi = {
IPMI: {
ProtocolEnabled: protocolEnabled,
},
};
return await api
.patch('/redfish/v1/Managers/bmc/NetworkProtocol', ipmi)
.then(() => {
if (protocolEnabled) {
return i18n.t('pagePolicies.toast.successIpmiEnabled');
} else {
return i18n.t('pagePolicies.toast.successIpmiDisabled');
}
})
.catch((error) => {
console.log(error);
commit('setIpmiProtocolEnabled', !protocolEnabled);
if (protocolEnabled) {
throw new Error(i18n.t('pagePolicies.toast.errorIpmiEnabled'));
} else {
throw new Error(i18n.t('pagePolicies.toast.errorIpmiDisabled'));
}
});
},
async saveSshProtocolState({ commit }, protocolEnabled) {
commit('setSshProtocolEnabled', protocolEnabled);
const ssh = {
SSH: {
ProtocolEnabled: protocolEnabled,
},
};
return await api
.patch('/redfish/v1/Managers/bmc/NetworkProtocol', ssh)
.then(() => {
if (protocolEnabled) {
return i18n.t('pagePolicies.toast.successSshEnabled');
} else {
return i18n.t('pagePolicies.toast.successSshDisabled');
}
})
.catch((error) => {
console.log(error);
commit('setSshProtocolEnabled', !protocolEnabled);
if (protocolEnabled) {
throw new Error(i18n.t('pagePolicies.toast.errorSshEnabled'));
} else {
throw new Error(i18n.t('pagePolicies.toast.errorSshDisabled'));
}
});
},
},
};
export default PoliciesStore;
|