Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
---------------------------------------------------------------
commit 10698c5f1c469395449b55d5a67bd0057876abf0
Author: Peter Hatina <phatina(a)redhat.com>
Date: Thu Nov 29 15:54:38 2012 +0100
fix namespace hierarchy
---------------------------------------------------------------
cli-tools/lmi-shell.py | 3 +-
cli-tools/lmi/lmi_client_shell.py | 43 ++++++++++++++++++++++++++----------
2 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/cli-tools/lmi-shell.py b/cli-tools/lmi-shell.py
index 0b33d5e..122bc34 100755
--- a/cli-tools/lmi-shell.py
+++ b/cli-tools/lmi-shell.py
@@ -23,6 +23,7 @@ import __builtin__
from lmi.lmi_client_base import LmiReturnValue
from lmi.lmi_client_shell import LmiConnection
from lmi.lmi_client_shell import _LmiNamespace
+from lmi.lmi_client_shell import _LmiNamespaceRoot
from lmi.lmi_client_shell import _LmiClass
from lmi.lmi_client_shell import _LmiInstance
@@ -116,7 +117,7 @@ class _LmiCompleter(rlcompleter.Completer):
expr = eval(cmd, self.namespace)
methods = self.__complete_object_methods(expr, to_complete)
properties = self.__complete_object_properties(expr, to_complete)
- if isinstance(expr, LmiConnection):
+ if isinstance(expr, (LmiConnection, _LmiNamespaceRoot)):
namespaces = expr.namespaces()
for n in namespaces:
if n.lower().startswith(to_complete.lower()):
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index af4d1cd..6b88d49 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -260,6 +260,35 @@ class _LmiNamespace(BaseObject):
for c in self.classes(filter_key, exact_match):
sys.stdout.write("%s\n" % c)
+class _LmiNamespaceRoot(_LmiNamespace):
+ def __init__(self, client):
+ super(self.__class__, self).__init__(client, "root")
+
+ @property
+ def cimv2(self):
+ return _LmiNamespace(self._client, "root/cimv2")
+
+ @property
+ def interop(self):
+ return _LmiNamespace(self._client, "root/interop")
+
+ @property
+ def PG_InterOp(self):
+ return _LmiNamespace(self._client, "root/PG_InterOp")
+
+ @property
+ def PG_Internal(self):
+ return _LmiNamespace(self._client, "root/PG_Internal")
+
+ def namespaces(self):
+ return ["cimv2", "interop", "PG_InterOp",
"PG_Internal"]
+
+ def print_namespaces(self):
+ sys.stdout.write("cimv2\n")
+ sys.stdout.write("interop\n")
+ sys.stdout.write("PG_InterOp")
+ sys.stdout.write("PG_Internal")
+
class _LmiClass(BaseObject):
def __init__(self, client, namespace, klass):
super(self.__class__, self).__init__()
@@ -530,21 +559,11 @@ class LmiConnection(object):
self._shell_client = _LmiShellClient(hostname, username, password, interactive)
def namespaces(self):
- return ["root", "cimv2", "interop"]
+ return ["root"]
def print_namespaces(self):
sys.stdout.write("root\n")
- sys.stdout.write("cimv2\n")
- sys.stdout.write("interop\n")
@property
def root(self):
- return _LmiNamespace(self._shell_client, "root")
-
- @property
- def cimv2(self):
- return _LmiNamespace(self._shell_client, "root/cimv2")
-
- @property
- def interop(self):
- return _LmiNamespace(self._shell_client, "root/interop")
+ return _LmiNamespaceRoot(self._shell_client)