From 582ac0d472a865294f496ff24f7a49af90bfabfe Mon Sep 17 00:00:00 2001 From: Sivaprabu Ganesan Date: Tue, 25 Jul 2023 15:12:46 +0530 Subject: 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 --- .env.intel | 1 + src/store/modules/HardwareStatus/FanStore.js | 99 ++++++++++++++++++++-------- 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)); + } }, }, }; -- cgit v1.2.3