Replace fixed paths with response from API
Currently, the Redfish request used fixed URIs, modify the code to use
the BMC and System paths got from response of API calls.
For CertificateStore, since it was using the URL for constant variable
assignment, changed the constant CERTIFICATE_TYPES to method call.
Change-Id: I330b7272083e3e6993aae5705aae170b8e9a4659
Signed-off-by: Sean Zhang <xiazhang@nvidia.com>
diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js
index 036dc48..10d50b1 100644
--- a/src/store/modules/GlobalStore.js
+++ b/src/store/modules/GlobalStore.js
@@ -77,9 +77,29 @@
},
},
actions: {
+ async getBmcPath() {
+ const serviceRoot = await api
+ .get('/redfish/v1')
+ .catch((error) => console.log(error));
+ let bmcPath = serviceRoot.data?.ManagerProvidingService?.['@odata.id'];
+ if (!bmcPath) {
+ const managers = await api
+ .get('/redfish/v1/Managers')
+ .catch((error) => console.log(error));
+ bmcPath = managers.data?.Members?.[0]?.['@odata.id'];
+ }
+ return bmcPath;
+ },
+ async getSystemPath() {
+ const systems = await api
+ .get('/redfish/v1/Systems')
+ .catch((error) => console.log(error));
+ let systemPath = systems.data?.Members?.[0]?.['@odata.id'];
+ return systemPath;
+ },
async getBmcTime({ commit }) {
return await api
- .get('/redfish/v1/Managers/bmc')
+ .get(`${await this.dispatch('global/getBmcPath')}`)
.then((response) => {
const bmcDateTime = response.data.DateTime;
const date = new Date(bmcDateTime);
@@ -87,9 +107,9 @@
})
.catch((error) => console.log(error));
},
- getSystemInfo({ commit }) {
+ async getSystemInfo({ commit }) {
api
- .get('/redfish/v1/Systems/system')
+ .get(`${await this.dispatch('global/getSystemPath')}`)
.then(
({
data: {
diff --git a/src/store/modules/HardwareStatus/BmcStore.js b/src/store/modules/HardwareStatus/BmcStore.js
index d96926e..f0e4cf9 100644
--- a/src/store/modules/HardwareStatus/BmcStore.js
+++ b/src/store/modules/HardwareStatus/BmcStore.js
@@ -47,7 +47,7 @@
actions: {
async getBmcInfo({ commit }) {
return await api
- .get('/redfish/v1/Managers/bmc')
+ .get(`${await this.dispatch('global/getBmcPath')}`)
.then(({ data }) => commit('setBmcInfo', data))
.catch((error) => console.log(error));
},
diff --git a/src/store/modules/HardwareStatus/MemoryStore.js b/src/store/modules/HardwareStatus/MemoryStore.js
index 787a050..d9a107d 100644
--- a/src/store/modules/HardwareStatus/MemoryStore.js
+++ b/src/store/modules/HardwareStatus/MemoryStore.js
@@ -60,7 +60,7 @@
actions: {
async getDimms({ commit }) {
return await api
- .get('/redfish/v1/Systems/system/Memory')
+ .get(`${await this.dispatch('global/getSystemPath')}/Memory`)
.then(({ data: { Members } }) => {
const promises = Members.map((item) => api.get(item['@odata.id']));
return api.all(promises);
diff --git a/src/store/modules/HardwareStatus/ProcessorStore.js b/src/store/modules/HardwareStatus/ProcessorStore.js
index 49f9620..446fdb9 100644
--- a/src/store/modules/HardwareStatus/ProcessorStore.js
+++ b/src/store/modules/HardwareStatus/ProcessorStore.js
@@ -63,7 +63,7 @@
actions: {
async getProcessorsInfo({ commit }) {
return await api
- .get('/redfish/v1/Systems/system/Processors')
+ .get(`${await this.dispatch('global/getSystemPath')}/Processors`)
.then(({ data: { Members = [] } }) =>
Members.map((member) => api.get(member['@odata.id'])),
)
diff --git a/src/store/modules/HardwareStatus/ServerLedStore.js b/src/store/modules/HardwareStatus/ServerLedStore.js
index af22802..d4af064 100644
--- a/src/store/modules/HardwareStatus/ServerLedStore.js
+++ b/src/store/modules/HardwareStatus/ServerLedStore.js
@@ -17,7 +17,7 @@
actions: {
async getIndicatorLedActiveState({ commit }) {
return await api
- .get('/redfish/v1/Systems/system')
+ .get(`${await this.dispatch('global/getSystemPath')}`)
.then((response) => {
commit(
'setIndicatorLedActiveState',
@@ -29,7 +29,7 @@
async saveIndicatorLedActiveState({ commit }, payload) {
commit('setIndicatorLedActiveState', payload);
return await api
- .patch('/redfish/v1/Systems/system', {
+ .patch(`${await this.dispatch('global/getSystemPath')}`, {
LocationIndicatorActive: payload,
})
.catch((error) => {
diff --git a/src/store/modules/HardwareStatus/SystemStore.js b/src/store/modules/HardwareStatus/SystemStore.js
index ea519d7..87d2810 100644
--- a/src/store/modules/HardwareStatus/SystemStore.js
+++ b/src/store/modules/HardwareStatus/SystemStore.js
@@ -37,16 +37,13 @@
actions: {
async getSystem({ commit }) {
return await api
- .get('/redfish/v1')
- .then((response) =>
- api.get(`${response.data.Systems['@odata.id']}/system`),
- )
+ .get(`${await this.dispatch('global/getSystemPath')}`)
.then(({ data }) => commit('setSystemInfo', data))
.catch((error) => console.log(error));
},
async changeIdentifyLedState({ commit }, ledState) {
return await api
- .patch('/redfish/v1/Systems/system', {
+ .patch(`${await this.dispatch('global/getSystemPath')}`, {
LocationIndicatorActive: ledState,
})
.then(() => {
diff --git a/src/store/modules/Logs/DumpsStore.js b/src/store/modules/Logs/DumpsStore.js
index 328e316..9391e57 100644
--- a/src/store/modules/Logs/DumpsStore.js
+++ b/src/store/modules/Logs/DumpsStore.js
@@ -24,9 +24,7 @@
actions: {
async getBmcDumpEntries() {
return api
- .get('/redfish/v1/')
- .then((response) => api.get(response.data.Managers['@odata.id']))
- .then((response) => api.get(`${response.data['@odata.id']}/bmc`))
+ .get(`${await this.dispatch('global/getBmcPath')}`)
.then((response) => api.get(response.data.LogServices['@odata.id']))
.then((response) => api.get(`${response.data['@odata.id']}/Dump`))
.then((response) => api.get(response.data.Entries['@odata.id']))
@@ -34,9 +32,7 @@
},
async getSystemDumpEntries() {
return api
- .get('/redfish/v1/')
- .then((response) => api.get(response.data.Systems['@odata.id']))
- .then((response) => api.get(`${response.data['@odata.id']}/system`))
+ .get(`${await this.dispatch('global/getSystemPath')}`)
.then((response) => api.get(response.data.LogServices['@odata.id']))
.then((response) => api.get(`${response.data['@odata.id']}/Dump`))
.then((response) => api.get(response.data.Entries['@odata.id']))
@@ -56,7 +52,7 @@
async createBmcDump() {
return await api
.post(
- '/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData',
+ `${await this.dispatch('global/getBmcPath')}/LogServices/Dump/Actions/LogService.CollectDiagnosticData`,
{
DiagnosticDataType: 'Manager',
OEMDiagnosticDataType: '',
@@ -70,7 +66,7 @@
async createSystemDump() {
return await api
.post(
- '/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.CollectDiagnosticData',
+ `${await this.dispatch('global/getSystemPath')}/LogServices/Dump/Actions/LogService.CollectDiagnosticData`,
{
DiagnosticDataType: 'OEM',
OEMDiagnosticDataType: 'System',
@@ -123,7 +119,7 @@
const totalDumpCount = state.allDumps.length;
return await api
.post(
- '/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog',
+ `${await this.dispatch('global/getBmcPath')}/LogServices/Dump/Actions/LogService.ClearLog`,
)
.then(() => {
commit('setAllDumps', []);
diff --git a/src/store/modules/Logs/EventLogStore.js b/src/store/modules/Logs/EventLogStore.js
index f7b2ead..e67da39 100644
--- a/src/store/modules/Logs/EventLogStore.js
+++ b/src/store/modules/Logs/EventLogStore.js
@@ -42,7 +42,9 @@
actions: {
async getEventLogData({ commit }) {
return await api
- .get('/redfish/v1/Systems/system/LogServices/EventLog/Entries')
+ .get(
+ `${await this.dispatch('global/getSystemPath')}/LogServices/EventLog/Entries`,
+ )
.then(({ data: { Members = [] } = {} }) => {
const eventLogs = Members.map((log) => {
const {
@@ -79,7 +81,7 @@
async deleteAllEventLogs({ dispatch }, data) {
return await api
.post(
- '/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.ClearLog',
+ `${await this.dispatch('global/getSystemPath')}/LogServices/EventLog/Actions/LogService.ClearLog`,
)
.then(() => dispatch('getEventLogData'))
.then(() => i18n.tc('pageEventLogs.toast.successDelete', data.length))
diff --git a/src/store/modules/Logs/PostCodeLogsStore.js b/src/store/modules/Logs/PostCodeLogsStore.js
index 7648b13..7bd1410 100644
--- a/src/store/modules/Logs/PostCodeLogsStore.js
+++ b/src/store/modules/Logs/PostCodeLogsStore.js
@@ -16,7 +16,9 @@
actions: {
async getPostCodesLogData({ commit }) {
return await api
- .get('/redfish/v1/Systems/system/LogServices/PostCodes/Entries')
+ .get(
+ `${await this.dispatch('global/getSystemPath')}/LogServices/PostCodes/Entries`,
+ )
.then(({ data: { Members = [] } = {} }) => {
const postCodeLogs = Members.map((log) => {
const { Created, MessageArgs, AdditionalDataURI } = log;
@@ -37,7 +39,7 @@
async deleteAllPostCodeLogs({ dispatch }, data) {
return await api
.post(
- '/redfish/v1/Systems/system/LogServices/PostCodes/Actions/LogService.ClearLog',
+ `${await this.dispatch('global/getSystemPath')}/LogServices/PostCodes/Actions/LogService.ClearLog`,
)
.then(() => dispatch('getPostCodesLogData'))
.then(() =>
diff --git a/src/store/modules/Operations/BootSettingsStore.js b/src/store/modules/Operations/BootSettingsStore.js
index 1f5a628..8959845 100644
--- a/src/store/modules/Operations/BootSettingsStore.js
+++ b/src/store/modules/Operations/BootSettingsStore.js
@@ -32,7 +32,7 @@
actions: {
async getBootSettings({ commit }) {
return await api
- .get('/redfish/v1/Systems/system')
+ .get(`${await this.dispatch('global/getSystemPath')}`)
.then(({ data: { Boot } }) => {
commit(
'setBootSourceOptions',
@@ -43,7 +43,10 @@
})
.catch((error) => console.log(error));
},
- saveBootSettings({ commit, dispatch }, { bootSource, overrideEnabled }) {
+ async saveBootSettings(
+ { commit, dispatch },
+ { bootSource, overrideEnabled },
+ ) {
const data = { Boot: {} };
data.Boot.BootSourceOverrideTarget = bootSource;
@@ -56,7 +59,7 @@
}
return api
- .patch('/redfish/v1/Systems/system', data)
+ .patch(`${await this.dispatch('global/getSystemPath')}`, data)
.then((response) => {
// If request success, commit the values
commit('setBootSource', data.Boot.BootSourceOverrideTarget);
diff --git a/src/store/modules/Operations/ControlStore.js b/src/store/modules/Operations/ControlStore.js
index e76063b..efcdf62 100644
--- a/src/store/modules/Operations/ControlStore.js
+++ b/src/store/modules/Operations/ControlStore.js
@@ -51,7 +51,7 @@
actions: {
async getLastPowerOperationTime({ commit }) {
return await api
- .get('/redfish/v1/Systems/system')
+ .get(`${await this.dispatch('global/getSystemPath')}`)
.then((response) => {
const lastReset = response.data.LastResetTime;
if (lastReset) {
@@ -61,9 +61,9 @@
})
.catch((error) => console.log(error));
},
- getLastBmcRebootTime({ commit }) {
+ async getLastBmcRebootTime({ commit }) {
return api
- .get('/redfish/v1/Managers/bmc')
+ .get(`${await this.dispatch('global/getBmcPath')}`)
.then((response) => {
const lastBmcReset = response.data.LastResetTime;
const lastBmcRebootTime = new Date(lastBmcReset);
@@ -74,7 +74,10 @@
async rebootBmc({ dispatch }) {
const data = { ResetType: 'GracefulRestart' };
return await api
- .post('/redfish/v1/Managers/bmc/Actions/Manager.Reset', data)
+ .post(
+ `${await this.dispatch('global/getBmcPath')}/Actions/Manager.Reset`,
+ data,
+ )
.then(() => dispatch('getLastBmcRebootTime'))
.then(() => i18n.t('pageRebootBmc.toast.successRebootStart'))
.catch((error) => {
@@ -117,10 +120,13 @@
commit('setOperationInProgress', false);
dispatch('getLastPowerOperationTime');
},
- serverPowerChange({ commit }, data) {
+ async serverPowerChange({ commit }, data) {
commit('setOperationInProgress', true);
api
- .post('/redfish/v1/Systems/system/Actions/ComputerSystem.Reset', data)
+ .post(
+ `${await this.dispatch('global/getSystemPath')}/Actions/ComputerSystem.Reset`,
+ data,
+ )
.catch((error) => {
console.log(error);
commit('setOperationInProgress', false);
diff --git a/src/store/modules/Operations/FactoryResetStore.js b/src/store/modules/Operations/FactoryResetStore.js
index 395cae1..84a8f08 100644
--- a/src/store/modules/Operations/FactoryResetStore.js
+++ b/src/store/modules/Operations/FactoryResetStore.js
@@ -6,9 +6,12 @@
actions: {
async resetToDefaults() {
return await api
- .post('/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults', {
- ResetType: 'ResetAll',
- })
+ .post(
+ `${await this.dispatch('global/getBmcPath')}/Actions/Manager.ResetToDefaults`,
+ {
+ ResetType: 'ResetAll',
+ },
+ )
.then(() => i18n.t('pageFactoryReset.toast.resetToDefaultsSuccess'))
.catch((error) => {
console.log('Factory Reset: ', error);
@@ -19,7 +22,9 @@
},
async resetBios() {
return await api
- .post('/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios')
+ .post(
+ `${await this.dispatch('global/getSystemPath')}/Bios/Actions/Bios.ResetBios`,
+ )
.then(() => i18n.t('pageFactoryReset.toast.resetBiosSuccess'))
.catch((error) => {
console.log('Factory Reset: ', error);
diff --git a/src/store/modules/Operations/FirmwareStore.js b/src/store/modules/Operations/FirmwareStore.js
index 7dce231..f6f965f 100644
--- a/src/store/modules/Operations/FirmwareStore.js
+++ b/src/store/modules/Operations/FirmwareStore.js
@@ -52,18 +52,18 @@
dispatch('getActiveBmcFirmware');
return await dispatch('getFirmwareInventory');
},
- getActiveBmcFirmware({ commit }) {
+ async getActiveBmcFirmware({ commit }) {
return api
- .get('/redfish/v1/Managers/bmc')
+ .get(`${await this.dispatch('global/getBmcPath')}`)
.then(({ data: { Links } }) => {
const id = Links?.ActiveSoftwareImage['@odata.id'].split('/').pop();
commit('setActiveBmcFirmwareId', id);
})
.catch((error) => console.log(error));
},
- getActiveHostFirmware({ commit }) {
+ async getActiveHostFirmware({ commit }) {
return api
- .get('/redfish/v1/Systems/system/Bios')
+ .get(`${await this.dispatch('global/getSystemPath')}/Bios`)
.then(({ data: { Links } }) => {
const id = Links?.ActiveSoftwareImage['@odata.id'].split('/').pop();
commit('setActiveHostFirmwareId', id);
@@ -159,7 +159,7 @@
},
};
return await api
- .patch('/redfish/v1/Managers/bmc', data)
+ .patch(`${await this.dispatch('global/getBmcPath')}`, data)
.catch((error) => {
console.log(error);
throw new Error(i18n.t('pageFirmware.toast.errorSwitchImages'));
diff --git a/src/store/modules/Operations/KeyClearStore.js b/src/store/modules/Operations/KeyClearStore.js
index 78804e7..9e5e875 100644
--- a/src/store/modules/Operations/KeyClearStore.js
+++ b/src/store/modules/Operations/KeyClearStore.js
@@ -10,7 +10,7 @@
};
return await api
.patch(
- '/redfish/v1/Systems/system/Bios/Settings',
+ `${await this.dispatch('global/getSystemPath')}/Bios/Settings`,
selectedKeyForClearing,
)
.then(() => i18n.t('pageKeyClear.toast.selectedKeyClearedSuccess'))
diff --git a/src/store/modules/Operations/VirtualMediaStore.js b/src/store/modules/Operations/VirtualMediaStore.js
index 1d27e21..9688d9c 100644
--- a/src/store/modules/Operations/VirtualMediaStore.js
+++ b/src/store/modules/Operations/VirtualMediaStore.js
@@ -49,7 +49,7 @@
}
return await api
- .get('/redfish/v1/Managers/bmc/VirtualMedia')
+ .get(`${await this.dispatch('global/getBmcPath')}/VirtualMedia`)
.then((response) =>
response.data.Members.map(
(virtualMedia) => virtualMedia['@odata.id'],
@@ -95,7 +95,7 @@
async mountImage(_, { id, data }) {
return await api
.post(
- `/redfish/v1/Managers/bmc/VirtualMedia/${id}/Actions/VirtualMedia.InsertMedia`,
+ `${await this.dispatch('global/getBmcPath')}/VirtualMedia/${id}/Actions/VirtualMedia.InsertMedia`,
data,
)
.catch((error) => {
@@ -106,7 +106,7 @@
async unmountImage(_, id) {
return await api
.post(
- `/redfish/v1/Managers/bmc/VirtualMedia/${id}/Actions/VirtualMedia.EjectMedia`,
+ `${await this.dispatch('global/getBmcPath')}/VirtualMedia/${id}/Actions/VirtualMedia.EjectMedia`,
)
.catch((error) => {
console.log('Unmount image:', error);
diff --git a/src/store/modules/SecurityAndAccess/CertificatesStore.js b/src/store/modules/SecurityAndAccess/CertificatesStore.js
index 666f5fd..5c7c36d 100644
--- a/src/store/modules/SecurityAndAccess/CertificatesStore.js
+++ b/src/store/modules/SecurityAndAccess/CertificatesStore.js
@@ -1,29 +1,8 @@
import api from '@/store/api';
import i18n from '@/i18n';
-export const CERTIFICATE_TYPES = [
- {
- type: 'HTTPS Certificate',
- location: '/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/',
- label: i18n.t('pageCertificates.httpsCertificate'),
- },
- {
- type: 'LDAP Certificate',
- location: '/redfish/v1/AccountService/LDAP/Certificates/',
- label: i18n.t('pageCertificates.ldapCertificate'),
- },
- {
- type: 'TrustStore Certificate',
- location: '/redfish/v1/Managers/bmc/Truststore/Certificates/',
- // Web UI will show 'CA Certificate' instead of
- // 'TrustStore Certificate' after user testing revealed
- // the term 'TrustStore Certificate' wasn't recognized/was unfamilar
- label: i18n.t('pageCertificates.caCertificate'),
- },
-];
-
-const getCertificateProp = (type, prop) => {
- const certificate = CERTIFICATE_TYPES.find(
+const getCertificateProp = (certificateTypes, type, prop) => {
+ const certificate = certificateTypes.find(
(certificate) => certificate.type === type,
);
return certificate ? certificate[prop] : null;
@@ -34,10 +13,12 @@
state: {
allCertificates: [],
availableUploadTypes: [],
+ certificateTypes: [],
},
getters: {
allCertificates: (state) => state.allCertificates,
availableUploadTypes: (state) => state.availableUploadTypes,
+ certificateTypes: (state) => state.certificateTypes,
},
mutations: {
setCertificates(state, certificates) {
@@ -46,9 +27,40 @@
setAvailableUploadTypes(state, availableUploadTypes) {
state.availableUploadTypes = availableUploadTypes;
},
+ setCertificateTypes(state, certificateTypes) {
+ state.certificateTypes = certificateTypes;
+ },
},
actions: {
- async getCertificates({ commit }) {
+ async getCertificateTypes({ commit }) {
+ const certificateTypes = [
+ {
+ type: 'HTTPS Certificate',
+ location: `${await this.dispatch(
+ 'global/getBmcPath',
+ )}/NetworkProtocol/HTTPS/Certificates/`,
+ label: i18n.t('pageCertificates.httpsCertificate'),
+ },
+ {
+ type: 'LDAP Certificate',
+ location: '/redfish/v1/AccountService/LDAP/Certificates/',
+ label: i18n.t('pageCertificates.ldapCertificate'),
+ },
+ {
+ type: 'TrustStore Certificate',
+ location: `${await this.dispatch(
+ 'global/getBmcPath',
+ )}/Truststore/Certificates/`,
+ // Web UI will show 'CA Certificate' instead of
+ // 'TrustStore Certificate' after user testing revealed
+ // the term 'TrustStore Certificate' wasn't recognized/was unfamilar
+ label: i18n.t('pageCertificates.caCertificate'),
+ },
+ ];
+ await commit('setCertificateTypes', certificateTypes);
+ },
+ async getCertificates({ dispatch, getters, commit }) {
+ await dispatch('getCertificateTypes');
return await api
.get('/redfish/v1/CertificateService/CertificateLocations')
.then(
@@ -75,14 +87,18 @@
return {
type: Name,
location: data['@odata.id'],
- certificate: getCertificateProp(Name, 'label'),
+ certificate: getCertificateProp(
+ getters['certificateTypes'],
+ Name,
+ 'label',
+ ),
issuedBy: Issuer.CommonName,
issuedTo: Subject.CommonName,
validFrom: new Date(ValidNotBefore),
validUntil: new Date(ValidNotAfter),
};
});
- const availableUploadTypes = CERTIFICATE_TYPES.filter(
+ const availableUploadTypes = getters['certificateTypes'].filter(
({ type }) =>
!certificates
.map((certificate) => certificate.type)
@@ -95,15 +111,23 @@
);
});
},
- async addNewCertificate({ dispatch }, { file, type }) {
+ async addNewCertificate({ dispatch, getters }, { file, type }) {
return await api
- .post(getCertificateProp(type, 'location'), file, {
- headers: { 'Content-Type': 'application/x-pem-file' },
- })
+ .post(
+ getCertificateProp(getters['certificateTypes'], type, 'location'),
+ file,
+ {
+ headers: { 'Content-Type': 'application/x-pem-file' },
+ },
+ )
.then(() => dispatch('getCertificates'))
.then(() =>
i18n.t('pageCertificates.toast.successAddCertificate', {
- certificate: getCertificateProp(type, 'label'),
+ certificate: getCertificateProp(
+ getters['certificateTypes'],
+ type,
+ 'label',
+ ),
}),
)
.catch((error) => {
@@ -112,7 +136,7 @@
});
},
async replaceCertificate(
- { dispatch },
+ { dispatch, getters },
{ certificateString, location, type },
) {
const data = {};
@@ -128,7 +152,11 @@
.then(() => dispatch('getCertificates'))
.then(() =>
i18n.t('pageCertificates.toast.successReplaceCertificate', {
- certificate: getCertificateProp(type, 'label'),
+ certificate: getCertificateProp(
+ getters['certificateTypes'],
+ type,
+ 'label',
+ ),
}),
)
.catch((error) => {
@@ -138,13 +166,17 @@
);
});
},
- async deleteCertificate({ dispatch }, { type, location }) {
+ async deleteCertificate({ dispatch, getters }, { type, location }) {
return await api
.delete(location)
.then(() => dispatch('getCertificates'))
.then(() =>
i18n.t('pageCertificates.toast.successDeleteCertificate', {
- certificate: getCertificateProp(type, 'label'),
+ certificate: getCertificateProp(
+ getters['certificateTypes'],
+ type,
+ 'label',
+ ),
}),
)
.catch((error) => {
@@ -154,7 +186,7 @@
);
});
},
- async generateCsr(_, userData) {
+ async generateCsr({ getters }, userData) {
const {
certificateType,
country,
@@ -173,7 +205,11 @@
const data = {};
data.CertificateCollection = {
- '@odata.id': getCertificateProp(certificateType, 'location'),
+ '@odata.id': getCertificateProp(
+ getters['certificateTypes'],
+ certificateType,
+ 'location',
+ ),
};
data.Country = country;
data.State = state;
diff --git a/src/store/modules/SecurityAndAccess/PoliciesStore.js b/src/store/modules/SecurityAndAccess/PoliciesStore.js
index e6bcfb9..f1e98b2 100644
--- a/src/store/modules/SecurityAndAccess/PoliciesStore.js
+++ b/src/store/modules/SecurityAndAccess/PoliciesStore.js
@@ -31,7 +31,7 @@
actions: {
async getNetworkProtocolStatus({ commit }) {
return await api
- .get('/redfish/v1/Managers/bmc/NetworkProtocol')
+ .get(`${await this.dispatch('global/getBmcPath')}/NetworkProtocol`)
.then((response) => {
const sshProtocol = response.data.SSH.ProtocolEnabled;
const ipmiProtocol = response.data.IPMI.ProtocolEnabled;
@@ -42,7 +42,7 @@
},
async getBiosStatus({ commit }) {
return await api
- .get('/redfish/v1/Systems/system/Bios')
+ .get(`${await this.dispatch('global/getSystemPath')}/Bios`)
.then((response) => {
commit('setRtadEnabled', response.data.Attributes.pvm_rtad);
commit('setVtpmEnabled', response.data.Attributes.pvm_vtpm);
@@ -66,7 +66,10 @@
},
};
return await api
- .patch('/redfish/v1/Managers/bmc/NetworkProtocol', ipmi)
+ .patch(
+ `${await this.dispatch('global/getBmcPath')}/NetworkProtocol`,
+ ipmi,
+ )
.then(() => {
if (protocolEnabled) {
return i18n.t('pagePolicies.toast.successIpmiEnabled');
@@ -92,7 +95,10 @@
},
};
return await api
- .patch('/redfish/v1/Managers/bmc/NetworkProtocol', ssh)
+ .patch(
+ `${await this.dispatch('global/getBmcPath')}/NetworkProtocol`,
+ ssh,
+ )
.then(() => {
if (protocolEnabled) {
return i18n.t('pagePolicies.toast.successSshEnabled');
@@ -113,7 +119,7 @@
async saveRtadState({ commit }, updatedRtad) {
commit('setRtadEnabled', updatedRtad);
return await api
- .patch('/redfish/v1/Systems/system/Bios/Settings', {
+ .patch(`${await this.dispatch('global/getSystemPath')}/Bios/Settings`, {
Attributes: {
pvm_rtad: updatedRtad,
},
@@ -137,7 +143,7 @@
async saveVtpmState({ commit }, updatedVtpm) {
commit('setVtpmEnabled', updatedVtpm);
return await api
- .patch('/redfish/v1/Systems/system/Bios/Settings', {
+ .patch(`${await this.dispatch('global/getSystemPath')}/Bios/Settings`, {
Attributes: {
pvm_vtpm: updatedVtpm,
},
diff --git a/src/store/modules/Settings/DateTimeStore.js b/src/store/modules/Settings/DateTimeStore.js
index 51b722a..9d804a7 100644
--- a/src/store/modules/Settings/DateTimeStore.js
+++ b/src/store/modules/Settings/DateTimeStore.js
@@ -19,7 +19,7 @@
actions: {
async getNtpData({ commit }) {
return await api
- .get('/redfish/v1/Managers/bmc/NetworkProtocol')
+ .get(`${await this.dispatch('global/getBmcPath')}/NetworkProtocol`)
.then((response) => {
const ntpServers = response.data.NTP.NTPServers;
const isNtpProtocolEnabled = response.data.NTP.ProtocolEnabled;
@@ -40,7 +40,10 @@
ntpData.NTP.NTPServers = dateTimeForm.ntpServersArray;
}
return await api
- .patch(`/redfish/v1/Managers/bmc/NetworkProtocol`, ntpData)
+ .patch(
+ `${await this.dispatch('global/getBmcPath')}/NetworkProtocol`,
+ ntpData,
+ )
.then(async () => {
if (!dateTimeForm.ntpProtocolEnabled) {
const dateTimeData = {
@@ -58,9 +61,12 @@
*/
const timeoutVal = state.isNtpProtocolEnabled ? 20000 : 0;
return await new Promise((resolve, reject) => {
- setTimeout(() => {
+ setTimeout(async () => {
return api
- .patch(`/redfish/v1/Managers/bmc`, dateTimeData)
+ .patch(
+ `${await this.dispatch('global/getBmcPath')}`,
+ dateTimeData,
+ )
.then(() => resolve())
.catch(() => reject());
}, timeoutVal);
diff --git a/src/store/modules/Settings/NetworkStore.js b/src/store/modules/Settings/NetworkStore.js
index 9b01603..7f24e19 100644
--- a/src/store/modules/Settings/NetworkStore.js
+++ b/src/store/modules/Settings/NetworkStore.js
@@ -60,7 +60,7 @@
actions: {
async getEthernetData({ commit }) {
return await api
- .get('/redfish/v1/Managers/bmc/EthernetInterfaces')
+ .get(`${await this.dispatch('global/getBmcPath')}/EthernetInterfaces`)
.then((response) =>
response.data.Members.map(
(ethernetInterface) => ethernetInterface['@odata.id'],
@@ -96,7 +96,7 @@
};
return api
.patch(
- `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ `${await this.dispatch('global/getBmcPath')}/EthernetInterfaces/${state.selectedInterfaceId}`,
data,
)
.then(dispatch('getEthernetData'))
@@ -125,7 +125,7 @@
// on all interfaces
return api
.patch(
- `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.firstInterfaceId}`,
+ `${await this.dispatch('global/getBmcPath')}/EthernetInterfaces/${state.firstInterfaceId}`,
data,
)
.then(() => {
@@ -154,7 +154,7 @@
// on all interfaces
return api
.patch(
- `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.firstInterfaceId}`,
+ `${await this.dispatch('global/getBmcPath')}/EthernetInterfaces/${state.firstInterfaceId}`,
data,
)
.then(() => {
@@ -183,7 +183,7 @@
// on all interfaces
return api
.patch(
- `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.firstInterfaceId}`,
+ `${await this.dispatch('global/getBmcPath')}/EthernetInterfaces/${state.firstInterfaceId}`,
data,
)
.then(() => {
@@ -221,7 +221,7 @@
const newAddress = [ipv4Form];
return api
.patch(
- `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ `${await this.dispatch('global/getBmcPath')}/EthernetInterfaces/${state.selectedInterfaceId}`,
{ IPv4StaticAddresses: originalAddresses.concat(newAddress) },
)
.then(dispatch('getEthernetData'))
@@ -242,7 +242,7 @@
async editIpv4Address({ dispatch, state }, ipv4TableData) {
return api
.patch(
- `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ `${await this.dispatch('global/getBmcPath')}/EthernetInterfaces/${state.selectedInterfaceId}`,
{ IPv4StaticAddresses: ipv4TableData },
)
.then(dispatch('getEthernetData'))
@@ -263,7 +263,7 @@
async saveSettings({ state, dispatch }, interfaceSettingsForm) {
return api
.patch(
- `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ `${await this.dispatch('global/getBmcPath')}/EthernetInterfaces/${state.selectedInterfaceId}`,
interfaceSettingsForm,
)
.then(dispatch('getEthernetData'))
@@ -288,7 +288,7 @@
const newDnsArray = originalAddresses.concat(newAddress);
return api
.patch(
- `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ `${await this.dispatch('global/getBmcPath')}/EthernetInterfaces/${state.selectedInterfaceId}`,
{ StaticNameServers: newDnsArray },
)
.then(dispatch('getEthernetData'))
@@ -309,7 +309,7 @@
async editDnsAddress({ dispatch, state }, dnsTableData) {
return api
.patch(
- `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ `${await this.dispatch('global/getBmcPath')}/EthernetInterfaces/${state.selectedInterfaceId}`,
{ StaticNameServers: dnsTableData },
)
.then(dispatch('getEthernetData'))
diff --git a/src/store/modules/Settings/PowerPolicyStore.js b/src/store/modules/Settings/PowerPolicyStore.js
index 3adaec8..fc65381 100644
--- a/src/store/modules/Settings/PowerPolicyStore.js
+++ b/src/store/modules/Settings/PowerPolicyStore.js
@@ -44,7 +44,7 @@
},
async getPowerRestoreCurrentPolicy({ commit }) {
return await api
- .get('/redfish/v1/Systems/system')
+ .get(`${await this.dispatch('global/getSystemPath')}`)
.then(({ data: { PowerRestorePolicy } }) => {
commit('setPowerRestoreCurrentPolicy', PowerRestorePolicy);
})
@@ -54,7 +54,7 @@
const data = { PowerRestorePolicy: powerPolicy };
return await api
- .patch('/redfish/v1/Systems/system', data)
+ .patch(`${await this.dispatch('global/getSystemPath')}`, data)
.then(() => {
dispatch('getPowerRestoreCurrentPolicy');
return i18n.t('pagePowerRestorePolicy.toast.successSaveSettings');