From 3709d0107651af42a1e81505ed47244bb75033ae Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Sat, 6 Jul 2013 14:33:36 +0200 Subject: software: using new Configuration and utility function using system_name, system_class_name and namespace values from SoftwareConfiguration object using new_instance_name from util module --- .../lmi/software/LMI_AffectedSoftwareJobElement.py | 4 +++- .../software/LMI_HostedSoftwareIdentityResource.py | 12 ++++-------- .../LMI_HostedSoftwareInstallationService.py | 5 +++-- .../lmi/software/LMI_InstalledSoftwareIdentity.py | 12 ++++-------- .../lmi/software/LMI_MemberOfSoftwareCollection.py | 12 ++++-------- .../software/LMI_ResourceForSoftwareIdentity.py | 13 ++++--------- .../lmi/software/LMI_SoftwareIdentityChecks.py | 6 ++---- ...MI_SoftwareInstallationServiceAffectsElement.py | 12 +++++------- src/software/lmi/software/cimom_entry.py | 4 +++- .../software/core/AffectedSoftwareJobElement.py | 5 ++--- src/software/lmi/software/core/ComputerSystem.py | 22 ++++++++++++---------- src/software/lmi/software/core/Error.py | 4 ++-- src/software/lmi/software/core/Identity.py | 3 +-- .../lmi/software/core/IdentityFileCheck.py | 3 +-- src/software/lmi/software/core/IdentityResource.py | 20 ++++++++++---------- src/software/lmi/software/core/InstMethodCall.py | 7 ++----- .../lmi/software/core/InstallationService.py | 14 +++++++------- .../core/InstallationServiceCapabilities.py | 7 +++---- src/software/lmi/software/core/Job.py | 4 ++-- src/software/lmi/software/core/MethodResult.py | 4 ++-- src/software/lmi/software/core/SystemCollection.py | 7 +++---- src/software/lmi/software/util/__init__.py | 4 ++-- 22 files changed, 81 insertions(+), 103 deletions(-) (limited to 'src/software') diff --git a/src/software/lmi/software/LMI_AffectedSoftwareJobElement.py b/src/software/lmi/software/LMI_AffectedSoftwareJobElement.py index 12e6a35..cbecd43 100644 --- a/src/software/lmi/software/LMI_AffectedSoftwareJobElement.py +++ b/src/software/lmi/software/LMI_AffectedSoftwareJobElement.py @@ -25,6 +25,7 @@ import pywbem from pywbem.cim_provider2 import CIMProvider2 from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import AffectedSoftwareJobElement from lmi.software.core import Job from lmi.software.yumdb import YumDB @@ -81,7 +82,8 @@ class LMI_AffectedSoftwareJobElement(CIMProvider2): model["OtherElementEffectsDescriptions"] = descriptions elif ch.is_subclass(affected.namespace, - sub=affected.classname, super='Linux_ComputerSystem'): + sub=affected.classname, + super=util.Configuration.get_instance().system_class_name): AffectedSoftwareJobElement.fill_model_computer_system( model, job, keys_only=False) diff --git a/src/software/lmi/software/LMI_HostedSoftwareIdentityResource.py b/src/software/lmi/software/LMI_HostedSoftwareIdentityResource.py index 767523a..1f2ce37 100644 --- a/src/software/lmi/software/LMI_HostedSoftwareIdentityResource.py +++ b/src/software/lmi/software/LMI_HostedSoftwareIdentityResource.py @@ -29,6 +29,7 @@ import pywbem from pywbem.cim_provider2 import CIMProvider2 from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import generate_references from lmi.software.core import ComputerSystem from lmi.software.core import IdentityResource @@ -40,11 +41,8 @@ def generate_system_referents(env, object_name, model, _keys_only): Handler for referents enumeration request. """ ComputerSystem.check_path(env, object_name, "Antecedent") - repomodel = pywbem.CIMInstanceName( - classname='LMI_SoftwareIdentityResource', - namespace='root/cimv2', - host=model.path.host) - model["Antecedent"] = ComputerSystem.get_path() + repomodel = util.new_instance_name('LMI_SoftwareIdentityResource', + Antecedent=ComputerSystem.get_path()) for repo in YumDB.get_instance().get_repository_list('all'): model["Dependent"] = IdentityResource.repo2model(repo, model=repomodel) yield model @@ -147,9 +145,7 @@ class LMI_HostedSoftwareIdentityResource(CIMProvider2): repolist = YumDB.get_instance().get_repository_list('all') model["Antecedent"] = ComputerSystem.get_path() - repomodel = pywbem.CIMInstanceName( - classname='LMI_SoftwareIdentityResource', - namespace='root/cimv2') + repomodel = util.new_instance_name('LMI_SoftwareIdentityResource') for repo in repolist: model["Dependent"] = IdentityResource.repo2model( repo, model=repomodel) diff --git a/src/software/lmi/software/LMI_HostedSoftwareInstallationService.py b/src/software/lmi/software/LMI_HostedSoftwareInstallationService.py index 5c650cb..e51111c 100644 --- a/src/software/lmi/software/LMI_HostedSoftwareInstallationService.py +++ b/src/software/lmi/software/LMI_HostedSoftwareInstallationService.py @@ -30,6 +30,7 @@ import pywbem from pywbem.cim_provider2 import CIMProvider2 from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import ComputerSystem, InstallationService class LMI_HostedSoftwareInstallationService(CIMProvider2): @@ -227,7 +228,7 @@ class LMI_HostedSoftwareInstallationService(CIMProvider2): sub=object_name.classname, super='LMI_SoftwareInstallationService') or \ ch.is_subclass(object_name.namespace, - sub=object_name.classname, - super='Linux_ComputerSystem'): + sub=object_name.classname, + super=util.Configuration.get_instance().system_class_name): return self.simple_refs(env, object_name, model, result_class_name, role, result_role, keys_only) diff --git a/src/software/lmi/software/LMI_InstalledSoftwareIdentity.py b/src/software/lmi/software/LMI_InstalledSoftwareIdentity.py index 429a7a2..fada7a9 100644 --- a/src/software/lmi/software/LMI_InstalledSoftwareIdentity.py +++ b/src/software/lmi/software/LMI_InstalledSoftwareIdentity.py @@ -29,6 +29,7 @@ import pywbem from pywbem.cim_provider2 import CIMProvider2 from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import generate_references from lmi.software.core import ComputerSystem from lmi.software.core import Identity @@ -41,11 +42,8 @@ def generate_system_referents(env, object_name, model, _keys_only): """ ComputerSystem.check_path(env, object_name, "object_name") - pkg_model = pywbem.CIMInstanceName( - classname='LMI_SoftwareIdentity', - namespace="root/cimv2", - host=model.path.host) - model["System"] = ComputerSystem.get_path() + pkg_model = util.new_instance_name('LMI_SoftwareIdentity', + System=ComputerSystem.get_path()) with YumDB.get_instance() as ydb: for pkg_info in ydb.get_package_list('installed', sort=True): model["InstalledSoftware"] = Identity.pkg2model( @@ -137,9 +135,7 @@ class LMI_InstalledSoftwareIdentity(CIMProvider2): model.path.update({'InstalledSoftware': None, 'System': None}) model['System'] = ComputerSystem.get_path() - inst_model = pywbem.CIMInstanceName( - classname="LMI_SoftwareIdentity", - namespace="root/cimv2") + inst_model = util.new_instance_name("LMI_SoftwareIdentity") with YumDB.get_instance() as yb: pl = yb.get_package_list('installed', sort=True) for pkg in pl: diff --git a/src/software/lmi/software/LMI_MemberOfSoftwareCollection.py b/src/software/lmi/software/LMI_MemberOfSoftwareCollection.py index f66f788..8011b37 100644 --- a/src/software/lmi/software/LMI_MemberOfSoftwareCollection.py +++ b/src/software/lmi/software/LMI_MemberOfSoftwareCollection.py @@ -25,6 +25,7 @@ import pywbem from pywbem.cim_provider2 import CIMProvider2 from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import generate_references from lmi.software.core import SystemCollection from lmi.software.core import Identity @@ -36,11 +37,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 = pywbem.CIMInstanceName( - classname='LMI_SoftwareIdentity', - namespace="root/cimv2", - host=model.path.host) - model["Collection"] = SystemCollection.get_path() + pkg_model = util.new_instance_name('LMI_SoftwareIdentity', + Collection=SystemCollection.get_path()) with YumDB.get_instance() as ydb: for pkg_info in ydb.get_package_list('available', allow_duplicates=True, sort=True): @@ -145,9 +143,7 @@ class LMI_MemberOfSoftwareCollection(CIMProvider2): model.path.update({'Member': None, 'Collection': None}) model['Collection'] = SystemCollection.get_path() - member_model = pywbem.CIMInstanceName( - classname="LMI_SoftwareIdentity", - namespace="root/cimv2") + member_model = util.new_instance_name("LMI_SoftwareIdentity") with YumDB.get_instance() as yb: pl = yb.get_package_list('available', allow_duplicates=True, diff --git a/src/software/lmi/software/LMI_ResourceForSoftwareIdentity.py b/src/software/lmi/software/LMI_ResourceForSoftwareIdentity.py index ca22337..ca125ad 100644 --- a/src/software/lmi/software/LMI_ResourceForSoftwareIdentity.py +++ b/src/software/lmi/software/LMI_ResourceForSoftwareIdentity.py @@ -25,6 +25,7 @@ import pywbem from pywbem.cim_provider2 import CIMProvider2 from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import generate_references from lmi.software.core import Identity from lmi.software.core import IdentityResource @@ -61,9 +62,7 @@ def generate_repository_referents(env, object_name, model, _keys_only): include_repos=repo.repoid, exclude_repos='*') model['AvailableSAP'] = IdentityResource.repo2model(repo) - pkg_model = pywbem.CIMInstanceName( - classname="LMI_SoftwareIdentity", - namespace="root/cimv2") + pkg_model = util.new_instance_name("LMI_SoftwareIdentity") for pkg_info in pkglist: model["ManagedElement"] = Identity.pkg2model( pkg_info, model=pkg_model) @@ -167,12 +166,8 @@ class LMI_ResourceForSoftwareIdentity(CIMProvider2): # we set property values on the model. model.path.update({'ManagedElement': None, 'AvailableSAP': None}) - elem_model = pywbem.CIMInstanceName( - classname="LMI_SoftwareIdentity", - namespace="root/cimv2") - sap_model = pywbem.CIMInstanceName( - classname="LMI_SoftwareIdentityResource", - namespace="root/cimv2") + elem_model = util.new_instance_name("LMI_SoftwareIdentity") + sap_model = util.new_instance_name("LMI_SoftwareIdentityResource") # maps repoid to instance name with YumDB.get_instance() as ydb: pl = ydb.get_package_list('available', diff --git a/src/software/lmi/software/LMI_SoftwareIdentityChecks.py b/src/software/lmi/software/LMI_SoftwareIdentityChecks.py index 47ae3f4..3bbf840 100644 --- a/src/software/lmi/software/LMI_SoftwareIdentityChecks.py +++ b/src/software/lmi/software/LMI_SoftwareIdentityChecks.py @@ -29,6 +29,7 @@ import pywbem from pywbem.cim_provider2 import CIMProvider2 from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import generate_references from lmi.software.core import Identity, IdentityFileCheck from lmi.software.yumdb import YumDB @@ -38,10 +39,7 @@ def generate_identity_referents(_env, object_name, model, _keys_only): Handler for referents enumeration request enumerating file checks associated to software identity. """ - filecheck_model = pywbem.CIMInstanceName( - classname='LMI_SoftwareIdentityFileCheck', - namespace="root/cimv2", - host=model.path.host) + filecheck_model = util.new_instance_name('LMI_SoftwareIdentityFileCheck') pkg_info = Identity.object_path2pkg( object_name, kind="installed") model['Element'] = Identity.pkg2model(pkg_info) diff --git a/src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py b/src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py index 92d5c26..bcca992 100644 --- a/src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py +++ b/src/software/lmi/software/LMI_SoftwareInstallationServiceAffectsElement.py @@ -25,6 +25,7 @@ import pywbem from pywbem.cim_provider2 import CIMProvider2 from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import ComputerSystem from lmi.software.core import Identity from lmi.software.core import InstallationService @@ -40,9 +41,7 @@ def generate_service_referents(env, model, object_name, keys_only): model, keys_only=keys_only) yield model - avail_model = pywbem.CIMInstanceName( - classname="LMI_SoftwareIdentity", - namespace="root/cimv2") + 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, @@ -100,7 +99,8 @@ class LMI_SoftwareInstallationServiceAffectsElement(CIMProvider2): InstallationServiceAffectsElement.fill_model_identity( model, pkg_info, keys_only=False) elif ch.is_subclass(affected.namespace, - sub=affected.classname, super='Linux_ComputerSystem'): + sub=affected.classname, + super=util.Configuration.get_instance().system_class_name): InstallationServiceAffectsElement.fill_model_computer_system( model, keys_only=False) else: @@ -141,9 +141,7 @@ class LMI_SoftwareInstallationServiceAffectsElement(CIMProvider2): model, keys_only=keys_only) yield model - avail_model = pywbem.CIMInstanceName( - classname="LMI_SoftwareIdentity", - namespace="root/cimv2") + 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, keys_only=keys_only, diff --git a/src/software/lmi/software/cimom_entry.py b/src/software/lmi/software/cimom_entry.py index 9e7d4f4..7c8e15e 100644 --- a/src/software/lmi/software/cimom_entry.py +++ b/src/software/lmi/software/cimom_entry.py @@ -28,6 +28,7 @@ from multiprocessing import Queue from lmi.common import cmpi_logging from lmi.common import JobManager from lmi.common.IndicationManager import IndicationManager +from lmi.software import util from lmi.software.core import Job from lmi.software.LMI_SoftwareIdentity import LMI_SoftwareIdentity from lmi.software.LMI_SystemSoftwareCollection import \ @@ -116,7 +117,8 @@ def get_providers(env): # Initialization of indication manager -- running in separate thread as # daemon. That means it does not have to be cleaned up. im = IndicationManager.get_instance( - env, "Software", "root/cimv2", queue=Queue()) + env, "Software", util.Configuration.get_instance().namespace, + queue=Queue()) JobManager.register_filters("LMI_SoftwareInstallationJob", im) JobManager.register_filters("LMI_SoftwareVerificationJob", im) diff --git a/src/software/lmi/software/core/AffectedSoftwareJobElement.py b/src/software/lmi/software/core/AffectedSoftwareJobElement.py index 90014eb..b245166 100644 --- a/src/software/lmi/software/core/AffectedSoftwareJobElement.py +++ b/src/software/lmi/software/core/AffectedSoftwareJobElement.py @@ -97,7 +97,7 @@ def check_path(env, op): SystemCollection.check_path(env, affected, "AffectedElement") affected = SystemCollection.get_path() elif ch.is_subclass(affected.namespace, sub=affected.classname, - super='Linux_ComputerSystem'): + super=util.Configuration.get_instance().system_class_name): ComputerSystem.check_path(env, affected, "AffectedElement") affected = ComputerSystem.get_path() elif ch.is_subclass(affected.namespace, sub=affected.classname, @@ -239,8 +239,7 @@ def generate_models_from_job(job, keys_only=True, model=None): if not isinstance(job, jobs.YumJob): raise TypeError("pkg must be an instance of PackageInfo or nevra") if model is None: - model = pywbem.CIMInstanceName("LMI_AffectedSoftwareJobElement", - namespace="root/cimv2") + model = util.new_instance_name("LMI_AffectedSoftwareJobElement") if not keys_only: model = pywbem.CIMInstance("LMI_AffectedSoftwareJobElement", path=model) diff --git a/src/software/lmi/software/core/ComputerSystem.py b/src/software/lmi/software/core/ComputerSystem.py index 53c0738..fe341d7 100644 --- a/src/software/lmi/software/core/ComputerSystem.py +++ b/src/software/lmi/software/core/ComputerSystem.py @@ -17,23 +17,25 @@ # along with this program. If not, see . """ -Just a common functionality related to associated class Linux_ComputerSystem. +Just a common functionality related to associated class CIM_ComputerSystem. """ import pywbem -import socket from lmi.common import cmpi_logging +from lmi.software import util -def get_path(prefix='Linux'): +def get_path(prefix=None): """ - @return object path of Linux_ComputerSystem + @return object path of CIM_ComputerSystem """ - op = pywbem.CIMInstanceName( - classname='%s_ComputerSystem' % prefix, - namespace="root/cimv2") - op["CreationClassName"] = "Linux_ComputerSystem" - op["Name"] = socket.gethostname() + if prefix is None: + classname = util.Configuration.get_instance().system_class_name + else: + classname = '%s_ComputerSystem' % prefix + op = util.new_instance_name(classname, + CreationClassName=classname, + Name=util.Configuration.get_instance().system_name) return op @cmpi_logging.trace_function @@ -77,7 +79,7 @@ def check_path(env, system, prop_name): def check_path_property(env, op, prop_name): """ Checks, whether object path contains correct instance name of - Linux_ComputerSystem corresponding to this system. + CIM_ComputerSystem corresponding to this system. If not, an exception is raised. """ if not prop_name in op: diff --git a/src/software/lmi/software/core/Error.py b/src/software/lmi/software/core/Error.py index d36ebb0..0acb155 100644 --- a/src/software/lmi/software/core/Error.py +++ b/src/software/lmi/software/core/Error.py @@ -23,6 +23,7 @@ Just a common functionality related to class CIM_Error. import pywbem from lmi.common import cmpi_logging +from lmi.software import util class Values(object): class ErrorSourceFormat(object): @@ -436,8 +437,7 @@ def make_instance( raise TypeError('error_source must be a CIMInstanceName') inst = pywbem.CIMInstance(classname="CIM_Error", - path=pywbem.CIMInstanceName(classname="CIM_Error", - namespace="root/cimv2")) + path=util.new_instance_name("CIM_Error")) inst['CIMStatusCode'] = pywbem.Uint32(status_code) if status_code_description is not None: inst['CIMStatusCodeDescription'] = status_code_description diff --git a/src/software/lmi/software/core/Identity.py b/src/software/lmi/software/core/Identity.py index 2df43a9..7f16f93 100644 --- a/src/software/lmi/software/core/Identity.py +++ b/src/software/lmi/software/core/Identity.py @@ -236,8 +236,7 @@ def pkg2model(pkg, keys_only=True, model=None): if isinstance(pkg, basestring) and not keys_only: raise ValueError("can not create instance out of nevra") if model is None: - model = pywbem.CIMInstanceName("LMI_SoftwareIdentity", - namespace="root/cimv2") + model = util.new_instance_name("LMI_SoftwareIdentity") if not keys_only: model = pywbem.CIMInstance("LMI_SoftwareIdentity", path=model) nevra = pkg if isinstance(pkg, basestring) else pkg.nevra diff --git a/src/software/lmi/software/core/IdentityFileCheck.py b/src/software/lmi/software/core/IdentityFileCheck.py index 665d822..cc8204e 100644 --- a/src/software/lmi/software/core/IdentityFileCheck.py +++ b/src/software/lmi/software/core/IdentityFileCheck.py @@ -939,8 +939,7 @@ def file_check2model(file_check, keys_only=True, model=None, job=None): raise TypeError("file_check must be an instance of FileCheck") if model is None: - model = pywbem.CIMInstanceName("LMI_SoftwareIdentityFileCheck", - namespace="root/cimv2") + model = util.new_instance_name("LMI_SoftwareIdentityFileCheck") if not keys_only: model = pywbem.CIMInstance("LMI_SoftwareIdentityFileCheck", path=model) diff --git a/src/software/lmi/software/core/IdentityResource.py b/src/software/lmi/software/core/IdentityResource.py index 228015b..392dac7 100644 --- a/src/software/lmi/software/core/IdentityResource.py +++ b/src/software/lmi/software/core/IdentityResource.py @@ -20,10 +20,9 @@ Just a common functionality related to LMI_SoftwareIdentityResource provider. """ import pywbem -import socket from lmi.common import cmpi_logging -from lmi.software.core import ComputerSystem +from lmi.software import util from lmi.software.yumdb import YumDB from lmi.software.yumdb.repository import Repository @@ -518,18 +517,19 @@ def object_path2repo(env, op, kind='enabled'): or not op["SystemCreationClassName"]) or (not "SystemName" in op or not op["SystemName"])): raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "Wrong keys.") - if op["SystemName"] != socket.gethostname(): + if op["SystemName"] != util.Configuration().system_name: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND, 'SystemName "%s" does not match "%s".' % ( - op["SystemName"], socket.gethostname())) + op["SystemName"], + util.Configuration.get_instance().system_name)) ch = env.get_cimom_handle() - if not ch.is_subclass("root/cimv2", + if not ch.is_subclass(util.Configuration.get_instance().namespace, sub=op["CreationClassName"], super="CIM_SoftwareIdentityResource"): raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, 'CreationClassName \"%s\" must be a subclass of "%s".' % ( op["CreationClassName"], "CIM_SoftwareIdentityResource")) - if not ch.is_subclass("root/cimv2", + if not ch.is_subclass(util.Configuration.get_instance().namespace, sub=op["SystemCreationClassName"], super="CIM_ComputerSystem"): raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, @@ -627,8 +627,7 @@ def repo2model(repo, keys_only=True, model=None): if not isinstance(repo, Repository): raise TypeError("pkg must be an instance of Repository") if model is None: - model = pywbem.CIMInstanceName("LMI_SoftwareIdentityResource", - namespace="root/cimv2") + model = util.new_instance_name("LMI_SoftwareIdentityResource") if not keys_only: model = pywbem.CIMInstance( "LMI_SoftwareIdentityResource", path=model) @@ -641,8 +640,9 @@ def repo2model(repo, keys_only=True, model=None): _set_key = model.__setitem__ _set_key('CreationClassName', "LMI_SoftwareIdentityResource") _set_key("Name", repo.repoid) - _set_key("SystemCreationClassName", "Linux_ComputerSystem") - _set_key("SystemName", ComputerSystem.get_path()["Name"]) + _set_key("SystemCreationClassName", + util.Configuration.get_instance().system_class_name) + _set_key("SystemName", util.Configuration.get_instance().system_name) if not keys_only: _fill_non_keys(repo, model) diff --git a/src/software/lmi/software/core/InstMethodCall.py b/src/software/lmi/software/core/InstMethodCall.py index 82b7b1e..061c0e1 100644 --- a/src/software/lmi/software/core/InstMethodCall.py +++ b/src/software/lmi/software/core/InstMethodCall.py @@ -21,9 +21,9 @@ CIM values for enumeration types of CIM_InstMethodCall indication class. """ import pywbem -import socket from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import Job from lmi.software.core import InstallationService from lmi.software.yumdb import jobs, errors @@ -102,10 +102,7 @@ def job2model(job, pre=True): if not pre and job.state == job.NEW or job.state == job.RUNNING: raise ValueError("job must be finished to make a post indication" " instance") - path = pywbem.CIMInstanceName( - classname="CIM_InstMethodCall", - host=socket.gethostname(), - namespace="root/cimv2") + path = util.new_instance_name("CIM_InstMethodCall") inst = pywbem.CIMInstance(classname="CIM_InstMethodCall", path=path) src_instance = Job.job2model(job, keys_only=False) inst['SourceInstance'] = pywbem.CIMProperty("SourceInstance", diff --git a/src/software/lmi/software/core/InstallationService.py b/src/software/lmi/software/core/InstallationService.py index 557f913..3eb391c 100644 --- a/src/software/lmi/software/core/InstallationService.py +++ b/src/software/lmi/software/core/InstallationService.py @@ -24,6 +24,7 @@ provider. import pywbem from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import ComputerSystem from lmi.software.core import Identity from lmi.software.core import Job @@ -558,14 +559,13 @@ class Values(object): def get_path(): """@return instance name with prefilled properties""" - op = pywbem.CIMInstanceName( - classname="LMI_SoftwareInstallationService", - namespace="root/cimv2") - op['CreationClassName'] = op.classname systemop = ComputerSystem.get_path() - op["SystemCreationClassName"] = systemop.classname - op['SystemName'] = systemop["Name"] - op["Name"] = "LMI:LMI_SoftwareInstallationService" + clsname = "LMI_SoftwareInstallationService" + op = util.new_instance_name(clsname, + CreationClassName=clsname, + SystemCreationClassName=systemop.classname, + SystemName=systemop["Name"], + Name="LMI:LMI_SoftwareInstallationService") return op @cmpi_logging.trace_function diff --git a/src/software/lmi/software/core/InstallationServiceCapabilities.py b/src/software/lmi/software/core/InstallationServiceCapabilities.py index 62209bf..0de4416 100644 --- a/src/software/lmi/software/core/InstallationServiceCapabilities.py +++ b/src/software/lmi/software/core/InstallationServiceCapabilities.py @@ -24,6 +24,7 @@ LMI_SoftwareInstallationServiceCapabilities provider. import pywbem from lmi.common import cmpi_logging +from lmi.software import util class Values(object): class SupportedExtendedResourceTypes(object): @@ -144,10 +145,8 @@ class Values(object): @cmpi_logging.trace_function def get_path(): """@return instance name with prefilled properties""" - op = pywbem.CIMInstanceName( - classname="LMI_SoftwareInstallationServiceCapabilities", - namespace="root/cimv2") - op['InstanceID'] = "LMI:LMI_SoftwareInstallationServiceCapabilities" + op = util.new_instance_name("LMI_SoftwareInstallationServiceCapabilities", + InstanceID="LMI:LMI_SoftwareInstallationServiceCapabilities") return op @cmpi_logging.trace_function diff --git a/src/software/lmi/software/core/Job.py b/src/software/lmi/software/core/Job.py index 4a7753a..a19bf02 100644 --- a/src/software/lmi/software/core/Job.py +++ b/src/software/lmi/software/core/Job.py @@ -468,7 +468,7 @@ def make_method_params(job, class_name, include_input, include_output): # TODO: this is workaround for bug #920763, use class_name # when it's fixed clsname = "CIM_ManagedElement" - path = pywbem.CIMInstanceName(classname=clsname, namespace="root/cimv2") + path = util.new_instance_name(clsname) inst = pywbem.CIMInstance(classname=clsname, path=path) if include_input and "input_params" in job.metadata: for (name, value) in job.metadata["input_params"].items(): @@ -613,7 +613,7 @@ def job2model(job, class_name=None, keys_only=True, model=None): "class_name not supplied for jobid=%d, using general" " LMI_SoftwareJob as CIM class name") if model is None: - model = pywbem.CIMInstanceName(class_name, namespace="root/cimv2") + model = util.new_instance_name(class_name) if not keys_only: model = pywbem.CIMInstance(class_name, path=model) diff --git a/src/software/lmi/software/core/MethodResult.py b/src/software/lmi/software/core/MethodResult.py index 47eb7ca..780772a 100644 --- a/src/software/lmi/software/core/MethodResult.py +++ b/src/software/lmi/software/core/MethodResult.py @@ -23,6 +23,7 @@ Just a common functionality related to class LMI_SoftwareMethodResult. import pywbem from lmi.common import cmpi_logging +from lmi.software import util from lmi.software.core import Job from lmi.software.core import InstMethodCall from lmi.software.yumdb import jobs, errors, YumDB @@ -64,8 +65,7 @@ def job2model(job, keys_only=True, model=None): if not isinstance(job, jobs.YumJob): raise TypeError("job must be an instance of YumJob") if model is None: - model = pywbem.CIMInstanceName("LMI_SoftwareMethodResult", - namespace="root/cimv2") + model = util.new_instance_name("LMI_SoftwareMethodResult") if not keys_only: model = pywbem.CIMInstance("LMI_SoftwareMethodResult", path=model) model['InstanceID'] = "LMI:LMI_SoftwareMethodResult:"+str(job.jobid) diff --git a/src/software/lmi/software/core/SystemCollection.py b/src/software/lmi/software/core/SystemCollection.py index 6596d40..0985ea4 100644 --- a/src/software/lmi/software/core/SystemCollection.py +++ b/src/software/lmi/software/core/SystemCollection.py @@ -22,13 +22,12 @@ Common utilities concerning SystemSoftwareCollection provider. import pywbem from lmi.common import cmpi_logging +from lmi.software import util def get_path(): """@return instance name with prefilled properties""" - op = pywbem.CIMInstanceName( - classname="LMI_SystemSoftwareCollection", - namespace="root/cimv2") - op['InstanceID'] = "LMI:LMI_SystemSoftwareCollection" + op = util.new_instance_name("LMI_SystemSoftwareCollection", + InstanceID="LMI:LMI_SystemSoftwareCollection") return op @cmpi_logging.trace_function diff --git a/src/software/lmi/software/util/__init__.py b/src/software/lmi/software/util/__init__.py index a9047d9..fad9bcd 100644 --- a/src/software/lmi/software/util/__init__.py +++ b/src/software/lmi/software/util/__init__.py @@ -182,9 +182,9 @@ def new_instance_name(class_name, namespace=None, **kwargs): """ keybindings = pywbem.NocaseDict(kwargs) if namespace is None: - namespace = Configuration().namespace + namespace = Configuration.get_instance().namespace return pywbem.CIMInstanceName( class_name, - host=Configuration().system_name, + host=Configuration.get_instance().system_name, namespace=namespace, keybindings=keybindings) -- cgit