[cura-tools] master: introduce verify_server_cert param for connect() (9b6cb08)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 9b6cb08a8d1692d58fc938fb9c0c879a6e617311
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Sep 2 17:02:05 2013 +0200
introduce verify_server_cert param for connect()
This optional parameter can override global setting, if provided.
>---------------------------------------------------------------
cli/lmi/shell/LMIConsole.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/shell/LMIConsole.py b/cli/lmi/shell/LMIConsole.py
index 0b98b2d..bebcce3 100644
--- a/cli/lmi/shell/LMIConsole.py
+++ b/cli/lmi/shell/LMIConsole.py
@@ -118,15 +118,18 @@ class LMIConsole(code.InteractiveConsole):
Keyword Arguments:
key_file -- string containing path to x509 key file; default value is None
cert_file -- string containing path to x509 cert file; default value is None
+ verify_server_cert -- bool flag, whether a server side certificate needs
+ to be verified, if ssl used; default value is True
"""
key_file = kwargs.pop("key_file", None)
cert_file = kwargs.pop("cert_file", None)
+ verify_server_cert = kwargs.pop("verify_server_cert", self._verify_server_cert)
if kwargs:
raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
return connect_internal(hostname, username, password, interactive=True,
use_cache=self._use_cache, key_file=key_file, cert_file=cert_file,
- verify_server_cert=self._verify_server_cert)
+ verify_server_cert=verify_server_cert)
# Initialize the interpreter
if locals is None:
@@ -206,16 +209,19 @@ class LMIConsole(code.InteractiveConsole):
Keyword Arguments:
key_file -- string containing path to x509 key file; default value is None
cert_file -- string containing path to x509 cert file; default value is None
+ verify_server_cert -- bool flag, whether a server side certificate needs
+ to be verified, if ssl used; default value is True
"""
# Set remaining arguments
key_file = kwargs.pop("key_file", None)
cert_file = kwargs.pop("cert_file", None)
+ verify_server_cert = kwargs.pop("verify_server_cert", self._verify_server_cert)
if kwargs:
raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
return connect_internal(hostname, username, password, interactive=False,
use_cache=self._use_cache, key_file=key_file, cert_file=cert_file,
- verify_server_cert=self._verify_server_cert)
+ verify_server_cert=verify_server_cert)
# Initialize locals
if locals is None:
locals = {}
10 years, 8 months
[cura-tools] master: introduce client certificate authentication (d7fd989)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit d7fd9895ed45b148d15bb421ebb76d47bb375d9c
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Sep 2 17:01:52 2013 +0200
introduce client certificate authentication
>---------------------------------------------------------------
cli/lmi/shell/LMIBaseClient.py | 5 +++++
cli/lmi/shell/LMIConnection.py | 15 ++++++++++++---
cli/lmi/shell/LMIConsole.py | 29 +++++++++++++++++++++++++----
cli/lmi/shell/LMIShellClient.py | 6 +++++-
4 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/cli/lmi/shell/LMIBaseClient.py b/cli/lmi/shell/LMIBaseClient.py
index 9e99094..10fd216 100644
--- a/cli/lmi/shell/LMIBaseClient.py
+++ b/cli/lmi/shell/LMIBaseClient.py
@@ -46,6 +46,8 @@ class LMIBaseClient(object):
LMIBaseClient.CONN_TYPE_PEGASUS_UDS -- applicable only for Tog-Pegasus
CIMOM, it uses unix socket for the connection; default value is
CONN_TYPE_WBEM
+ key_file -- string containing path to x509 key file; default value is None
+ cert_file -- string containing path to x509 cert file; default value is None
verify_server_cert -- flag indicating, whether a server side certificate
needs to be verified, if SSL used; default value is True
"""
@@ -67,6 +69,8 @@ class LMIBaseClient(object):
# Set remaining arguments
conn_type = kwargs.pop("conn_type", LMIBaseClient.CONN_TYPE_WBEM)
verify_server_cert = kwargs.pop("verify_server_cert", True)
+ key_file = kwargs.pop("key_file", None)
+ cert_file = kwargs.pop("cert_file", None)
if kwargs:
raise TypeError("__init__() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
@@ -79,6 +83,7 @@ class LMIBaseClient(object):
else:
self._cliconn = pywbem.WBEMConnection(self._hostname,
(self._username, password),
+ x509={"key_file" : key_file, "cert_file" : cert_file},
verify_callback=verify_callback if verify_server_cert else None
)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index b79ea4c..3c00217 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -96,6 +96,8 @@ def connect(hostname, username="", password="", **kwargs):
CIMClass objects. This saves a lot's of communication, if there is
often the LMIShellClient._get_class_names() or ._get_class() call
issued. Default value is True.
+ key_file -- string containing path to x509 key file; default value is None
+ cert_file -- string containing path to x509 cert file; default value is None
verify_server_cert -- flag indicating, whether a server side certificate
needs to be verified, if SSL used; default value is True.
prompt_prefix -- string prefixing username and password prompts in case
@@ -104,6 +106,8 @@ def connect(hostname, username="", password="", **kwargs):
# Set remaining arguments
interactive = kwargs.pop("interactive", False)
use_cache = kwargs.pop("use_cache", True)
+ key_file = kwargs.pop("key_file", None)
+ cert_file = kwargs.pop("cert_file", None)
verify_server_cert = kwargs.pop("verify_server_cert", True)
prompt_prefix = kwargs.pop("prompt_prefix", "")
if kwargs:
@@ -121,7 +125,7 @@ def connect(hostname, username="", password="", **kwargs):
if not connection.verify_credentials():
connection = None
if connection is None:
- if interactive:
+ if interactive and not key_file and not cert_file:
try:
if not username:
username = __lmi_raw_input(prompt_prefix+"username: ", True)
@@ -132,7 +136,7 @@ def connect(hostname, username="", password="", **kwargs):
return None
connection = LMIConnection(hostname, username, password, interactive=interactive,
use_cache=use_cache, conn_type=LMIBaseClient.CONN_TYPE_WBEM,
- verify_server_cert=verify_server_cert)
+ key_file=key_file, cert_file=cert_file, verify_server_cert=verify_server_cert)
if not connection.verify_credentials():
return None
return connection
@@ -164,6 +168,8 @@ class LMIConnection(object):
LMIBaseClient.CONN_TYPE_PEGASUS_UDS -- applicable only for Tog-Pegasus
CIMOM, it uses unix socket for the connection; default value is
CONN_TYPE_WBEM
+ key_file -- string containing path to x509 key file; default value is None
+ cert_file -- string containing path to x509 cert file; default value is None
verify_server_cert -- flag indicating, whether a server side certificate
needs to be verified, if SSL used; default value is True
"""
@@ -171,12 +177,15 @@ class LMIConnection(object):
interactive = kwargs.pop("interactive", False)
use_cache = kwargs.pop("use_cache", True)
conn_type = kwargs.pop("conn_type", LMIBaseClient.CONN_TYPE_WBEM)
+ key_file = kwargs.pop("key_file", None)
+ cert_file = kwargs.pop("cert_file", None)
verify_server_cert = kwargs.pop("verify_server_cert", True)
if kwargs:
raise TypeError("__init__() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
self._client = LMIShellClient(hostname, username, password, interactive=interactive,
- use_cache=use_cache, conn_type=conn_type, verify_server_cert=verify_server_cert)
+ use_cache=use_cache, conn_type=conn_type, key_file=key_file, cert_file=cert_file,
+ verify_server_cert=verify_server_cert)
self._indications = {}
# Register LMIConnection.__unsubscribe_all_indications() to be called at LMIShell's exit.
atexit.register(lambda: self.__unsubscribe_all_indications())
diff --git a/cli/lmi/shell/LMIConsole.py b/cli/lmi/shell/LMIConsole.py
index 226eeac..0b98b2d 100644
--- a/cli/lmi/shell/LMIConsole.py
+++ b/cli/lmi/shell/LMIConsole.py
@@ -106,7 +106,7 @@ class LMIConsole(code.InteractiveConsole):
Arguments:
locals -- dictionary with locals
"""
- def connect(hostname, username="", password=""):
+ def connect(hostname, username="", password="", **kwargs):
"""
Returns LMIConnection object with provided hostname and credentials.
@@ -114,9 +114,19 @@ class LMIConsole(code.InteractiveConsole):
hostname -- uri of the CIMOM
username -- account, under which, the CIM calls will be performed
password -- user's password
+
+ Keyword Arguments:
+ key_file -- string containing path to x509 key file; default value is None
+ cert_file -- string containing path to x509 cert file; default value is None
"""
+ key_file = kwargs.pop("key_file", None)
+ cert_file = kwargs.pop("cert_file", None)
+ if kwargs:
+ raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+
return connect_internal(hostname, username, password, interactive=True,
- use_cache=self._use_cache, verify_server_cert=self._verify_server_cert)
+ use_cache=self._use_cache, key_file=key_file, cert_file=cert_file,
+ verify_server_cert=self._verify_server_cert)
# Initialize the interpreter
if locals is None:
@@ -184,7 +194,7 @@ class LMIConsole(code.InteractiveConsole):
locals -- dictionary with locals
"""
# Helper function for non-interactive connect
- def connect(hostname, username="", password=""):
+ def connect(hostname, username="", password="", **kwargs):
"""
Returns LMIConnection object with provided hostname and credentials.
@@ -192,9 +202,20 @@ class LMIConsole(code.InteractiveConsole):
hostname -- uri of the CIMOM
username -- account, under which, the CIM calls will be performed
password -- user's password
+
+ Keyword Arguments:
+ key_file -- string containing path to x509 key file; default value is None
+ cert_file -- string containing path to x509 cert file; default value is None
"""
+ # Set remaining arguments
+ key_file = kwargs.pop("key_file", None)
+ cert_file = kwargs.pop("cert_file", None)
+ if kwargs:
+ raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+
return connect_internal(hostname, username, password, interactive=False,
- use_cache=self._use_cache, verify_server_cert=self._verify_server_cert)
+ use_cache=self._use_cache, key_file=key_file, cert_file=cert_file,
+ verify_server_cert=self._verify_server_cert)
# Initialize locals
if locals is None:
locals = {}
diff --git a/cli/lmi/shell/LMIShellClient.py b/cli/lmi/shell/LMIShellClient.py
index 857bec0..4ebeba1 100644
--- a/cli/lmi/shell/LMIShellClient.py
+++ b/cli/lmi/shell/LMIShellClient.py
@@ -44,6 +44,8 @@ class LMIShellClient(LMIBaseClient):
LMIBaseClient.CONN_TYPE_PEGASUS_UDS -- applicable only for Tog-Pegasus
CIMOM, it uses unix socket for the connection; default value is
CONN_TYPE_WBEM
+ key_file -- string containing path to x509 key file; default value is None
+ cert_file -- string containing path to x509 cert file; default value is None
verify_server_cert -- flag indicating, whether a server side certificate
needs to be verified, if SSL used; default value is True
"""
@@ -51,12 +53,14 @@ class LMIShellClient(LMIBaseClient):
interactive = kwargs.pop("interactive", False)
use_cache = kwargs.pop("use_cache", True)
conn_type = kwargs.pop("conn_type", LMIBaseClient.CONN_TYPE_WBEM)
+ key_file = kwargs.pop("key_file", None)
+ cert_file = kwargs.pop("cert_file", None)
verify_server_cert = kwargs.pop("verify_server_cert", True)
if kwargs:
raise TypeError("__init__() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
super(LMIShellClient, self).__init__(hostname, username, password, conn_type=conn_type,
- verify_server_cert=verify_server_cert)
+ key_file=key_file, cert_file=cert_file, verify_server_cert=verify_server_cert)
self._interactive = interactive
self._cache = LMIShellCache(use_cache)
10 years, 8 months
[cura-tools] master: drop lmi_get_item_or_default (d30b54a)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit d30b54a6a79d68778339f6b3e8d17c1dd75bbe3a
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Sep 2 16:37:47 2013 +0200
drop lmi_get_item_or_default
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 3 +--
cli/lmi/shell/LMIMethod.py | 9 +++------
cli/lmi/shell/LMIShellConfig.py | 13 ++++---------
cli/lmi/shell/LMIUtil.py | 14 +-------------
4 files changed, 9 insertions(+), 30 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 27191d3..cd8b9a2 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -31,7 +31,6 @@ from LMISubscription import LMISubscription
from LMIExceptions import LMIIndicationError
-from LMIUtil import lmi_get_item_or_default
from LMIUtil import lmi_raise_or_dump_exception
from LMIUtil import lmi_get_use_exceptions
from LMIUtil import lmi_set_use_exceptions
@@ -330,7 +329,7 @@ class LMIConnection(object):
lmi_raise_or_dump_exception(LMIIndicationError(errorstr))
return LMIReturnValue(rval=False, errorstr=errorstr)
# XXX: Should we auto-delete all the indications?
- permanent = lmi_get_item_or_default(kwargs, "Permanent", True)
+ permanent = kwargs.get("Permanent", True)
self._indications[kwargs["Name"]] = LMISubscription(
self._client,
(cim_filter, not cim_filter_provided),
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index b863371..8168ca4 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -42,7 +42,6 @@ from LMIUtil import LMIPassByRef
from LMIUtil import lmi_raise_or_dump_exception
from LMIUtil import lmi_cast_to_cim
from LMIUtil import lmi_transform_to_lmi
-from LMIUtil import lmi_get_item_or_default
from LMIExceptions import LMIIndicationListenerError
from LMIExceptions import LMIMethodCallError
@@ -130,7 +129,7 @@ class LMIMethod(LMIWrapperBaseObject):
if not refreshed:
raise LMISynchroMethodCallError(errorstr)
(exc_rval, exc_rparams, exc_errorstr) = job_inst.GetError()
- error_inst = lmi_get_item_or_default(exc_rparams, "error", None)
+ error_inst = exc_rparams.get("error", None)
if not error_inst:
raise LMISynchroMethodCallError("Could not get Job error message")
errorstr = error_inst.Message
@@ -349,9 +348,7 @@ class LMIMethod(LMIWrapperBaseObject):
args -- CIMMethod arguments
kwargs -- CIMMethod keyword arguments
"""
- synchro_method_polling = False
- if "PreferPolling" in kwargs:
- synchro_method_polling = kwargs.pop("PreferPolling")
+ synchro_method_polling = kwargs.pop("PreferPolling", False)
for (param, value) in kwargs.iteritems():
if param in self._method.parameters:
t = self._method.parameters[param].type
@@ -372,7 +369,7 @@ class LMIMethod(LMIWrapperBaseObject):
lmi_raise_or_dump_exception(LMIMethodCallError(errorstr))
return LMIReturnValue(rval=rval, errorstr=errorstr)
# Check if we can perform synchronous method call
- job = call_rparams["job"] if "job" in call_rparams else None
+ job = call_rparams.get("job", None)
can_perform_sync_call = job.classname in LMIMethod._INDICATION_JOB_CLASSNAMES if job else False
if self._sync_method and job and can_perform_sync_call:
# Synchronous method calls
diff --git a/cli/lmi/shell/LMIShellConfig.py b/cli/lmi/shell/LMIShellConfig.py
index 66e05c8..c0fd24c 100644
--- a/cli/lmi/shell/LMIShellConfig.py
+++ b/cli/lmi/shell/LMIShellConfig.py
@@ -16,8 +16,6 @@
import os
import sys
-from LMIUtil import lmi_get_item_or_default
-
class LMIShellConfig(object):
"""
Class representing the shell's configuration. The class is responsible for loading the
@@ -39,14 +37,11 @@ class LMIShellConfig(object):
try:
conf = {}
execfile(os.path.expanduser(LMIShellConfig.DEFAULT_CONFIG_FILE), conf)
- self._history_file = os.path.expanduser(lmi_get_item_or_default(conf, "history_file",
+ self._history_file = os.path.expanduser(conf.get("history_file",
LMIShellConfig.DEFAULT_HISTORY_FILE))
- self._history_length = lmi_get_item_or_default(conf, "history_length",
- LMIShellConfig.DEFAULT_HISTORY_LENGTH)
- self._use_cache = lmi_get_item_or_default(conf, "use_cache",
- LMIShellConfig.DEFAULT_USE_CACHE)
- self._use_exceptions = lmi_get_item_or_default(conf, "use_exceptions",
- LMIShellConfig.DEFAULT_USE_EXCEPTIONS)
+ self._history_length = conf.get("history_length", LMIShellConfig.DEFAULT_HISTORY_LENGTH)
+ self._use_cache = conf.get("use_cache", LMIShellConfig.DEFAULT_USE_CACHE)
+ self._use_exceptions = conf.get("use_exceptions", LMIShellConfig.DEFAULT_USE_EXCEPTIONS)
except (SyntaxError, IOError), e:
if isinstance(e, SyntaxError):
sys.stderr.write("Error: %s\n" % e)
diff --git a/cli/lmi/shell/LMIUtil.py b/cli/lmi/shell/LMIUtil.py
index f536b80..94f38b4 100644
--- a/cli/lmi/shell/LMIUtil.py
+++ b/cli/lmi/shell/LMIUtil.py
@@ -87,18 +87,6 @@ class LMIPassByRef(object):
"""
self._val[0] = new_val
-def lmi_get_item_or_default(dic, item, default):
- """
- Helper function, which returns either the dictionary member, or specified default
- value.
-
- Arguments:
- dic -- dictionary
- item -- dictionary key
- default -- default return value, if item is not present in the dictionary
- """
- return dic[item] if item in dic else default
-
def lmi_get_use_exceptions():
"""
Returns a global flag indicating, if the LMIShell should use the exceptions,
@@ -134,7 +122,7 @@ def _lmi_do_cast(t, value, cast):
value -- variable to cast
cast -- dictionary with type:cast_func
"""
- cast_func = cast[t.lower()] if t.lower() in cast else lambda x: x
+ cast_func = cast.get(t.lower(), lambda x: x)
if isinstance(value, (dict, pywbem.NocaseDict)):
return pywbem.NocaseDict({
k: _lmi_do_cast(t, val, cast) for k, val in value.iteritems()})
10 years, 8 months
[cura-tools] master: fix missing doc string for LMIFilterError (ce584de)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit ce584de6d89662f8d05f1f34482986e5660ef70e
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Sep 2 16:58:49 2013 +0200
fix missing doc string for LMIFilterError
>---------------------------------------------------------------
cli/lmi/shell/LMIExceptions.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli/lmi/shell/LMIExceptions.py b/cli/lmi/shell/LMIExceptions.py
index d499918..2714c56 100644
--- a/cli/lmi/shell/LMIExceptions.py
+++ b/cli/lmi/shell/LMIExceptions.py
@@ -66,7 +66,7 @@ class LMIHandlerNamePatternError(Exception):
class LMIFilterError(Exception):
"""
- Raised, when there is a filter error present
+ Raised, when a filter error occurs, mostly when filter object is missing.
"""
class LMIClassNotFound(AttributeError):
10 years, 8 months
[cura-tools] master: move optional parameters into kwargs (e8c4840)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit e8c48409c10ec589fffb242282965389a52dd50e
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Sep 2 16:58:17 2013 +0200
move optional parameters into kwargs
Affected classes: LMIBaseClient, LMIConnection, LMIConsole, LMIShellClient. Afftected functions: connect()
>---------------------------------------------------------------
cli/lmi/shell/LMIBaseClient.py | 13 ++++++--
cli/lmi/shell/LMIConnection.py | 59 +++++++++++++++++++++++++++-----------
cli/lmi/shell/LMIConsole.py | 8 ++--
cli/lmi/shell/LMIShellClient.py | 19 +++++++++---
4 files changed, 70 insertions(+), 29 deletions(-)
diff --git a/cli/lmi/shell/LMIBaseClient.py b/cli/lmi/shell/LMIBaseClient.py
index 85fe161..9e99094 100644
--- a/cli/lmi/shell/LMIBaseClient.py
+++ b/cli/lmi/shell/LMIBaseClient.py
@@ -31,8 +31,7 @@ class LMIBaseClient(object):
CONN_TYPE_WBEM, \
CONN_TYPE_PEGASUS_UDS = range(2)
- def __init__(self, hostname, username="", password="", conn_type=CONN_TYPE_WBEM, \
- verify_server_cert=True):
+ def __init__(self, hostname, username="", password="", **kwargs):
"""
Constructs a LMIBaseClient object.
@@ -40,13 +39,15 @@ class LMIBaseClient(object):
hostname -- uri of the CIMOM
username -- account, under which, the CIM calls will be performed
password -- user's password
+
+ Keyword Arguments:
conn_type -- type of connection; can be of 2 values:
LMIBaseClient.CONN_TYPE_WBEM -- WBEM connection,
LMIBaseClient.CONN_TYPE_PEGASUS_UDS -- applicable only for Tog-Pegasus
CIMOM, it uses unix socket for the connection; default value is
CONN_TYPE_WBEM
verify_server_cert -- flag indicating, whether a server side certificate
- needs to be verified, if SSL used
+ needs to be verified, if SSL used; default value is True
"""
def verify_callback(conn, cert, errno, errdepth, rcode):
"""
@@ -63,6 +64,12 @@ class LMIBaseClient(object):
"""
return bool(rcode)
+ # Set remaining arguments
+ conn_type = kwargs.pop("conn_type", LMIBaseClient.CONN_TYPE_WBEM)
+ verify_server_cert = kwargs.pop("verify_server_cert", True)
+ if kwargs:
+ raise TypeError("__init__() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+
self._hostname = hostname
self._username = username
if not self._hostname.startswith("http://") and not self._hostname.startswith("https://"):
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index cd8b9a2..b79ea4c 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -80,8 +80,7 @@ def __lmi_raw_input(prompt, use_echo=True):
return result
-def connect(hostname, username="", password="", interactive=False, use_cache=True,
- verify_server_cert=True, prompt_prefix=''):
+def connect(hostname, username="", password="", **kwargs):
"""
Returns a LMIConnection object with provided hostname and credentials.
@@ -89,25 +88,36 @@ def connect(hostname, username="", password="", interactive=False, use_cache=Tru
hostname -- uri of the CIMOM
username -- account, under which, the CIM calls will be performed
password -- user's password
+
+ Keyword Arguments:
interactive -- flag indicating, if the LMIShell client is running in the
- interactive mode
+ interactive mode; default value is False.
use_cache -- flag indicationg, if the LMIShell client should use cache for
CIMClass objects. This saves a lot's of communication, if there is
often the LMIShellClient._get_class_names() or ._get_class() call
- issued.
+ issued. Default value is True.
verify_server_cert -- flag indicating, whether a server side certificate
- needs to be verified, if SSL used
+ needs to be verified, if SSL used; default value is True.
prompt_prefix -- string prefixing username and password prompts in case
- the user is asked for credentials
+ the user is asked for credentials. Default value is empty string.
"""
+ # Set remaining arguments
+ interactive = kwargs.pop("interactive", False)
+ use_cache = kwargs.pop("use_cache", True)
+ verify_server_cert = kwargs.pop("verify_server_cert", True)
+ prompt_prefix = kwargs.pop("prompt_prefix", "")
+ if kwargs:
+ raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+
connection = None
netloc = urlparse.urlparse(hostname).netloc
destination = netloc if netloc else hostname
if os.getuid() == 0 and destination in ("localhost", "127.0.0.1", "::1") and \
os.path.exists("/var/run/tog-pegasus/cimxml.socket") and \
not username and not password:
- connection = LMIConnection(hostname, None, None, interactive,
- use_cache, LMIBaseClient.CONN_TYPE_PEGASUS_UDS, verify_server_cert)
+ connection = LMIConnection(hostname, None, None, interactive=interactive,
+ use_cache=use_cache, conn_type=LMIBaseClient.CONN_TYPE_PEGASUS_UDS,
+ verify_server_cert=verify_server_cert)
if not connection.verify_credentials():
connection = None
if connection is None:
@@ -120,8 +130,9 @@ def connect(hostname, username="", password="", interactive=False, use_cache=Tru
except KeyboardInterrupt, e:
sys.stdout.write("\n")
return None
- connection = LMIConnection(hostname, username, password, interactive,
- use_cache, LMIBaseClient.CONN_TYPE_WBEM, verify_server_cert)
+ connection = LMIConnection(hostname, username, password, interactive=interactive,
+ use_cache=use_cache, conn_type=LMIBaseClient.CONN_TYPE_WBEM,
+ verify_server_cert=verify_server_cert)
if not connection.verify_credentials():
return None
return connection
@@ -132,8 +143,7 @@ class LMIConnection(object):
should have its own connection object created. This class provides an entry point to
the namespace/classes/instances/methods hierarchy present in the LMIShell.
"""
- def __init__(self, hostname, username="", password="", interactive=False, use_cache=True, \
- conn_type=LMIBaseClient.CONN_TYPE_WBEM, verify_server_cert=True):
+ def __init__(self, hostname, username="", password="", **kwargs):
"""
Constructs a LMIConnection object.
@@ -141,17 +151,32 @@ class LMIConnection(object):
hostname -- uri of the CIMOM
username -- account, under which, the CIM calls will be performed
password -- user's password
+
+ Keyword Arguments:
interactive -- flag indicating, if the LMIShell client is running in the
- interactive mode
+ interactive mode; default value is False
use_cache -- flag indicationg, if the LMIShell client should use cache for
CIMClass objects. This saves a lot's of communication, if there is
often the LMIShellClient._get_class_names() or ._get_class() call
- issued.
+ issued. Default value is True.
+ conn_type -- type of connection; can be of 2 values:
+ LMIBaseClient.CONN_TYPE_WBEM -- WBEM connection,
+ LMIBaseClient.CONN_TYPE_PEGASUS_UDS -- applicable only for Tog-Pegasus
+ CIMOM, it uses unix socket for the connection; default value is
+ CONN_TYPE_WBEM
verify_server_cert -- flag indicating, whether a server side certificate
- needs to be verified, if SSL used
+ needs to be verified, if SSL used; default value is True
"""
- self._client = LMIShellClient(hostname, username, password, interactive, use_cache,
- conn_type, verify_server_cert)
+ # Set remaining arguments
+ interactive = kwargs.pop("interactive", False)
+ use_cache = kwargs.pop("use_cache", True)
+ conn_type = kwargs.pop("conn_type", LMIBaseClient.CONN_TYPE_WBEM)
+ verify_server_cert = kwargs.pop("verify_server_cert", True)
+ if kwargs:
+ raise TypeError("__init__() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+
+ self._client = LMIShellClient(hostname, username, password, interactive=interactive,
+ use_cache=use_cache, conn_type=conn_type, verify_server_cert=verify_server_cert)
self._indications = {}
# Register LMIConnection.__unsubscribe_all_indications() to be called at LMIShell's exit.
atexit.register(lambda: self.__unsubscribe_all_indications())
diff --git a/cli/lmi/shell/LMIConsole.py b/cli/lmi/shell/LMIConsole.py
index c0ffe3a..226eeac 100644
--- a/cli/lmi/shell/LMIConsole.py
+++ b/cli/lmi/shell/LMIConsole.py
@@ -115,8 +115,8 @@ class LMIConsole(code.InteractiveConsole):
username -- account, under which, the CIM calls will be performed
password -- user's password
"""
- return connect_internal(hostname, username, password, True,
- self._use_cache, self._verify_server_cert)
+ return connect_internal(hostname, username, password, interactive=True,
+ use_cache=self._use_cache, verify_server_cert=self._verify_server_cert)
# Initialize the interpreter
if locals is None:
@@ -193,8 +193,8 @@ class LMIConsole(code.InteractiveConsole):
username -- account, under which, the CIM calls will be performed
password -- user's password
"""
- return connect_internal(hostname, username, password, False,
- self._use_cache, self._verify_server_cert)
+ return connect_internal(hostname, username, password, interactive=False,
+ use_cache=self._use_cache, verify_server_cert=self._verify_server_cert)
# Initialize locals
if locals is None:
locals = {}
diff --git a/cli/lmi/shell/LMIShellClient.py b/cli/lmi/shell/LMIShellClient.py
index 59e28ad..857bec0 100644
--- a/cli/lmi/shell/LMIShellClient.py
+++ b/cli/lmi/shell/LMIShellClient.py
@@ -23,8 +23,7 @@ class LMIShellClient(LMIBaseClient):
This class overrides few methods due to caching.
"""
- def __init__(self, hostname, username="", password="", interactive=False, use_cache=True, \
- conn_type=LMIBaseClient.CONN_TYPE_WBEM, verify_server_cert=True):
+ def __init__(self, hostname, username="", password="", **kwargs):
"""
Constructs a LMIShellClient object.
@@ -32,6 +31,8 @@ class LMIShellClient(LMIBaseClient):
hostname -- uri of the CIMOM
username -- account, under which, the CIM calls will be performed
password -- user's password
+
+ Keyword Arguments:
interactive -- flag indicating, if the LMIShell client is running in the
interactive mode
use_cache -- flag indicationg, if the LMIShell client should use cache for
@@ -44,10 +45,18 @@ class LMIShellClient(LMIBaseClient):
CIMOM, it uses unix socket for the connection; default value is
CONN_TYPE_WBEM
verify_server_cert -- flag indicating, whether a server side certificate
- needs to be verified, if SSL used
- """
- super(LMIShellClient, self).__init__(hostname, username, password, conn_type,
- verify_server_cert)
+ needs to be verified, if SSL used; default value is True
+ """
+ # Set remaining arguments
+ interactive = kwargs.pop("interactive", False)
+ use_cache = kwargs.pop("use_cache", True)
+ conn_type = kwargs.pop("conn_type", LMIBaseClient.CONN_TYPE_WBEM)
+ verify_server_cert = kwargs.pop("verify_server_cert", True)
+ if kwargs:
+ raise TypeError("__init__() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+
+ super(LMIShellClient, self).__init__(hostname, username, password, conn_type=conn_type,
+ verify_server_cert=verify_server_cert)
self._interactive = interactive
self._cache = LMIShellCache(use_cache)
10 years, 8 months
[cura-tools] master: rename verify_certificate (b1d5284)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit b1d5284feb0636a05a6070c46c4fde7641eb6d4e
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Sep 2 16:35:22 2013 +0200
rename verify_certificate
Preparation for naming exactness, when introducing client certificate authentication.
>---------------------------------------------------------------
cli/lmi/shell/LMIBaseClient.py | 6 +++---
cli/lmi/shell/LMIConnection.py | 14 +++++++-------
cli/lmi/shell/LMIConsole.py | 12 ++++++------
cli/lmi/shell/LMIShellClient.py | 6 +++---
cli/lmi/shell/LMIShellOptions.py | 2 +-
cli/lmishell | 2 +-
6 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/cli/lmi/shell/LMIBaseClient.py b/cli/lmi/shell/LMIBaseClient.py
index 8ccb079..85fe161 100644
--- a/cli/lmi/shell/LMIBaseClient.py
+++ b/cli/lmi/shell/LMIBaseClient.py
@@ -32,7 +32,7 @@ class LMIBaseClient(object):
CONN_TYPE_PEGASUS_UDS = range(2)
def __init__(self, hostname, username="", password="", conn_type=CONN_TYPE_WBEM, \
- verify_certificate=True):
+ verify_server_cert=True):
"""
Constructs a LMIBaseClient object.
@@ -45,7 +45,7 @@ class LMIBaseClient(object):
LMIBaseClient.CONN_TYPE_PEGASUS_UDS -- applicable only for Tog-Pegasus
CIMOM, it uses unix socket for the connection; default value is
CONN_TYPE_WBEM
- verify_certificate -- flag indicating, whether a server side certificate
+ verify_server_cert -- flag indicating, whether a server side certificate
needs to be verified, if SSL used
"""
def verify_callback(conn, cert, errno, errdepth, rcode):
@@ -72,7 +72,7 @@ class LMIBaseClient(object):
else:
self._cliconn = pywbem.WBEMConnection(self._hostname,
(self._username, password),
- verify_callback=verify_callback if verify_certificate else None
+ verify_callback=verify_callback if verify_server_cert else None
)
# NOTE: usage with Key=something, Value=something is deprecated
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 5dfa5fe..27191d3 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -82,7 +82,7 @@ def __lmi_raw_input(prompt, use_echo=True):
return result
def connect(hostname, username="", password="", interactive=False, use_cache=True,
- verify_certificate=True, prompt_prefix=''):
+ verify_server_cert=True, prompt_prefix=''):
"""
Returns a LMIConnection object with provided hostname and credentials.
@@ -96,7 +96,7 @@ def connect(hostname, username="", password="", interactive=False, use_cache=Tru
CIMClass objects. This saves a lot's of communication, if there is
often the LMIShellClient._get_class_names() or ._get_class() call
issued.
- verify_certificate -- flag indicating, whether a server side certificate
+ verify_server_cert -- flag indicating, whether a server side certificate
needs to be verified, if SSL used
prompt_prefix -- string prefixing username and password prompts in case
the user is asked for credentials
@@ -108,7 +108,7 @@ def connect(hostname, username="", password="", interactive=False, use_cache=Tru
os.path.exists("/var/run/tog-pegasus/cimxml.socket") and \
not username and not password:
connection = LMIConnection(hostname, None, None, interactive,
- use_cache, LMIBaseClient.CONN_TYPE_PEGASUS_UDS, verify_certificate)
+ use_cache, LMIBaseClient.CONN_TYPE_PEGASUS_UDS, verify_server_cert)
if not connection.verify_credentials():
connection = None
if connection is None:
@@ -122,7 +122,7 @@ def connect(hostname, username="", password="", interactive=False, use_cache=Tru
sys.stdout.write("\n")
return None
connection = LMIConnection(hostname, username, password, interactive,
- use_cache, LMIBaseClient.CONN_TYPE_WBEM, verify_certificate)
+ use_cache, LMIBaseClient.CONN_TYPE_WBEM, verify_server_cert)
if not connection.verify_credentials():
return None
return connection
@@ -134,7 +134,7 @@ class LMIConnection(object):
the namespace/classes/instances/methods hierarchy present in the LMIShell.
"""
def __init__(self, hostname, username="", password="", interactive=False, use_cache=True, \
- conn_type=LMIBaseClient.CONN_TYPE_WBEM, verify_certificate=True):
+ conn_type=LMIBaseClient.CONN_TYPE_WBEM, verify_server_cert=True):
"""
Constructs a LMIConnection object.
@@ -148,11 +148,11 @@ class LMIConnection(object):
CIMClass objects. This saves a lot's of communication, if there is
often the LMIShellClient._get_class_names() or ._get_class() call
issued.
- verify_certificate -- flag indicating, whether a server side certificate
+ verify_server_cert -- flag indicating, whether a server side certificate
needs to be verified, if SSL used
"""
self._client = LMIShellClient(hostname, username, password, interactive, use_cache,
- conn_type, verify_certificate)
+ conn_type, verify_server_cert)
self._indications = {}
# Register LMIConnection.__unsubscribe_all_indications() to be called at LMIShell's exit.
atexit.register(lambda: self.__unsubscribe_all_indications())
diff --git a/cli/lmi/shell/LMIConsole.py b/cli/lmi/shell/LMIConsole.py
index 1a0bd3e..c0ffe3a 100644
--- a/cli/lmi/shell/LMIConsole.py
+++ b/cli/lmi/shell/LMIConsole.py
@@ -85,7 +85,7 @@ class LMIConsole(code.InteractiveConsole):
self._history_length = config.history_length
self._use_cache = config.use_cache
self._use_exceptions = config.use_exceptions
- self._verify_certificate = True
+ self._verify_server_cert = True
# Setup LMIShell-wide option, which defines, whether the LMIShell
# should propagate caught exceptions, or dump them
@@ -116,7 +116,7 @@ class LMIConsole(code.InteractiveConsole):
password -- user's password
"""
return connect_internal(hostname, username, password, True,
- self._use_cache, self._verify_certificate)
+ self._use_cache, self._verify_server_cert)
# Initialize the interpreter
if locals is None:
@@ -194,7 +194,7 @@ class LMIConsole(code.InteractiveConsole):
password -- user's password
"""
return connect_internal(hostname, username, password, False,
- self._use_cache, self._verify_certificate)
+ self._use_cache, self._verify_server_cert)
# Initialize locals
if locals is None:
locals = {}
@@ -248,12 +248,12 @@ class LMIConsole(code.InteractiveConsole):
"""
readline.clear_history()
- def set_verify_certificate(self, verify_certificate=True):
+ def set_verify_server_certificate(self, verify_server_cert=True):
"""
Turns on or off server side certificate verification, if SSL used.
Arguments:
- verify_certificate -- flag indicating, whether a server side certificate
+ verify_server_cert -- flag indicating, whether a server side certificate
needs to be verified, if SSL used
"""
- self._verify_certificate = verify_certificate
+ self._verify_server_cert = verify_server_cert
diff --git a/cli/lmi/shell/LMIShellClient.py b/cli/lmi/shell/LMIShellClient.py
index 3b7b473..59e28ad 100644
--- a/cli/lmi/shell/LMIShellClient.py
+++ b/cli/lmi/shell/LMIShellClient.py
@@ -24,7 +24,7 @@ class LMIShellClient(LMIBaseClient):
This class overrides few methods due to caching.
"""
def __init__(self, hostname, username="", password="", interactive=False, use_cache=True, \
- conn_type=LMIBaseClient.CONN_TYPE_WBEM, verify_certificate=True):
+ conn_type=LMIBaseClient.CONN_TYPE_WBEM, verify_server_cert=True):
"""
Constructs a LMIShellClient object.
@@ -43,11 +43,11 @@ class LMIShellClient(LMIBaseClient):
LMIBaseClient.CONN_TYPE_PEGASUS_UDS -- applicable only for Tog-Pegasus
CIMOM, it uses unix socket for the connection; default value is
CONN_TYPE_WBEM
- verify_certificate -- flag indicating, whether a server side certificate
+ verify_server_cert -- flag indicating, whether a server side certificate
needs to be verified, if SSL used
"""
super(LMIShellClient, self).__init__(hostname, username, password, conn_type,
- verify_certificate)
+ verify_server_cert)
self._interactive = interactive
self._cache = LMIShellCache(use_cache)
diff --git a/cli/lmi/shell/LMIShellOptions.py b/cli/lmi/shell/LMIShellOptions.py
index 4c26839..74d9586 100644
--- a/cli/lmi/shell/LMIShellOptions.py
+++ b/cli/lmi/shell/LMIShellOptions.py
@@ -155,7 +155,7 @@ class LMIShellOptions(object):
return self._log
@property
- def verify_certificate(self):
+ def verify_server_cert(self):
"""
Property returning bool flag, which indicates, if LMIShell should verify
server side certificate, if SSL used.
diff --git a/cli/lmishell b/cli/lmishell
index b9ee4e6..e493af5 100755
--- a/cli/lmishell
+++ b/cli/lmishell
@@ -42,7 +42,7 @@ if __name__ == "__main__":
logger.addHandler(logging.StreamHandler(sys.stderr))
console = LMIConsole()
- console.set_verify_certificate(options.verify_certificate)
+ console.set_verify_server_certificate(options.verify_server_cert)
if options.interactive:
console.interact()
else:
10 years, 8 months
[cura-tools] master: added LMI_SoftwareVerificationJob to supported jobs (12c05af)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 12c05afd785932be33eae96d533abde1c031cdb5
Author: Michal Minar <miminar(a)redhat.com>
Date: Mon Sep 2 15:36:50 2013 +0200
added LMI_SoftwareVerificationJob to supported jobs
Allowed for asynchronous software verification method to be treated as a
synchronous one.
>---------------------------------------------------------------
cli/lmi/shell/LMIMethod.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index f93f04f..b863371 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -70,6 +70,7 @@ class LMIMethod(LMIWrapperBaseObject):
_INDICATION_JOB_CLASSNAMES = (
"LMI_StorageJob",
"LMI_SoftwareInstallationJob",
+ "LMI_SoftwareVerificationJob",
"LMI_NetworkJob"
)
# Default namespace where the indication subscriptions, used for synchronous
10 years, 8 months
[cura-tools] master: use NocaseDict instead of dict where appropriate (4f0c165)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 4f0c1651a5e58c99553e869a34378cb41dd9c12d
Author: Michal Minar <miminar(a)redhat.com>
Date: Mon Sep 2 15:34:59 2013 +0200
use NocaseDict instead of dict where appropriate
NocaseDict should be used for properties of instances, instance names
and output parameters of method to allow for case-insesitive
comparisons.
This fixes a bug, where job was not found in output parameters of
asynchronous method, when treating it as a synchronoush one.
>---------------------------------------------------------------
cli/lmi/shell/LMIInstance.py | 4 ++--
cli/lmi/shell/LMIInstanceName.py | 2 +-
cli/lmi/shell/LMIMethod.py | 8 +++++---
cli/lmi/shell/LMIReturnValue.py | 3 +++
cli/lmi/shell/LMIUtil.py | 22 +++++++---------------
5 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/cli/lmi/shell/LMIInstance.py b/cli/lmi/shell/LMIInstance.py
index 17646de..037b58a 100644
--- a/cli/lmi/shell/LMIInstance.py
+++ b/cli/lmi/shell/LMIInstance.py
@@ -553,8 +553,8 @@ class LMIInstance(LMIWrapperBaseObject):
Raised exceptions:
LMIDeletedObjectError
"""
- return dict(zip(self._cim_instance.properties.keys(),
- map(lambda x: x.value, self._cim_instance.properties.values())))
+ return pywbem.NocaseDict({
+ k: x.value for k, x in self._cim_instance.properties.iteritems()})
@lmi_possibly_deleted(None)
def property_value(self, prop_name):
diff --git a/cli/lmi/shell/LMIInstanceName.py b/cli/lmi/shell/LMIInstanceName.py
index b4dcc42..4285a1d 100644
--- a/cli/lmi/shell/LMIInstanceName.py
+++ b/cli/lmi/shell/LMIInstanceName.py
@@ -88,7 +88,7 @@ class LMIInstanceName(LMIWrapperBaseObject):
"""
Returns a dictionary with key properties and corresponding values.
"""
- return dict(self._cim_instance_name.items())
+ return self._cim_instance_name.keybindings.copy()
def key_property_value(self, prop_name):
"""
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index a5bad8d..f93f04f 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -115,9 +115,11 @@ class LMIMethod(LMIWrapperBaseObject):
# Adjust return value from the job object
if job_refresh:
job_inst.refresh()
- rparams = dict(zip(job_inst.JobOutParameters.properties.keys(),
- [x.value for x in job_inst.JobOutParameters.properties.values()]))
- rval = rparams.pop("__ReturnValue")
+ rparams = pywbem.NocaseDict({
+ k: x.value
+ for k, x in job_inst.JobOutParameters.properties.iteritems()})
+ rval = rparams["__ReturnValue"]
+ del rparams["__ReturnValue"] # NocaseDict has no pop()
errorstr = ""
# Is job in exception state? If so, adjust corresponding error string
diff --git a/cli/lmi/shell/LMIReturnValue.py b/cli/lmi/shell/LMIReturnValue.py
index 9203040..dd7966b 100644
--- a/cli/lmi/shell/LMIReturnValue.py
+++ b/cli/lmi/shell/LMIReturnValue.py
@@ -14,6 +14,7 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
import collections
+import pywbem
_RValue = collections.namedtuple('RValue', ["rval", "rparams", "errorstr"])
@@ -40,5 +41,7 @@ class LMIReturnValue(_RValue):
errorstr -- optional error string
"""
rparams = rparams if rparams else {}
+ if not isinstance(rparams, pywbem.NocaseDict):
+ rparams = pywbem.NocaseDict(rparams)
errorstr = errorstr if errorstr else ""
return _RValue.__new__(self, rval=rval, rparams=rparams, errorstr=errorstr)
diff --git a/cli/lmi/shell/LMIUtil.py b/cli/lmi/shell/LMIUtil.py
index 9f34d21..f536b80 100644
--- a/cli/lmi/shell/LMIUtil.py
+++ b/cli/lmi/shell/LMIUtil.py
@@ -135,11 +135,9 @@ def _lmi_do_cast(t, value, cast):
cast -- dictionary with type:cast_func
"""
cast_func = cast[t.lower()] if t.lower() in cast else lambda x: x
- if isinstance(value, dict):
- return dict(
- zip(value.keys()),
- map(lambda val: _lmi_do_cast(t, val, cast), value.values())
- )
+ if isinstance(value, (dict, pywbem.NocaseDict)):
+ return pywbem.NocaseDict({
+ k: _lmi_do_cast(t, val, cast) for k, val in value.iteritems()})
elif isinstance(value, list):
return map(lambda val: _lmi_do_cast(t, val, cast), value)
elif isinstance(value, tuple):
@@ -268,16 +266,10 @@ def lmi_transform_to_lmi(conn, value):
return int(value)
elif isinstance(value, pywbem.CIMFloat):
return float(value)
- elif isinstance(value, dict):
- return dict(
- zip(value.keys(),
- map(lambda val: lmi_transform_to_lmi(conn, val), value.values()))
- )
- elif isinstance(value, pywbem.NocaseDict):
- return pywbem.NocaseDict(
- zip(value.keys(),
- map(lambda val: lmi_transform_to_lmi(conn, val), value.values()))
- )
+ elif isinstance(value, (dict, pywbem.NocaseDict)):
+ return pywbem.NocaseDict({
+ k: lmi_transform_to_lmi(conn, val)
+ for k, val in value.iteritems()})
elif isinstance(value, list):
return map(lambda val: lmi_transform_to_lmi(conn, val), value)
elif isinstance(value, tuple):
10 years, 8 months