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/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);