summaryrefslogtreecommitdiffstats
path: root/src/software
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-11-27 15:38:17 +0100
committerMichal Minar <miminar@redhat.com>2013-11-27 15:58:15 +0100
commit920ca0fe6f6c92870b9e604030219d06f3d3f616 (patch)
tree5b79b4e9e7fc8a4e195f6fc714c25f09f161aa4b /src/software
parent3061b44c910d37789461924867d5b4899822f82c (diff)
downloadopenlmi-providers-920ca0fe6f6c92870b9e604030219d06f3d3f616.tar.gz
openlmi-providers-920ca0fe6f6c92870b9e604030219d06f3d3f616.tar.xz
openlmi-providers-920ca0fe6f6c92870b9e604030219d06f3d3f616.zip
software: fixed and speeded up another associator call
Associators generator of LMI_MemberOfSoftwareCollection is broken. It adds Collection property to genereted instance names of LMI_SoftwareIdentity. Moreover its very slow if instances are requested. This patch removes superfluous key property and adds optimizations reducing its execution time to seconds. Resolves: rhbz#1035328
Diffstat (limited to 'src/software')
-rw-r--r--src/software/lmi/software/LMI_MemberOfSoftwareCollection.py59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/software/lmi/software/LMI_MemberOfSoftwareCollection.py b/src/software/lmi/software/LMI_MemberOfSoftwareCollection.py
index 9d99d5f..64cb001 100644
--- a/src/software/lmi/software/LMI_MemberOfSoftwareCollection.py
+++ b/src/software/lmi/software/LMI_MemberOfSoftwareCollection.py
@@ -38,8 +38,8 @@ def generate_collection_referents(env, object_name, model, _keys_only):
Handler for referents enumeration request.
"""
SystemCollection.check_path(env, object_name, "collection")
- pkg_model = util.new_instance_name('LMI_SoftwareIdentity',
- Collection=SystemCollection.get_path())
+ model["Collection"] = SystemCollection.get_path()
+ pkg_model = util.new_instance_name('LMI_SoftwareIdentity')
with YumDB.get_instance() as ydb:
for pkg_info in ydb.get_package_list('available',
allow_duplicates=True, sort=True):
@@ -206,6 +206,61 @@ class LMI_MemberOfSoftwareCollection(CIMProvider2):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
@cmpi_logging.trace_method
+ def MI_associators(self,
+ env,
+ objectName,
+ assocClassName,
+ resultClassName,
+ role,
+ resultRole,
+ propertyList):
+ """
+ Yields available identities associated to ``ComputerSystem`` instance.
+
+ This overrides method of superclass for a very good reason. Original
+ method calls ``GetInstance()`` on every single object path returned by
+ :py:meth:`LMI_MemberOfSoftwareCollection.references` which is very time
+ consuming operation on ``LMI_SoftwareIdentity`` class in particular.
+ On slow machine this could take several minutes. This method just
+ enumerates requested instances directly.
+ """
+ ns = util.Configuration.get_instance().namespace
+ ch = env.get_cimom_handle()
+ if ( (not role or role.lower() == "collection")
+ and (not resultRole or resultRole.lower() == "member")
+ and ch.is_subclass(ns,
+ sub=objectName.classname,
+ super="CIM_ComputerSystem")):
+ try:
+ ComputerSystem.check_path(env, objectName, 'ObjectName')
+ except pywbem.CIMError as e:
+ if e.args[0] != pywbem.CIM_ERR_NOT_FOUND:
+ raise
+ raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER,
+ e.args[1])
+
+ model = pywbem.CIMInstance(classname='LMI_SoftwareIdentity')
+ model.path = util.new_instance_name('LMI_SoftwareIdentity')
+ with YumDB.get_instance() as ydb:
+ pkglist = ydb.get_package_list('available',
+ allow_duplicates=True, sort=True)
+ for pkg_info in pkglist:
+ yield Identity.pkg2model(pkg_info,
+ keys_only=False, model=model)
+
+ else:
+ # no need to optimize associators for SoftwareIdentity
+ for obj in CIMProvider2.MI_associators(self,
+ env,
+ objectName,
+ assocClassName,
+ resultClassName,
+ role,
+ resultRole,
+ propertyList):
+ yield obj
+
+ @cmpi_logging.trace_method
def references(self, env, object_name, model, result_class_name, role,
result_role, keys_only):
"""Instrument Associations.