Change in vdsm[ovirt-3.4]: API: return additional Hosted Engine information from vdsStats

gpadgett at redhat.com gpadgett at redhat.com
Tue Feb 4 23:57:13 UTC 2014


Greg Padgett has uploaded a new change for review.

Change subject: API: return additional Hosted Engine information from vdsStats
......................................................................

API: return additional Hosted Engine information from vdsStats

Return additional hosted engine runtime information with vds statistics
which allows for better interoperability between the engine and hosted
engine agent.

Change-Id: Iaee2756d0652dc56439b8004e9260fcea927b708
Bug-Url: https://bugzilla.redhat.com/1053040
Signed-off-by: Greg Padgett <gpadgett at redhat.com>
---
M vdsm/API.py
M vdsm_api/vdsmapi-schema.json
2 files changed, 57 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/90/24090/1

diff --git a/vdsm/API.py b/vdsm/API.py
index bb76f20..ae1ec79 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1235,12 +1235,10 @@
 
         stats['netConfigDirty'] = str(self._cif._netConfigDirty)
         stats['generationID'] = self._cif._generationID
-
-        if haClient:
-            try:
-                stats['haScore'] = haClient.HAClient().get_local_host_score()
-            except Exception:
-                self.log.exception("failed to retrieve Hosted Engine HA score")
+        stats['haStats'] = self._getHaInfo()
+        if stats['haStats']['configured']:
+            # For backwards compatibility, will be removed in the future
+            stats['haScore'] = stats['haStats']['score']
 
         return {'status': doneCode, 'info': stats}
 
@@ -1554,6 +1552,36 @@
                 self.log.error(vmId + ': Lost connection to VM')
         return count, active, migrating
 
+    def _getHaInfo(self):
+        """
+        Return Hosted Engine HA information for this host.
+        """
+        i = {
+            'configured': False,
+            'active': False,
+            'score': 0,
+            'globalMaintenance': False,
+            'localMaintenance': False,
+        }
+        if haClient:
+            try:
+                instance = haClient.HAClient()
+                host_id = instance.get_local_host_id()
+                # If a host id is available, consider HA configured
+                i['configured'] = True
+
+                stats = instance.get_all_stats()
+                if 0 in stats:
+                    i['globalMaintenance'] = stats[0].get(
+                        haClient.HAClient.GlobalMdFlags.MAINTENANCE, False)
+                if host_id in stats:
+                    i['active'] = stats[host_id]['live-data']
+                    i['score'] = stats[host_id]['score']
+                    i['localMaintenance'] = stats[host_id]['maintenance']
+            except Exception:
+                self.log.exception("failed to retrieve Hosted Engine HA info")
+        return i
+
     @staticmethod
     def translateNetOptionsToNew(options):
         _translationMap = {
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 564180a..12f0c98 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -1540,6 +1540,24 @@
 ##
 {'enum': 'MOMStatus', 'data': ['disabled', 'active', 'inactive']}
 
+##
+# @HostedEngineStatus:
+#
+# Hosted Engine subsystem status, according to each host.
+#
+# @active:             Indicates if the HA agent is alive and updating data
+#
+# @localMaintenance:   Indicates if host is in local HA maintenance mode
+#
+# @globalMaintenance:  Indicates if cluster is in global maintenance mode
+#
+# @score:              Numeric host score
+#
+# Since: 4.14.0
+##
+{'type': 'HostedEngineStatus',
+ 'data': {'active': 'bool', 'globalMaintenance': 'bool',
+          'localMaintenance': 'bool', 'score': 'uint'}}
 
 ##
 # @HostStats:
@@ -1619,6 +1637,9 @@
 # @haScore:         #optional The host score according to the HA agent,
 #                   if installed (new in version 4.13.0)
 #
+# @haStatus:        The current status of the Hosted Engine HA system
+#                   (new in version 4.14.0)
+#
 # Since: 4.10.0
 ##
 {'type': 'HostStats',
@@ -1636,7 +1657,8 @@
            'vmCount': 'int', 'vmActive': 'int', 'vmMigrating': 'int',
            'dateTime': 'str', 'ksmState': 'bool', 'ksmPages': 'int',
            'ksmCpu': 'float', 'netConfigDirty': 'bool', 'generationID': 'UUID',
-           'momStatus': 'MOMStatus', '*haScore': 'uint'}}
+           'momStatus': 'MOMStatus', '*haScore': 'int',
+           'haStatus': 'HostedEngineStatus'}}
 
 ##
 # @Host.getStats:


-- 
To view, visit http://gerrit.ovirt.org/24090
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaee2756d0652dc56439b8004e9260fcea927b708
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.4
Gerrit-Owner: Greg Padgett <gpadgett at redhat.com>


More information about the vdsm-patches mailing list