Jiří Moskovčák has uploaded a new change for review.

Change subject: refactoring: use constants for engine states instead of plain 
strings
......................................................................

refactoring: use constants for engine states instead of plain strings

Change-Id: I27ccb6533676edfc1b5bfbf009d5820853eebab6
Signed-off-by: Jiri Moskovcak <[email protected]>
---
M ovirt_hosted_engine_ha/broker/submonitors/engine_health.py
M ovirt_hosted_engine_ha/lib/Makefile.am
A ovirt_hosted_engine_ha/lib/engine.py
3 files changed, 42 insertions(+), 4 deletions(-)


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

diff --git a/ovirt_hosted_engine_ha/broker/submonitors/engine_health.py 
b/ovirt_hosted_engine_ha/broker/submonitors/engine_health.py
index 7557a50..a7933bc 100644
--- a/ovirt_hosted_engine_ha/broker/submonitors/engine_health.py
+++ b/ovirt_hosted_engine_ha/broker/submonitors/engine_health.py
@@ -27,6 +27,7 @@
 from ovirt_hosted_engine_ha.lib import log_filter
 from ovirt_hosted_engine_ha.lib import util as util
 from ovirt_hosted_engine_ha.lib import vds_client as vdsc
+from ovirt_hosted_engine_ha.lib import engine
 
 
 def register():
@@ -77,7 +78,9 @@
         if vm_status in ('paused', 'waitforlaunch', 'restoringstate'):
             self._log.info("VM status: %s", vm_status,
                            extra=log_filter.lf_args('status', 60))
-            d = {'vm': 'up', 'health': 'bad', 'detail': vm_status,
+            d = {'vm': engine.VMState.UP,
+                 'health': engine.Health.BAD,
+                 'detail': vm_status,
                  'reason': 'bad vm status'}
             self.update_result(json.dumps(d))
             return
@@ -86,7 +89,9 @@
         if vm_status in ('down', 'migration destination'):
             self._log.info("VM not running on this host, status %s", vm_status,
                            extra=log_filter.lf_args('status', 60))
-            d = {'vm': 'down', 'health': 'bad', 'detail': vm_status,
+            d = {'vm': engine.VMState.DOWN,
+                 'health': engine.Health.BAD,
+                 'detail': vm_status,
                  'reason': 'bad vm status'}
             self.update_result(json.dumps(d))
             return
@@ -100,11 +105,15 @@
         if p.returncode == 0:
             self._log.info("VM is up on this host with healthy engine",
                            extra=log_filter.lf_args('status', 60))
-            d = {'vm': 'up', 'health': 'good', 'detail': vm_status}
+            d = {'vm': engine.VMState.UP,
+                 'health': engine.Health.GOOD,
+                 'detail': vm_status}
             self.update_result(json.dumps(d))
         else:
             self._log.warning("bad health status: %s", output[0])
-            d = {'vm': 'up', 'health': 'bad', 'detail': vm_status,
+            d = {'vm': engine.VMState.UP,
+                 'health': engine.Health.BAD,
+                 'detail': vm_status,
                  'reason': 'failed liveliness check'}
             self.update_result(json.dumps(d))
 
diff --git a/ovirt_hosted_engine_ha/lib/Makefile.am 
b/ovirt_hosted_engine_ha/lib/Makefile.am
index 22133a8..49b5c63 100644
--- a/ovirt_hosted_engine_ha/lib/Makefile.am
+++ b/ovirt_hosted_engine_ha/lib/Makefile.am
@@ -33,6 +33,7 @@
        metadata.py \
        util.py \
        vds_client.py \
+       engine.py \
        $(NULL)
 
 SUBDIRS = \
diff --git a/ovirt_hosted_engine_ha/lib/engine.py 
b/ovirt_hosted_engine_ha/lib/engine.py
new file mode 100644
index 0000000..cba520c
--- /dev/null
+++ b/ovirt_hosted_engine_ha/lib/engine.py
@@ -0,0 +1,28 @@
+#
+# ovirt-hosted-engine-ha -- ovirt hosted engine high availability
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+class VMState(object):
+    UP = "up"
+    DOWN = "down"
+
+
+class Health(object):
+    GOOD = "good"
+    BAD = "bad"


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I27ccb6533676edfc1b5bfbf009d5820853eebab6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-ha
Gerrit-Branch: ovirt-hosted-engine-ha-1.1
Gerrit-Owner: Jiří Moskovčák <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to