For Hosted Engine, the engine needs to know the HA score assigned to
each host by the HA agent--if it's installed.  This patch returns the
score via the statistics interface.

Change-Id: Ibdad8accb0660dbdcc8b6e1b83f491c2f89c2d30
Signed-off-by: Greg Padgett <gpadg...@redhat.com>
Signed-off-by: Martin Sivák <msi...@redhat.com>
Label: DOWNSTREAM ONLY
---
 vdsm/API.py                  | 13 +++++++++++++
 vdsm_api/vdsmapi-schema.json |  5 ++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git vdsm/API.py vdsm/API.py
index 37bb908..6cd13ee 100644
--- vdsm/API.py
+++ vdsm/API.py
@@ -48,6 +48,12 @@ import ksm
 
 import supervdsm
 
+haClient = None  # Define here to work around pyflakes issue #13
+try:
+    import ovirt_hosted_engine_ha.client.client as haClient
+except ImportError:
+    pass
+
 # default message for system shutdown, will be displayed in guest
 USER_SHUTDOWN_MESSAGE = 'System going down'
 
@@ -1209,6 +1215,13 @@ class Global(APIBase):
 
         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")
+
         return {'status': doneCode, 'info': stats}
 
     def setLogLevel(self, level):
diff --git vdsm_api/vdsmapi-schema.json vdsm_api/vdsmapi-schema.json
index 60b4bd5..787c608 100644
--- vdsm_api/vdsmapi-schema.json
+++ vdsm_api/vdsmapi-schema.json
@@ -1613,6 +1613,9 @@
 #
 # @momStatus:       The current status of the MOM policy engine
 #
+# @haScore:         #optional The host score according to the HA agent,
+#                   if installed (new in version 4.13.0)
+#
 # Since: 4.10.0
 ##
 {'type': 'HostStats',
@@ -1630,7 +1633,7 @@
            'vmCount': 'int', 'vmActive': 'int', 'vmMigrating': 'int',
            'dateTime': 'str', 'ksmState': 'bool', 'ksmPages': 'int',
            'ksmCpu': 'float', 'netConfigDirty': 'bool', 'generationID':
            'UUID',
-           'momStatus': 'MOMStatus'}}
+           'momStatus': 'MOMStatus', '*haScore': 'uint'}}
 
 ##
 # @Host.getStats:
--
1.8.3.1
_______________________________________________
vdsm-devel mailing list
vdsm-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-devel

Reply via email to