summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-07-06 13:42:31 +0200
committerMichal Minar <miminar@redhat.com>2013-07-23 13:52:34 +0200
commitb7dcdd646832cf613d8faa85b55bcc37681fb4d3 (patch)
tree7189d1d8e0b7d5a67d8191b29ccff1fb38e7994d /src
parentf882972d9ac5cf87584c164953baa964c24caaff (diff)
downloadopenlmi-providers-b7dcdd646832cf613d8faa85b55bcc37681fb4d3.tar.gz
openlmi-providers-b7dcdd646832cf613d8faa85b55bcc37681fb4d3.tar.xz
openlmi-providers-b7dcdd646832cf613d8faa85b55bcc37681fb4d3.zip
software: added utility function for instance name creation
Diffstat (limited to 'src')
-rw-r--r--src/software/lmi/software/util/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/software/lmi/software/util/__init__.py b/src/software/lmi/software/util/__init__.py
index d92fd7c..a9047d9 100644
--- a/src/software/lmi/software/util/__init__.py
+++ b/src/software/lmi/software/util/__init__.py
@@ -24,8 +24,11 @@
"""
import platform
+import pywbem
import re
import signal
+from lmi.software.util.SoftwareConfiguration \
+ import SoftwareConfiguration as Configuration
RE_INSTANCE_ID = re.compile(r'LMI:(?P<clsname>[a-z][a-z_0-9]+):(?P<id>\d+)',
re.IGNORECASE)
@@ -168,3 +171,20 @@ def get_signal_name(signal_num):
except KeyError:
return "UNKNOWN_SIGNAL(%d)" % signal_num
+def new_instance_name(class_name, namespace=None, **kwargs):
+ """
+ Create new CIMInstanceName with provided attributes.
+
+ :param class_name: (``str``) Name of CIM Class that will be instantiated.
+ :param namespace: (``str``) Target CIM namespace.
+ :param kwargs: (``dict``) Key properties with associated values.
+ :rtype: (``pywbem.CIMInstanceName``) New object path.
+ """
+ keybindings = pywbem.NocaseDict(kwargs)
+ if namespace is None:
+ namespace = Configuration().namespace
+ return pywbem.CIMInstanceName(
+ class_name,
+ host=Configuration().system_name,
+ namespace=namespace,
+ keybindings=keybindings)