Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
---------------------------------------------------------------
commit b7ea2b324599895e4cdd1eceec4ea6781acee8b2
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Sep 30 10:54:56 2013 +0200
introduce get_namespace()
---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 3c00217..629310f 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -30,6 +30,7 @@ from LMIReturnValue import LMIReturnValue
from LMISubscription import LMISubscription
from LMIExceptions import LMIIndicationError
+from LMIExceptions import LMINamespaceNotFound
from LMIUtil import lmi_raise_or_dump_exception
from LMIUtil import lmi_get_use_exceptions
@@ -225,6 +226,28 @@ class LMIConnection(object):
"""
sys.stdout.write("root\n")
+ def get_namespace(self, namespace):
+ """
+ Returns LMINamespace object.
+
+ Raised exceptions:
+ LMINamespaceNotFound
+
+ Arguments:
+ namespace -- string containing namespace path (eg. root/cimv2)
+ """
+ def get_namespace_priv(namespace, namespace_path):
+ if not namespace_path:
+ return namespace
+ ns = namespace_path.pop(0)
+ return get_namespace_priv(getattr(namespace, ns), namespace_path)
+
+ namespace_path = namespace.split("/")
+ ns = namespace_path.pop(0)
+ if not ns in self.namespaces:
+ raise LMINamespaceNotFound(ns)
+ return get_namespace_priv(getattr(self, ns), namespace_path)
+
def clear_cache(self):
"""
Clears the cache.