Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
commit b2239e2632b98744942143e0bbf48c474b69bc89 Author: Peter Hatina phatina@redhat.com Date: Tue Oct 30 22:53:00 2012 +0100
cache classes in _LmiShellClient::getClass()
cli-tools/lmi/lmi_client_shell.py | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 88e4fd0..9c44dea 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -249,6 +249,11 @@ class _LmiShellClient(LmiBaseClient): def __init__(self, hostname, username = "", password = ""): super(self.__class__, self).__init__(hostname, username, password) self.m_cache_class_names = {} + self.m_cache_classes = { + "root" : {}, + "root/cimv2" : {}, + "root/interop" : {} + }
def getClassNames(self, namespace = None, use_cache = True): errorstr = "" @@ -266,8 +271,15 @@ class _LmiShellClient(LmiBaseClient): return None return instance_list
- def getClass(self, class_name, namespace = None): - return self._getClass(class_name, namespace) + def getClass(self, class_name, namespace = None, use_cache = True): + errorstr = "" + ns = namespace if namespace else "none" + if class_name not in self.m_cache_classes[ns] or not use_cache: + (klass, errorstr) = self._getClass(class_name, namespace) + if not klass: + return (None, errorstr) + self.m_cache_classes[ns][class_name] = klass + return (self.m_cache_classes[ns][class_name], errorstr)
def callMethodRaw(self, instance, method, **params): return self._callMethodRaw(instance, method, **params)
cura-tools-devel@lists.fedorahosted.org