summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-08-06 16:23:26 +0200
committerMichal Minar <miminar@redhat.com>2013-08-08 12:53:21 +0200
commit8a1119dc7a8581c8b3858132990ebc1ab3b71aee (patch)
tree448ec0e89740ec36b584664d8333b0027584d7c1
parent2d69169f616a6ff029914f21fb5420631bf40171 (diff)
downloadopenlmi-providers-8a1119dc7a8581c8b3858132990ebc1ab3b71aee.tar.gz
openlmi-providers-8a1119dc7a8581c8b3858132990ebc1ab3b71aee.tar.xz
openlmi-providers-8a1119dc7a8581c8b3858132990ebc1ab3b71aee.zip
software: async jobs have associated job method results
This is a temporary work around Pegasus not being able to handle instances of unknown classes.
-rw-r--r--src/software/lmi/software/core/InstMethodCall.py15
-rw-r--r--src/software/lmi/software/core/Job.py26
2 files changed, 27 insertions, 14 deletions
diff --git a/src/software/lmi/software/core/InstMethodCall.py b/src/software/lmi/software/core/InstMethodCall.py
index ec9356e..358d342 100644
--- a/src/software/lmi/software/core/InstMethodCall.py
+++ b/src/software/lmi/software/core/InstMethodCall.py
@@ -109,10 +109,17 @@ def job2model(job, pre=True):
type="instance", value=src_instance)
inst['SourceInstanceModelPath'] = \
str(src_instance.path) #pylint: disable=E1103
- inst['MethodName'] = Job.JOB_METHOD_NAMES[
- job.metadata["method"]]
- inst['MethodParameters'] = Job.make_method_params(
- job, '__MethodParameters', True, not pre)
+ method_name = Job.JOB_METHOD_NAMES[job.metadata["method"]]
+ inst['MethodName'] = method_name
+ # TODO: uncomment when Pegasus can correctly handle instances
+ # of unregistered classes
+ #inst['MethodParameters'] = Job.make_method_params(
+ # job, '__MethodParameters', True, not pre)
+ # TODO: until then, use this workaround
+ if not pre:
+ inst["MethodParameters"] = Job.make_method_params(
+ job, '__MethodParameters_' + method_name, False, True)
+
inst['PreCall'] = pre
if not pre:
diff --git a/src/software/lmi/software/core/Job.py b/src/software/lmi/software/core/Job.py
index b3ccd5d..0bf6faa 100644
--- a/src/software/lmi/software/core/Job.py
+++ b/src/software/lmi/software/core/Job.py
@@ -469,18 +469,20 @@ def make_method_params(job, class_name, include_input, include_output):
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 = util.new_instance_name(clsname)
- inst = pywbem.CIMInstance(classname=clsname, path=path)
+ path = util.new_instance_name(class_name)
+ inst = pywbem.CIMInstance(classname=class_name, 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:
if isinstance(job, jobs.YumCheckPackage):
# make sure, that output parameters are computed
- get_verification_out_params(job)
+ # TODO: uncomment this, when pegasus properly handles instances
+ # of unknown classes - we can not create Failed property, which
+ # is an array of references in association class representing
+ # result of asynchronous method
+ #get_verification_out_params(job)
+ pass
if "output_params" in job.metadata:
# overwrite any input parameter
for (name, value) in job.metadata["output_params"].iteritems():
@@ -585,12 +587,15 @@ def _fill_nonkeys(job, model):
type='uint16', value=None)
model['OperationalStatus'] = [Values.OperationalStatus.Unknown]
model['JobStatus'] = 'Unknown'
- model["JobInParameters"] = make_method_params(
- job, "__JobInParameters", True, False)
+ # TODO: uncomment this, when Pegasus propertly supports instances of
+ # unknown classes
+ #model["JobInParameters"] = make_method_params(
+ # job, "__JobInParameters", True, False)
+ method_name = JOB_METHOD_NAMES[job.metadata["method"]]
model["JobOutParameters"] = make_method_params(
- job, "__JobOutParameters", False, True)
+ job, "__MethodParameters_"+method_name+"_Result", False, True)
if 'method' in job.metadata:
- model['MethodName'] = JOB_METHOD_NAMES[job.metadata["method"]]
+ model['MethodName'] = method_name
else:
model["MethodName"] = pywbem.CIMProperty('MethodName',
type='string', value=None)
@@ -655,6 +660,7 @@ def job2model(job, class_name=None, keys_only=True, model=None):
model['InstanceID'] = 'LMI:%s:%d' % (class_name, jobid)
if isinstance(model, pywbem.CIMInstance):
model.path['InstanceID'] = model['InstanceID'] #pylint: disable=E1103
+
if not keys_only:
_fill_nonkeys(job, model)
return model