diff --git a/lago/plugins/output.py b/lago/plugins/output.py index f094a0a0..96aa24f0 100644 --- a/lago/plugins/output.py +++ b/lago/plugins/output.py @@ -150,6 +150,6 @@ def dfs(father, path, acc): acc.append(delimiter.join(path)) result = [] - dfs(info_dict['Prefix'], [], result) + dfs(info_dict.get('Prefix') or info_dict, [], result) return '\n'.join(result) diff --git a/ovirtlago/cmd.py b/ovirtlago/cmd.py index 0677139c..93ab925c 100755 --- a/ovirtlago/cmd.py +++ b/ovirtlago/cmd.py @@ -217,8 +217,8 @@ def do_ovirt_start_vms(prefix, vms_timeout, **kwargs): @cli_plugin(help='Print oVirt setup status') @in_ovirt_prefix @with_logging -def do_ovirt_status(prefix, **kwargs): - prefix.virt_env.engine_vm().status() +def do_ovirt_status(prefix, out_format, **kwargs): + print(out_format.format(prefix.virt_env.engine_vm().status())) @cli_plugin( diff --git a/ovirtlago/virt.py b/ovirtlago/virt.py index 65005ad1..a1bdf298 100644 --- a/ovirtlago/virt.py +++ b/ovirtlago/virt.py @@ -24,6 +24,7 @@ import lago.vm import logging import yaml +from collections import OrderedDict from lago.config import config as lago_config from ovirtlago import utils from utils import partial @@ -461,13 +462,28 @@ def _sds_state(dc_id): @require_sdk(version='4') def status(self): api = self.get_api_v4(check=True) - sys_service = api.system_service().get() - print("Version: %s" % sys_service.product_info.version.full_version) - print("Hosts: %d" % sys_service.summary.hosts.total) - print("SDs: %d" % sys_service.summary.storage_domains.total) - print("Users: %d" % sys_service.summary.users.total) - print("Vms: %d" % sys_service.summary.vms.total) + info = {'global': {}, 'items': {}} + + info['global']['version' + ] = sys_service.product_info.version.full_version + info['global']['web_ui'] = OrderedDict( + [ + ('url', self.ip()), ('username', constants.ENGINE_USER), + ('password', self.metadata['ovirt-engine-password']) + ] + ) + + for k, v in vars(sys_service.summary).viewitems(): + if isinstance(v, otypes.ApiSummaryItem): + info['items'][k.lstrip('_')] = OrderedDict( + [ + ('total', v.total), + ('active', v.active), + ] + ) + + return info class HostVM(lago.vm.DefaultVM):