Greg Padgett has uploaded a new change for review.

Change subject: agent: use vdsm domain monitor
......................................................................

agent: use vdsm domain monitor

Ensure that the storage domain is monitored by VDSM using the
repoStats and startMonitoringDomain APIs.

Change-Id: I9bab369784fecbf972622922a925fd0b45de123f
Requires: http://gerrit.ovirt.org/19762
Bug-Url: https://bugzilla.redhat.com/1017406
Signed-off-by: Greg Padgett <[email protected]>
---
M ovirt_hosted_engine_ha/agent/hosted_engine.py
1 file changed, 40 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-ha 
refs/changes/51/20051/1

diff --git a/ovirt_hosted_engine_ha/agent/hosted_engine.py 
b/ovirt_hosted_engine_ha/agent/hosted_engine.py
index 89304ba..f568803 100644
--- a/ovirt_hosted_engine_ha/agent/hosted_engine.py
+++ b/ovirt_hosted_engine_ha/agent/hosted_engine.py
@@ -32,6 +32,7 @@
 from ..lib import exceptions as ex
 from ..lib import log_filter
 from ..lib import metadata
+from ..lib import util
 from ..lib import vds_client as vdsc
 
 
@@ -226,6 +227,7 @@
                 self._initialize_broker()
                 self._initialize_vdsm()
                 self._initialize_sanlock()
+                self._initialize_domain_monitor()
 
                 self._collect_local_stats()
                 blocks = self._generate_local_blocks()
@@ -396,6 +398,44 @@
             self._log.info("Acquired lock on host id %d", host_id)
         self._sanlock_initialized = True
 
+    def _initialize_domain_monitor(self):
+        use_ssl = util.to_bool(self._config.get(config.ENGINE,
+                                                config.VDSM_SSL))
+        sd_uuid = self._config.get(config.ENGINE, config.SD_UUID)
+        host_id = self._rinfo['host-id']
+
+        try:
+            repo_stats = vdsc.run_vds_client_cmd(
+                '0',
+                use_ssl,
+                'repoStats'
+            )
+        except Exception as e:
+            msg = ("Failed to get vdsm monitored domain stats: {0}"
+                   .format(str(e)))
+            self._log.error(msg, esc_info=True)
+            raise Exception(msg)
+
+        if sd_uuid in repo_stats:
+            self._log.info("VDSM is monitoring domain %s", sd_uuid)
+        else:
+            try:
+                vdsc.run_vds_client_cmd(
+                    '0',
+                    use_ssl,
+                    'startMonitoringDomain',
+                    sd_uuid,
+                    host_id,
+                )
+            except Exception as e:
+                msg = ("Failed to start monitoring domain"
+                       " (sd_uuid={0}, host_id={1}): {2}"
+                       .format(sd_uuid, host_id, str(e)))
+                self._log.error(msg, exc_info=True)
+                raise Exception(msg)
+            else:
+                self._log.info("Started VDSM domain monitor for %s", sd_uuid)
+
     def _collect_local_stats(self):
         """
         Refresh all required submonitors and update local state.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9bab369784fecbf972622922a925fd0b45de123f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-ha
Gerrit-Branch: master
Gerrit-Owner: Greg Padgett <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to