Remove hardcoded chassis in power supplies
According to our conversation on community meeting we want to remove all hardcoded chassis names in request URL. This change corrects the "Power supplies" table in "Hardware Status" view.
Signed-off-by: MichalX Szopinski <michalx.szopinski@intel.com>
Change-Id: I5219c68b71477adee5f6785c58808eeaa5d35986
diff --git a/src/store/modules/Health/PowerSupplyStore.js b/src/store/modules/Health/PowerSupplyStore.js
index 565715f..cc82f2e 100644
--- a/src/store/modules/Health/PowerSupplyStore.js
+++ b/src/store/modules/Health/PowerSupplyStore.js
@@ -38,14 +38,34 @@
},
},
actions: {
- async getPowerSupply({ commit }) {
+ async getChassisCollection() {
return await api
- .get('/redfish/v1/Chassis/chassis/Power')
- .then(({ data: { PowerSupplies } }) =>
- commit('setPowerSupply', PowerSupplies)
+ .get('/redfish/v1/Chassis')
+ .then(({ data: { Members } }) =>
+ Members.map((member) => member['@odata.id'])
)
.catch((error) => console.log(error));
},
+ async getAllPowerSupplies({ dispatch, commit }) {
+ const collection = await dispatch('getChassisCollection');
+ if (!collection) return;
+ return await api
+ .all(collection.map((chassis) => dispatch('getChassisPower', chassis)))
+ .then((supplies) => {
+ let suppliesList = [];
+ supplies.forEach(
+ (supply) => (suppliesList = [...suppliesList, ...supply])
+ );
+ commit('setPowerSupply', suppliesList);
+ })
+ .catch((error) => console.log(error));
+ },
+ async getChassisPower(_, id) {
+ return await api
+ .get(`${id}/Power`)
+ .then(({ data: { PowerSupplies } }) => PowerSupplies || [])
+ .catch((error) => console.log(error));
+ },
},
};
diff --git a/src/views/Health/HardwareStatus/HardwareStatusTablePowerSupplies.vue b/src/views/Health/HardwareStatus/HardwareStatusTablePowerSupplies.vue
index 3de6919..ba1537b 100644
--- a/src/views/Health/HardwareStatus/HardwareStatusTablePowerSupplies.vue
+++ b/src/views/Health/HardwareStatus/HardwareStatusTablePowerSupplies.vue
@@ -165,7 +165,7 @@
},
},
created() {
- this.$store.dispatch('powerSupply/getPowerSupply').finally(() => {
+ this.$store.dispatch('powerSupply/getAllPowerSupplies').finally(() => {
// Emit initial data fetch complete to parent component
this.$root.$emit('hardware-status-power-supplies-complete');
});