Sandro Bonazzola has uploaded a new change for review. Change subject: bin: add --set-maintenance to hosted-engine ......................................................................
bin: add --set-maintenance to hosted-engine Add support for --set-maintenance=local|global|none to hosted-engine command. Change-Id: If2e07a4ac57268a18523a3119d60b10021f36cfa Bug-Url: https://bugzilla.redhat.com/1020858 Signed-off-by: Sandro Bonazzola <[email protected]> --- M man/hosted-engine.8 M src/bin/hosted-engine.in M src/ovirt_hosted_engine_setup/Makefile.am A src/ovirt_hosted_engine_setup/set_maintenance.py 4 files changed, 88 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/60/20460/1 diff --git a/man/hosted-engine.8 b/man/hosted-engine.8 index bcba5f4..34b86fc 100644 --- a/man/hosted-engine.8 +++ b/man/hosted-engine.8 @@ -1,5 +1,5 @@ .\" hosted-engine - Tool for handling hosted engine -.TH "HOSTED-ENGINE" "8" "2013-09-06" "oVirt" "oVirt Hosted Engine Setup Manual" +.TH "HOSTED-ENGINE" "8" "2013-10-23" "oVirt" "oVirt Hosted Engine Setup Manual" .SH "NAME" hosted\-engine \- Tools for handling hosted engine .SH "SYNOPSIS" @@ -41,6 +41,7 @@ Manually connect the storage domain to the local VDSM instance.\& .IP "\fB\-\-start-pool\fP" Start the storage pool manually.\& - +.IP "\fB\-\-set-maintenance=mode\fP" +Set maintenance status to the specified mode (global/local/none).\& .SH "SEE ALSO" .BR ovirt\-hosted\-engine\-setup (8) diff --git a/src/bin/hosted-engine.in b/src/bin/hosted-engine.in index 8d93a34..1f496af 100644 --- a/src/bin/hosted-engine.in +++ b/src/bin/hosted-engine.in @@ -34,6 +34,8 @@ Start the storage pool manually --console Open the configured console using remote-viewer on localhost + --set-maintenance=mode + Set maintenance status to the specified mode (global/local/none) __EOF__ exit $rc @@ -150,6 +152,12 @@ --spice-host-subject="${ca_subject}" fi ;; + --set-maintenance=*) + if [ -r "${conf}" ] ; then + python -m ovirt_hosted_engine_setup.set_maintenance "${v}" + else + echo "You must run --deploy first" + fi --help) rc=0 usage diff --git a/src/ovirt_hosted_engine_setup/Makefile.am b/src/ovirt_hosted_engine_setup/Makefile.am index ee28411..f7925a9 100644 --- a/src/ovirt_hosted_engine_setup/Makefile.am +++ b/src/ovirt_hosted_engine_setup/Makefile.am @@ -41,6 +41,7 @@ constants.py \ domains.py \ util.py \ + set_maintenance.py \ tasks.py \ vm_status.py \ $(NULL) diff --git a/src/ovirt_hosted_engine_setup/set_maintenance.py b/src/ovirt_hosted_engine_setup/set_maintenance.py new file mode 100644 index 0000000..96ca277 --- /dev/null +++ b/src/ovirt_hosted_engine_setup/set_maintenance.py @@ -0,0 +1,76 @@ +# +# ovirt-hosted-engine-setup -- ovirt hosted engine setup +# 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 +# + + +"""Set maintenance mode for hosted engine VM""" + + +import gettext +import socket +import sys + + +from ovirt_hosted_engine_ha.client import client + + +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-hosted-engine-setup') + + +class Maintenance(object): + + def __init__(self): + super(Maintenance, self).__init__() + + def set_mode(self, mode): + ha_cli = client.HAClient() + if mode not in ( + 'local', + 'global', + 'none', + ): + sys.stderr.write( + _('Invalid maintenance mode: {0}\n').format(mode) + ) + return False + m_local = (mode == 'local') + m_global = (mode == 'global') + try: + ha_cli.set_maintenance_mode( + mode=ha_cli.MaintenanceMode.LOCAL, + value=m_local, + ) + ha_cli.set_maintenance_mode( + mode=ha_cli.MaintenanceMode.GLOBAL, + value=m_global, + ) + except socket.error: + sys.stderr.write( + _('Cannot connect to the HA daemon, please check the logs.\n') + ) + return False + return True + + +if __name__ == "__main__": + maintenance = Maintenance() + if not maintenance.set_mode(sys.argv[1]): + sys.exit(1) + + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/20460 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If2e07a4ac57268a18523a3119d60b10021f36cfa Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-setup Gerrit-Branch: master Gerrit-Owner: Sandro Bonazzola <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
