Ravi Nori has uploaded a new change for review.

Change subject: cli: x-identifier auto-completion doesn't work in 
permissions(#1027281)
......................................................................

cli: x-identifier auto-completion doesn't work in permissions(#1027281)

append of -identifier suffix for vm object at
permission auto-completion doesn't work for
list/show/remove commands.

Change-Id: I3af7a66a1cd403f6506cf8a3ce00f8a63d9effd3
Bug-Url: https://bugzilla.redhat.com/1027281
Signed-off-by: Ravi Nori <[email protected]>
---
M src/ovirtcli/shell/addcmdshell.py
M src/ovirtcli/shell/cmdshell.py
M src/ovirtcli/utils/typehelper.py
3 files changed, 23 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/13/21513/1

diff --git a/src/ovirtcli/shell/addcmdshell.py 
b/src/ovirtcli/shell/addcmdshell.py
index 1b7c315..76463e3 100644
--- a/src/ovirtcli/shell/addcmdshell.py
+++ b/src/ovirtcli/shell/addcmdshell.py
@@ -44,8 +44,11 @@
                         specific_options[obj if key == None else key] = 
method_args
 
     def complete_add(self, text, line, begidx, endidx):
-        args = TypeHelper.get_types_by_method(False, AddCmdShell.NAME, 
expendNestedTypes=True)
+        args = TypeHelper.get_types_by_method(False,
+                                              AddCmdShell.NAME,
+                                              
obj_decorator_type=self.get_obj_decorator_type(line),
+                                              expendNestedTypes=True)
+
         specific_options = self.get_resource_specific_options(args, line,
                                                               
callback=self.__add_resource_specific_options)
-
         return AutoCompletionHelper.complete(line, text, args, 
specific_options=specific_options)
diff --git a/src/ovirtcli/shell/cmdshell.py b/src/ovirtcli/shell/cmdshell.py
index 794c700..10655b4 100644
--- a/src/ovirtcli/shell/cmdshell.py
+++ b/src/ovirtcli/shell/cmdshell.py
@@ -114,6 +114,22 @@
 
         return None
 
+    def get_obj_decorator_type(self, line):
+        obj_decorator_type = None
+        if line:
+            obj = None
+            spl = line.rstrip().split(' ')
+            if len(spl) >= 2:
+                obj = spl[1].strip()
+                base = self._resolve_base(spl[1:])
+                if base:
+                    obj = base
+            elif len(spl) == 2 and spl[1] != '':
+                obj = spl[1].strip()
+            obj_decorator_type = 
TypeHelper.getDecoratorType(TypeHelper.to_plural(obj))
+
+        return obj_decorator_type
+
     def get_resource_specific_options(self, args, line, callback):
         """
          Generates resource specific options. 
diff --git a/src/ovirtcli/utils/typehelper.py b/src/ovirtcli/utils/typehelper.py
index 6eba8bd..4be7a1a 100644
--- a/src/ovirtcli/utils/typehelper.py
+++ b/src/ovirtcli/utils/typehelper.py
@@ -111,7 +111,7 @@
         return types
 
     @staticmethod
-    def get_types_by_method(plural, method, expendNestedTypes=False, 
groupOptions=False):
+    def get_types_by_method(plural, method, obj_decorator_type=None, 
expendNestedTypes=False, groupOptions=False):
         """INTERNAL: return a list of types that implement given method and 
context/s of this types."""
         sing_types = {}
 
@@ -119,7 +119,7 @@
             for decorator in TypeHelper.getKnownDecoratorsTypes():
                 dct = getattr(brokers, decorator).__dict__
                 if dct.has_key(method):
-                    if decorator.endswith('s'):
+                    if decorator.endswith('s') and (obj_decorator_type is None 
or str(decorator) == str(obj_decorator_type)):
                         cls_name = 
TypeHelper.getDecoratorType(decorator[:len(decorator) - 1])
                         if cls_name:
                             MethodHelper.get_method_params(brokers,


-- 
To view, visit http://gerrit.ovirt.org/21513
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3af7a66a1cd403f6506cf8a3ce00f8a63d9effd3
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

Reply via email to