summaryrefslogtreecommitdiffstats
path: root/src/software/lmi/software/LMI_MemberOfSoftwareCollection.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/software/lmi/software/LMI_MemberOfSoftwareCollection.py')
-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.