Ravi Nori has uploaded a new change for review. Change subject: cli: 'show vm' not returning all guest attributes ......................................................................
cli: 'show vm' not returning all guest attributes 'show vm <guest name>' does not return all attributes or settings for the given guest. Add code to support All-content header for get operations Change-Id: Ia65d4609a8dac28ff3d894baaf8c97f2881b865e Bug-Url: https://bugzilla.redhat.com/1062434 Signed-off-by: Ravi Nori <[email protected]> --- M src/ovirtcli/command/command.py M src/ovirtcli/shell/showcmdshell.py 2 files changed, 38 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/09/24209/1 diff --git a/src/ovirtcli/command/command.py b/src/ovirtcli/command/command.py index 9b9b6dc..44817f3 100644 --- a/src/ovirtcli/command/command.py +++ b/src/ovirtcli/command/command.py @@ -319,6 +319,9 @@ """Return an object by id or name.""" self.check_connection() connection = self.context.connection + all_content = None + if opts.has_key("--all_content"): + all_content = opts["--all_content"] name, kwargs = self._get_query_params(opts, query_arg='--name') candidate = typ if typ is not None and isinstance(typ, type('')) \ @@ -345,15 +348,15 @@ coll = getattr(base, candidate + 's') if coll is not None: if name: - return coll.get(name=name) + return self.__get_by_name(coll, name, all_content) if kwargs and kwargs.has_key('id'): - return coll.get(id=str(kwargs['id'])) + return self.__get_by_id(coll, str(kwargs['id']), all_content) else: identifier = self.__produce_identifier(obj_id) if identifier: - return coll.get(id=str(obj_id)) + return self.__get_by_id(coll, str(obj_id), all_content) else: - return coll.get(name=obj_id) + return self.__get_by_name(coll, obj_id, all_content) else: err_str = Messages.Error.NO_SUCH_TYPE_OR_ARS_NOT_VALID if context_variants: @@ -363,6 +366,18 @@ return None + def __get_by_name(self, coll, name, all_content): + if all_content: + return coll.get(name=name, all_content=all_content) + else: + return coll.get(name=name) + + def __get_by_id(self, coll, id, all_content): + if all_content: + return coll.get(id=id, all_content=all_content) + else: + return coll.get(id=id) + def __produce_identifier(self, candidate): if type(candidate) == str: match = re.search(r'[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}', candidate) diff --git a/src/ovirtcli/shell/showcmdshell.py b/src/ovirtcli/shell/showcmdshell.py index c64d3c1..6d7cbca 100644 --- a/src/ovirtcli/shell/showcmdshell.py +++ b/src/ovirtcli/shell/showcmdshell.py @@ -18,6 +18,8 @@ from ovirtcli.shell.cmdshell import CmdShell from ovirtcli.utils.typehelper import TypeHelper from ovirtcli.utils.autocompletionhelper import AutoCompletionHelper +from ovirtsdk.infrastructure import brokers +from ovirtcli.utils.methodhelper import MethodHelper class ShowCmdShell(CmdShell): @@ -32,13 +34,29 @@ def do_show(self, args): return self.context.execute_string(ShowCmdShell.NAME + ' ' + args + '\n') + def __add_resource_specific_options(self, obj, specific_options, line, key=None): + obj_coll_type = TypeHelper.getDecoratorType(TypeHelper.to_plural(obj)) + if obj_coll_type: + if hasattr(brokers, obj_coll_type): + obj_coll = getattr(brokers, obj_coll_type) + if obj_coll and hasattr(obj_coll, ShowCmdShell.ALIAS): + method_args = MethodHelper.get_documented_arguments(method_ref=getattr(obj_coll, ShowCmdShell.ALIAS), + as_params_collection=True, + spilt_or=True) + if method_args: + specific_options[obj if key == None else key] = method_args + def complete_show(self, text, line, begidx, endidx): args = TypeHelper.get_types_by_method(False, ShowCmdShell.ALIAS, expendNestedTypes=True) + specific_options = self.get_resource_specific_options(args, + line, + callback=self.__add_resource_specific_options) return AutoCompletionHelper.complete(line=line, text=text, args=args, - common_options=ShowCmdShell.OPTIONS) + common_options=ShowCmdShell.OPTIONS, + specific_options=specific_options) def is_show_argument(self, line, key): args = TypeHelper.get_types_by_method(False, ShowCmdShell.ALIAS, expendNestedTypes=True) if key in args: -- To view, visit http://gerrit.ovirt.org/24209 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia65d4609a8dac28ff3d894baaf8c97f2881b865e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-cli Gerrit-Branch: master Gerrit-Owner: Ravi Nori <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
