summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSivaprabu Ganesan <sivaprabug@ami.com>2023-07-25 12:42:46 +0300
committerGunnar Mills <gmills@us.ibm.com>2023-08-08 00:12:27 +0300
commit582ac0d472a865294f496ff24f7a49af90bfabfe (patch)
treec6157f91e873e9c7235212b2d6e0b53b0c364c7c
parent43e3bd26133b06ed117a3a3f10b2bc09e2c2aafc (diff)
downloadwebui-vue-582ac0d472a865294f496ff24f7a49af90bfabfe.tar.xz
Fan data from Thermal or ThermalSubsystem API
Fan data API switch in Inventory and LEDs page based on environment variable VUE_APP_FAN_DATA_FROM_THERMAL_SUBSYSTEM. Backend Support PR: https://gerrit.openbmc.org/c/openbmc/bmcweb/+/57533 Change-Id: I95ac9f9cef97bdab84a179b3e318eb37ab11752b Signed-off-by: Sivaprabu Ganesan <sivaprabug@ami.com>
-rw-r--r--.env.intel1
-rw-r--r--src/store/modules/HardwareStatus/FanStore.js99
2 files changed, 73 insertions, 27 deletions
diff --git a/.env.intel b/.env.intel
index 6a8c1811..c7dea364 100644
--- a/.env.intel
+++ b/.env.intel
@@ -8,6 +8,7 @@ VUE_APP_MODIFY_SSH_POLICY_DISABLED="true"
VUE_APP_VIRTUAL_MEDIA_LIST_ENABLED="true"
VUE_APP_EVENT_LOGS_DELETE_BUTTON_DISABLED="true"
VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED="true"
+VUE_APP_FAN_DATA_FROM_THERMAL_SUBSYSTEM="true"
CUSTOM_STYLES="true"
CUSTOM_APP_NAV="true"
CUSTOM_STORE="true"
diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js
index 3f172d2d..832ef634 100644
--- a/src/store/modules/HardwareStatus/FanStore.js
+++ b/src/store/modules/HardwareStatus/FanStore.js
@@ -11,29 +11,49 @@ const FanStore = {
mutations: {
setFanInfo: (state, data) => {
state.fans = data.map((fan) => {
- const {
- IndicatorLED,
- Location,
- MemberId,
- Name,
- Reading,
- ReadingUnits,
- Status = {},
- PartNumber,
- SerialNumber,
- } = fan;
- return {
- id: MemberId,
- health: Status.Health,
- partNumber: PartNumber,
- serialNumber: SerialNumber,
- healthRollup: Status.HealthRollup,
- identifyLed: IndicatorLED,
- locationNumber: Location,
- name: Name,
- speed: Reading + ' ' + ReadingUnits,
- statusState: Status.State,
- };
+ const ThermalSubsystem =
+ process.env.VUE_APP_FAN_DATA_FROM_THERMAL_SUBSYSTEM === 'true'
+ ? true
+ : false;
+ if (ThermalSubsystem) {
+ const {
+ Id,
+ Name,
+ PartNumber,
+ SerialNumber,
+ SpeedPercent = {},
+ Status = {},
+ } = fan;
+ return {
+ id: Id,
+ health: Status.Health,
+ name: Name,
+ speed: SpeedPercent.Reading,
+ statusState: Status.State,
+ healthRollup: Status.HealthRollup,
+ partNumber: PartNumber,
+ serialNumber: SerialNumber,
+ };
+ } else {
+ const {
+ MemberId,
+ Name,
+ Reading,
+ Status = {},
+ PartNumber,
+ SerialNumber,
+ } = fan;
+ return {
+ id: MemberId,
+ health: Status.Health,
+ partNumber: PartNumber,
+ serialNumber: SerialNumber,
+ healthRollup: Status.HealthRollup,
+ name: Name,
+ speed: Reading,
+ statusState: Status.State,
+ };
+ }
});
},
},
@@ -59,10 +79,35 @@ const FanStore = {
.catch((error) => console.log(error));
},
async getChassisFans(_, chassis) {
- return await api
- .get(chassis.Thermal['@odata.id'])
- .then(({ data: { Fans } }) => Fans || [])
- .catch((error) => console.log(error));
+ const ThermalSubsystem =
+ process.env.VUE_APP_FAN_DATA_FROM_THERMAL_SUBSYSTEM === 'true'
+ ? true
+ : false;
+ if (ThermalSubsystem) {
+ return await api
+ .get(chassis.ThermalSubsystem['@odata.id'])
+ .then((response) => {
+ return api.get(`${response.data.Fans['@odata.id']}`);
+ })
+ .then(({ data: { Members } }) => {
+ const promises = Members.map((member) =>
+ api.get(member['@odata.id'])
+ );
+ return api.all(promises);
+ })
+ .then((response) => {
+ const data = response.map(({ data }) => data);
+ return data;
+ })
+ .catch((error) => console.log(error));
+ } else {
+ return await api
+ .get(chassis.Thermal['@odata.id'])
+ .then(({ data: { Fans } }) => {
+ return Fans || [];
+ })
+ .catch((error) => console.log(error));
+ }
},
},
};