Change in vdsm[ovirt-3.4]: API: setHaMaintenanceMode command

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


Greg Padgett has uploaded a new change for review.

Change subject: API: setHaMaintenanceMode command
......................................................................

API: setHaMaintenanceMode command

New API for setting hosted engine maintenance mode.  This allows the
engine to send commands to the hosted engine agent in order to ease any
necessary maintenance tasks.  The following modes are supported:

local - allow maintenance of the host by effectively stopping the ha
  agent from performing any vm-related activity.  The engine vm is
  moved to another host in the ha cluster, and the host score is set
  to 0.  It is meant to correspond to vds maintenance operations
  performed by the engine.

global - allow maintenance of the ha system or engine vm.  All hosted
  engine state changes are halted for all nodes in the ha cluster,
  so that user-initiated changes to the vm or hosts are ignored.

This API improves usability for the hosted engine subsystem by enabling
changes in the engine ui that would otherwise require the command-line.

For more information:
http://www.ovirt.org/Features/Self_Hosted_Engine_Maintenance_Flows

Change-Id: Ic08c5edb0e9b8cc11eb70ef6a66301335c42aad3
Bug-Url: https://bugzilla.redhat.com/1053040
Signed-off-by: Greg Padgett <gpadgett at redhat.com>
---
M client/vdsClient.py
M lib/vdsm/define.py
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm_api/vdsmapi-schema.json
5 files changed, 75 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/24091/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index 74361fb..90bceb3 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1444,6 +1444,15 @@
             return stats['status']['code'], stats['status']['message']
         return 0, ''
 
+    def do_setHaMaintenanceMode(self, args):
+        mode = args[0]
+        enabled = utils.tobool(args[1])
+        assert len(args) == 2
+        stats = self.s.setHaMaintenanceMode(mode, enabled)
+        if stats['status']['code']:
+            return stats['status']['code'], stats['status']['message']
+        return 0, ''
+
     def do_getVmsInfo(self, args):
         spUUID = args[0]
         if len(args) >= 2:
@@ -2344,6 +2353,11 @@
                                    ('key=python_code [key=python_code] ...',
                                     'set variables for MOM policy fine '
                                     'tuning')),
+        'setHaMaintenanceMode': (serv.do_setHaMaintenanceMode,
+                                 ('<type = global/local>'
+                                  ' <enabled = true/false>',
+                                  'Enable or disable Hosted Engine HA'
+                                  ' maintenance')),
         'deleteImage': (serv.deleteImage,
                         ('<sdUUID> <spUUID> <imgUUID> [<postZero>] [<force>]',
                          'Delete Image folder with all volumes.',
diff --git a/lib/vdsm/define.py b/lib/vdsm/define.py
index 5cd9b99..abf6437 100644
--- a/lib/vdsm/define.py
+++ b/lib/vdsm/define.py
@@ -135,6 +135,9 @@
     'setNumberOfCpusErr': {'status': {
         'code': 60,
         'message': 'Failed to set the number of cpus'}},
+    'haErr': {'status': {
+        'code': 61,
+        'message': 'Failed to set Hosted Engine HA policy'}},
     'recovery': {'status': {
         'code': 99,
         'message': 'Recovering from crash or Initializing'}},
diff --git a/vdsm/API.py b/vdsm/API.py
index ae1ec79..9fd4294 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1487,6 +1487,30 @@
         except:
             return errCode['momErr']
 
+    def setHaMaintenanceMode(self, mode, enabled):
+        """
+        Sets Hosted Engine HA maintenance mode ('global' or 'local') to
+        enabled (True) or disabled (False).
+        """
+        if not haClient:
+            return errCode['unavail']
+
+        self.log.info("Setting Hosted Engine HA {0} maintenance to {1}"
+            .format(mode.lower(), enabled))
+        if mode.lower() == 'global':
+            mm = haClient.HAClient.MaintenanceMode.GLOBAL
+        elif mode.lower() == 'local':
+            mm = haClient.HAClient.MaintenanceMode.LOCAL
+        else:
+            return errCode['haErr']
+
+        try:
+            haClient.HAClient().set_maintenance_mode(mm, enabled)
+        except:
+            self.log.exception("error setting HA maintenance mode")
+            return errCode['haErr']
+        return {'status': doneCode}
+
     # take a rough estimate on how much free mem is available for new vm
     # memTotal = memFree + memCached + mem_used_by_non_qemu + resident  .
     # simply returning (memFree + memCached) is not good enough, as the
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index d0987e5..54cae06 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -427,6 +427,10 @@
         api = API.Global()
         return api.setMOMPolicyParameters(key_value_store)
 
+    def setHaMaintenanceMode(self, mode, enabled):
+        api = API.Global()
+        return api.setHaMaintenanceMode(mode, enabled)
+
     def domainActivate(self, sdUUID, spUUID, options=None):
         domain = API.StorageDomain(sdUUID)
         return domain.activate(spUUID)
@@ -846,6 +850,7 @@
                 (self.setLogLevel, 'setLogLevel'),
                 (self.setMOMPolicy, 'setMOMPolicy'),
                 (self.setMOMPolicyParameters, 'setMOMPolicyParameters'),
+                (self.setHaMaintenanceMode, 'setHaMaintenanceMode'),
                 (self.vmHotplugDisk, 'hotplugDisk'),
                 (self.vmHotunplugDisk, 'hotunplugDisk'),
                 (self.vmHotplugNic, 'hotplugNic'),
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 12f0c98..cd7dd36 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -460,6 +460,35 @@
  'data': {'key_value_store': 'dict'}}
 
 ##
+# @HaMaintenanceMode:
+#
+# An enumeration of recognized Hosted Engine maintenance modes.
+#
+# @GLOBAL:  Suspend Hosted Engine agent actions on all hosts
+#
+# @LOCAL:   Suspend Hosted Engine agent on this host, after migrating
+#           engine VM, if necessary.
+#
+# Since: 4.14.0
+##
+{'enum': 'HaMaintenanceMode',
+ 'data': ['GLOBAL', 'LOCAL']}
+
+##
+# @Host.setHaMaintenanceMode:
+#
+# Configure maintenance for Hosted Engine subsystem.
+#
+# @mode:     Type of maintenance to configure
+#
+# @enabled:  Whether to enable or disable maintenance
+#
+# Since: 4.14.0
+##
+{'command': {'class': 'Host', 'name': 'setHaMaintenanceMode'},
+ 'data': {'mode': 'HaMaintenanceMode', 'enabled': 'bool'}}
+
+##
 # @TaskDetails:
 #
 # A collection of information about a task.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic08c5edb0e9b8cc11eb70ef6a66301335c42aad3
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