Sandro Bonazzola has uploaded a new change for review. Change subject: bin: support --vm-status option ......................................................................
bin: support --vm-status option Implemented --vm-status command: it will print to the screen the status of the hosted engine VM and of the hosts where it may run. Change-Id: If552f8aacba1744608bd9e87f5f3fafffa6e931d Signed-off-by: Sandro Bonazzola <[email protected]> --- M src/bin/hosted-engine.in M src/ovirt_hosted_engine_setup/Makefile.am A src/ovirt_hosted_engine_setup/vm_status.py 3 files changed, 69 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/78/17878/1 diff --git a/src/bin/hosted-engine.in b/src/bin/hosted-engine.in index 80ba4ea..fcad933 100644 --- a/src/bin/hosted-engine.in +++ b/src/bin/hosted-engine.in @@ -23,7 +23,7 @@ --vm-poweroff forcefully poweroff the VM on this host --vm-status - VM status according to sanlock + VM status according to HA agent --add-console-password=<password> Create a temporary password for vnc/spice connection --check-liveliness @@ -79,7 +79,7 @@ fi ;; --vm-status) - echo "This option is not yet supported" + python -m ovirt_hosted_engine_setup.vm_status ;; --add-console-password=*) if [ -n "${vmid}" ] ; then diff --git a/src/ovirt_hosted_engine_setup/Makefile.am b/src/ovirt_hosted_engine_setup/Makefile.am index 2bef5b8..980346e 100644 --- a/src/ovirt_hosted_engine_setup/Makefile.am +++ b/src/ovirt_hosted_engine_setup/Makefile.am @@ -42,6 +42,7 @@ domains.py \ util.py \ tasks.py \ + vm_status.py \ $(NULL) nodist_ovirthostedenginelib_PYTHON = \ diff --git a/src/ovirt_hosted_engine_setup/vm_status.py b/src/ovirt_hosted_engine_setup/vm_status.py new file mode 100644 index 0000000..9c5b418 --- /dev/null +++ b/src/ovirt_hosted_engine_setup/vm_status.py @@ -0,0 +1,66 @@ +# +# 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 +# + + +"""Check for hosted engine VM status""" + +import gettext + +from ovirt_hosted_engine_ha.agent import client + + +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-hosted-engine-setup') + + +class VmStatus(object): + + DESCRIPTIONS = { + 'first-update': _('First update'), + 'last-update-local-ts': _('Last update received'), + 'last-update-host-ts': _('Last update generated'), + 'alive': _('Host is alive'), + 'score': _('Score'), + 'engine-status': _('Engine status'), + 'hostname': _('Hostname'), + } + + def __init__(self): + super(VmStatus, self).__init__() + + def print_status(self): + all_host_stats = client.get_host_stats() + for host_id in all_host_stats.keys(): + print _('\n--== Host {host_id} status ==--\n\n') + for key in all_host_stats[host_id].keys(): + print _('{key:35}: {value}').format( + key=( + self.DESCRIPTIONS[key] + if key in self.DESCRIPTIONS + else key + ), + value=all_host_stats[host_id][key], + ) + + +if __name__ == "__main__": + status_checker = VmStatus() + status_checker.print_status() + + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/17878 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If552f8aacba1744608bd9e87f5f3fafffa6e931d 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
