Skip to content

Commit

Permalink
Improve lago ovirt status
Browse files Browse the repository at this point in the history
1. Format the output with format plugins.
2. Adding url to the web ui.
3. Adding engine's web ui username and password.
4. Auto detect all the items from api.system_service.summary (hosts,
   vms, sds, users)

Signed-off-by: gbenhaim <[email protected]>
  • Loading branch information
gbenhaim committed Apr 27, 2017
1 parent c5687ae commit 5c86420
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 5c86420

Please sign in to comment.