Skip to content

Commit

Permalink
Merge pull request #520 from lago-project/improve_lago_ovirt_status
Browse files Browse the repository at this point in the history
Improve lago ovirt status
  • Loading branch information
ovirt-infra authored Apr 27, 2017
2 parents c5687ae + 5c86420 commit fcf0fcd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lago/plugins/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions ovirtlago/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
28 changes: 22 additions & 6 deletions ovirtlago/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit fcf0fcd

Please sign in to comment.