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. Change-Id: Ic08c5edb0e9b8cc11eb70ef6a66301335c42aad3 Bug-Url: https://bugzilla.redhat.com/1053040 Signed-off-by: Greg Padgett <gpadg...@redhat.com> --- M lib/vdsm/define.py M vdsm/API.py M vdsm/BindingXMLRPC.py M vdsm_api/vdsmapi-schema.json 4 files changed, 61 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/64/23264/1 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 bb589c9..b918c27 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -1484,6 +1484,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().setMaintenance(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 cfe13e2..732c4da 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/23264 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic08c5edb0e9b8cc11eb70ef6a66301335c42aad3 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