Greg Padgett has uploaded a new change for review.

Change subject: WIP vdsStats: return HA agent score when applicable
......................................................................

WIP vdsStats: return HA agent score when applicable

When the Hosted Engine HA Agent is installed, it can provide information
useful to the engine about the host's suitability to run the engine VM.
Provide this information to the engine through the vdsStats interface.

Change-Id: Ibdad8accb0660dbdcc8b6e1b83f491c2f89c2d30
Bug-Url: https://bugzilla.redhat.com/??????
Signed-off-by: Greg Padgett <gpadg...@redhat.com>
---
M vdsm/API.py
M vdsm_api/vdsmapi-schema.json
2 files changed, 28 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/20126/1

diff --git a/vdsm/API.py b/vdsm/API.py
index 37bb908..8ca5a0b 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -48,6 +48,13 @@
 
 import supervdsm
 
+try:
+    import ovirt_hosted_engine_ha.client.client as ha_client
+    ha_agent = True
+except ImportError:
+    ha_agent = False
+
+
 # default message for system shutdown, will be displayed in guest
 USER_SHUTDOWN_MESSAGE = 'System going down'
 
@@ -1209,6 +1216,11 @@
 
         stats['netConfigDirty'] = str(self._cif._netConfigDirty)
         stats['generationID'] = self._cif._generationID
+
+        haScore = self._getHaScore()
+        if haScore is not False:
+            stats['haScore'] = haScore
+
         return {'status': doneCode, 'info': stats}
 
     def setLogLevel(self, level):
@@ -1493,6 +1505,18 @@
                 self.log.error(vmId + ': Lost connection to VM')
         return count, active, migrating
 
+    def _getHaScore(self):
+        """
+        Return the hosted engine HA score for this host,
+        or False if unavailable.
+        """
+        if ha_agent:
+            try:
+                return ha_client.HAClient().get_local_host_score()
+            except:
+                pass
+        return False
+
     @staticmethod
     def translateNetOptionsToNew(options):
         _translationMap = {
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index aae6c6e..47f7114 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/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
+#
 # 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:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdad8accb0660dbdcc8b6e1b83f491c2f89c2d30
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Greg Padgett <gpadg...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to