diff options
author | Michal Minar <miminar@redhat.com> | 2013-11-26 10:52:52 +0100 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2013-11-27 15:58:15 +0100 |
commit | 3061b44c910d37789461924867d5b4899822f82c (patch) | |
tree | 4c38152f692a70be1b9c53e7e0c8f3efe41d85c1 /src/software | |
parent | d0f5744e3593b766fe6388367f20c97356d94dea (diff) | |
download | openlmi-providers-3061b44c910d37789461924867d5b4899822f82c.tar.gz openlmi-providers-3061b44c910d37789461924867d5b4899822f82c.tar.xz openlmi-providers-3061b44c910d37789461924867d5b4899822f82c.zip |
software: fixed and speeded up associator call
Associators generator of LMI_SoftwareIdentityServiceAffectsElement is
broken. It generates only CIM_ComputerSystem, not any
LMI_SoftwareIdentity instance. And if it did, it would be too slow (tens
of minutes). This patch allows software identities to be generated and
adds optimizations reducing its execution time to seconds.
Resolves: rhbz#1034698
Diffstat (limited to 'src/software')
-rw-r--r-- | src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py | 58 |
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. |