summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py58
1 files changed, 56 insertions, 2 deletions
diff --git a/src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py b/src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py
index ddc9b32..b0294f2 100644
--- a/src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py
+++ b/src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py
@@ -46,8 +46,7 @@ def generate_service_referents(env, model, object_name, keys_only):
avail_model = util.new_instance_name("LMI_SoftwareIdentity")
for pkg_info in YumDB.get_instance().get_package_list('available'):
- model["AffectedElement"] = InstallationServiceAffectsElement. \
- fill_model_identity(model, pkg_info,
+ InstallationServiceAffectsElement.fill_model_identity(model, pkg_info,
keys_only=keys_only,
identity_model=avail_model)
yield model
@@ -199,6 +198,61 @@ class LMI_SoftwareInstallationServiceAffectsElement(CIMProvider2):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
@cmpi_logging.trace_method
+ def MI_associators(self,
+ env,
+ objectName,
+ assocClassName,
+ resultClassName,
+ role,
+ resultRole,
+ propertyList):
+ """
+ Yield instances associated to ``SostwareInstallationService``
+ 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_SoftwareInstallationServiceAffectsElement.references`
+ which is very time consuming operation on ``LMI_SoftwareIdentity``
+ class in particular. On slow machine this could take several minutes.
+ This method enumerates requested instances directly.
+ """
+ ns = util.Configuration.get_instance().namespace
+ ch = env.get_cimom_handle()
+ if ( (not role or role.lower() == "affectingelement")
+ and (not resultRole or resultRole.lower() == "affectedelement")
+ and ch.is_subclass(ns,
+ sub=objectName.classname,
+ super="LMI_SoftwareInstallationService")):
+ try:
+ InstallationService.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', 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.