Move Firmware version call to use Redfish

Updates firmware store to use redfish api for bmc and host firmware
version.

Signed-off-by: Dixsie Wolmers <dixsie@ibm.com>
Change-Id: Ib545d62b5211d141307364c0e45a3462f85e9d90
diff --git a/src/store/modules/Configuration/FirmwareStore.js b/src/store/modules/Configuration/FirmwareStore.js
index 5185a13..b76748f 100644
--- a/src/store/modules/Configuration/FirmwareStore.js
+++ b/src/store/modules/Configuration/FirmwareStore.js
@@ -3,52 +3,37 @@
 const FirmwareStore = {
   namespaced: true,
   state: {
-    firmwareInfo: null,
-    bmcActiveVersion: '--',
-    hostActiveVersion: '--'
+    bmcFirmwareVersion: '--',
+    hostFirmwareVersion: '--'
   },
   getters: {
-    firmwareInfo: state => state.firmwareInfo,
-    bmcActiveVersion: state => state.bmcActiveVersion,
-    hostActiveVersion: state => state.hostActiveVersion
+    bmcFirmwareVersion: state => state.bmcFirmwareVersion,
+    hostFirmwareVersion: state => state.hostFirmwareVersion
   },
   mutations: {
-    setFirmwareInfo: (state, firmwareInfo) =>
-      (state.firmwareInfo = firmwareInfo),
-    setBmcActiveVersion: (state, bmcActiveVersion) =>
-      (state.bmcActiveVersion = bmcActiveVersion),
-    setHostActiveVersion: (state, hostActiveVersion) =>
-      (state.hostActiveVersion = hostActiveVersion)
+    setBmcFirmwareVersion: (state, bmcFirmwareVersion) =>
+      (state.bmcFirmwareVersion = bmcFirmwareVersion),
+    setHostFirmwareVersion: (state, hostFirmwareVersion) =>
+      (state.hostFirmwareVersion = hostFirmwareVersion)
   },
   actions: {
-    getFirmwareInfo({ commit }) {
+    getBmcFirmware({ commit }) {
       api
-        .get('/xyz/openbmc_project/software/enumerate')
+        .get('/redfish/v1/Managers/bmc')
         .then(response => {
-          const firmwareInfo = response.data.data;
-          const functionalImages =
-            firmwareInfo['/xyz/openbmc_project/software/functional'].endpoints;
-          for (let key in firmwareInfo) {
-            /**
-             * If "Functional" activation status is
-             * functional, else it is "activation"
-             * github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Software/Activation.interface.yaml
-             */
-            if (firmwareInfo[key].hasOwnProperty('Version')) {
-              let activationStatus = '';
-              const imageType = firmwareInfo[key].Purpose.split('.').pop();
-              if (functionalImages.includes(key)) {
-                activationStatus = 'Functional';
-              }
-              // Get BMC and Host active Versions
-              if (activationStatus == 'Functional' && imageType == 'BMC') {
-                commit('setBmcActiveVersion', firmwareInfo[key].Version);
-              }
-              if (activationStatus == 'Functional' && imageType == 'Host') {
-                commit('setHostActiveVersion', firmwareInfo[key].Version);
-              }
-            }
-          }
+          const bmcFirmwareVersion = response.data.FirmwareVersion;
+          commit('setBmcFirmwareVersion', bmcFirmwareVersion);
+        })
+        .catch(error => {
+          console.log(error);
+        });
+    },
+    getHostFirmware({ commit }) {
+      api
+        .get('/redfish/v1/Systems/system')
+        .then(response => {
+          const hostFirmwareVersion = response.data.BiosVersion;
+          commit('setHostFirmwareVersion', hostFirmwareVersion);
         })
         .catch(error => {
           console.log(error);
diff --git a/src/views/Overview/Overview.vue b/src/views/Overview/Overview.vue
index 5d2ede5..76a062c 100644
--- a/src/views/Overview/Overview.vue
+++ b/src/views/Overview/Overview.vue
@@ -11,7 +11,7 @@
             <b-col>
               <dl>
                 <dt>{{ $t('pageOverview.firmwareVersion') }}</dt>
-                <dd>{{ bmcActiveVersion }}</dd>
+                <dd>{{ bmcFirmwareVersion }}</dd>
               </dl>
             </b-col>
           </b-row>
@@ -50,7 +50,7 @@
             <b-col sm="6">
               <dl>
                 <dt>{{ $t('pageOverview.firmwareVersion') }}</dt>
-                <dd>{{ hostActiveVersion }}</dd>
+                <dd>{{ hostFirmwareVersion }}</dd>
               </dl>
             </b-col>
           </b-row>
@@ -103,8 +103,8 @@
     serverManufacturer: state => state.overview.serverManufacturer,
     serverSerialNumber: state => state.overview.serverSerialNumber,
     hostName: state => state.global.hostName,
-    hostActiveVersion: state => state.firmware.hostActiveVersion,
-    bmcActiveVersion: state => state.firmware.bmcActiveVersion,
+    hostFirmwareVersion: state => state.firmware.hostFirmwareVersion,
+    bmcFirmwareVersion: state => state.firmware.bmcFirmwareVersion,
     powerConsumption: state => state.powerConsumption.powerConsumption,
     powerCapValue: state => state.powerCap.powerCapValue
   }),
@@ -115,7 +115,8 @@
     getOverviewInfo() {
       this.$store.dispatch('overview/getServerInfo');
       this.$store.dispatch('global/getHostName');
-      this.$store.dispatch('firmware/getFirmwareInfo');
+      this.$store.dispatch('firmware/getBmcFirmware');
+      this.$store.dispatch('firmware/getHostFirmware');
       this.$store.dispatch('powerConsumption/getPowerData');
       this.$store.dispatch('powerCap/getPowerCapData');
     }