diff options
author | Michal Minar <miminar@redhat.com> | 2013-05-10 13:49:31 +0200 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2013-05-10 13:49:31 +0200 |
commit | 53aed1bf202d69b1ed717dc707c75533c73a06a6 (patch) | |
tree | c139c0e0606422d2edd2f1669289fbf567dfcd42 /src/software/openlmi/software/core/InstallationJob.py | |
parent | be2b9c7f7530b6c5c31de4878092fd1e655fc033 (diff) | |
parent | 8640b6f00b259df2371a1181f434f5d841fcf207 (diff) | |
download | openlmi-providers-53aed1bf202d69b1ed717dc707c75533c73a06a6.tar.gz openlmi-providers-53aed1bf202d69b1ed717dc707c75533c73a06a6.tar.xz openlmi-providers-53aed1bf202d69b1ed717dc707c75533c73a06a6.zip |
Merge branch 'software-indications'
Diffstat (limited to 'src/software/openlmi/software/core/InstallationJob.py')
-rw-r--r-- | src/software/openlmi/software/core/InstallationJob.py | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/src/software/openlmi/software/core/InstallationJob.py b/src/software/openlmi/software/core/InstallationJob.py index 7b06be2..e90ad1b 100644 --- a/src/software/openlmi/software/core/InstallationJob.py +++ b/src/software/openlmi/software/core/InstallationJob.py @@ -44,6 +44,18 @@ JOB_DESCRIPTIONS = { 'Software package installation job %(jobid)d from uri: "%(uri)s".', } +# identificators of InstallationService method, which may trigger +# creation of asynchronous job +( JOB_METHOD_INSTALL_FROM_SOFTWARE_IDENTITY +, JOB_METHOD_INSTALL_FROM_URI +, JOB_METHOD_INSTALL_FROM_BYTE_STREAM) = range(3) + +# above identificators point to this array to their description +JOB_METHOD_NAMES = ( + "InstallFromSoftwareIdentity", + "InstallFromURI", + "InstallFromByteStream") + class Values(object): class DetailedStatus(object): Not_Available = pywbem.Uint16(0) @@ -386,6 +398,37 @@ class Values(object): } @cmpi_logging.trace_function +def make_method_params(job, class_name, include_input, include_output): + """ + Create a class of given name with all input or output parameters + of the asynchronous method. Typically used to assemble + CIM_ConcreteJob.JobInParameters or CIM_InstMethodCall.MethodParameters + values. + + :param job: (``YumJob``) Instance of job created as a result of method + invocation. It carries method parameters. + :param class_name: (``str``) Name of the class to create. + :param include_input: (``bool``) Whether input parameters should be + included in the returned class. + :param include_output: (``bool``) Whether output parameters should be + included in the returned class. + :rtype: CIMInstance of the created class. + """ + # 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") + 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(): + inst[name] = value + if include_output and "output_params" in job.metadata: + # overwrite any input parameter + for (name, value) in job.metadata["output_params"].iteritems(): + inst[name] = value + return inst + +@cmpi_logging.trace_function def _fill_nonkeys(job, model): """ Fills into the model of instance all non-key properties. @@ -436,8 +479,12 @@ def _fill_nonkeys(job, model): type='uint16', value=None) model['OperationalStatus'] = [Values.OperationalStatus.Unknown] model['JobStatus'] = 'Unknown' - if 'method_name' in job.metadata: - model['MethodName'] = job.metadata['method_name'] + model["JobInParameters"] = make_method_params( + job, "__JobInParameters", True, False) + model["JobOutParameters"] = make_method_params( + job, "__JobOutParameters", False, True) + if 'method' in job.metadata: + model['MethodName'] = JOB_METHOD_NAMES[job.metadata["method"]] else: model["MethodName"] = pywbem.CIMProperty('MethodName', type='string', value=None) @@ -502,7 +549,8 @@ def object_path2job(op): instid = op['InstanceID'] if not instid.lower().startswith("lmi:lmi_softwareinstallationjob:"): raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, - "InstanceID must start with LMI:LMI_SoftwareInstallationJob: prefix.") + "InstanceID must start with LMI:LMI_SoftwareInstallationJob:" + " prefix.") try: instid = int(instid[len("LMI:LMI_SoftwareInstallationJob:"):]) except ValueError: @@ -596,11 +644,9 @@ def job2error(job): kwargs['status_code'] = Error.Values. \ CIMStatusCode.CIM_ERR_NOT_FOUND if issubclass(errortup[0], errors.PackageNotFound): - kwargs['status_code_description'] = \ - "Package not found" + kwargs['status_code_description'] = "Package not found" else: - kwargs['status_code_description'] = \ - "Repository not found" + kwargs['status_code_description'] = "Repository not found" elif issubclass(errortup[0], errors.PackageAlreadyInstalled): kwargs['status_code'] = Error.Values. \ CIMStatusCode.CIM_ERR_ALREADY_EXISTS |