summaryrefslogtreecommitdiffstats
path: root/src/software/lmi
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-12-15 10:55:14 +0100
committerMichal Minar <miminar@redhat.com>2013-12-17 13:49:01 +0100
commitef3f7563d1cffe0e9b6b67f2f4d242893c706329 (patch)
tree408cb52b47a461f265e69aaea115df08baccbdb3 /src/software/lmi
parentd3d9a68627e5d2c1ab4d355579a068aee1ddb048 (diff)
downloadopenlmi-providers-ef3f7563d1cffe0e9b6b67f2f4d242893c706329.tar.gz
openlmi-providers-ef3f7563d1cffe0e9b6b67f2f4d242893c706329.tar.xz
openlmi-providers-ef3f7563d1cffe0e9b6b67f2f4d242893c706329.zip
software: fixed creation of Error instance
Environment needs to be propagated to factory function of CIMError when error occurs while handling asynchronous job. Resolves: rhbz#1043243
Diffstat (limited to 'src/software/lmi')
-rw-r--r--src/software/lmi/software/LMI_AssociatedSoftwareJobMethodResult.py12
-rw-r--r--src/software/lmi/software/LMI_SoftwareJob.py4
-rw-r--r--src/software/lmi/software/LMI_SoftwareMethodResult.py5
-rw-r--r--src/software/lmi/software/core/Error.py1
-rw-r--r--src/software/lmi/software/core/InstMethodCall.py4
-rw-r--r--src/software/lmi/software/core/Job.py4
-rw-r--r--src/software/lmi/software/core/MethodResult.py6
7 files changed, 19 insertions, 17 deletions
diff --git a/src/software/lmi/software/LMI_AssociatedSoftwareJobMethodResult.py b/src/software/lmi/software/LMI_AssociatedSoftwareJobMethodResult.py
index 46ef67b..0a7965b 100644
--- a/src/software/lmi/software/LMI_AssociatedSoftwareJobMethodResult.py
+++ b/src/software/lmi/software/LMI_AssociatedSoftwareJobMethodResult.py
@@ -32,25 +32,25 @@ from lmi.software.core import MethodResult
from lmi.software.yumdb import YumDB
@cmpi_logging.trace_function
-def generate_job_referents(_env, object_name, model, _keys_only):
+def generate_job_referents(env, object_name, model, _keys_only):
"""
Handler for referents enumeration request.
"""
job = Job.object_path2job(object_name)
model["Job"] = Job.job2model(job)
- model["JobParameters"] = MethodResult.job2model(job)
+ model["JobParameters"] = MethodResult.job2model(env, job)
yield model
@cmpi_logging.trace_function
-def generate_result_referents(_env, object_name, model, _keys_only):
+def generate_result_referents(env, object_name, model, _keys_only):
"""
Handler for referents enumeration request.
"""
job = MethodResult.object_path2job(object_name)
model["Job"] = Job.job2model(job)
- model["JobParameters"] = MethodResult.job2model(job)
+ model["JobParameters"] = MethodResult.job2model(env, job)
yield model
class LMI_AssociatedSoftwareJobMethodResult(CIMProvider2):
@@ -95,7 +95,7 @@ class LMI_AssociatedSoftwareJobMethodResult(CIMProvider2):
"Job id of Job(%d) does not match JobParameters(%d)." %
(job.jobid, jobid))
model["Job"] = Job.job2model(job)
- model["JobParameters"] = MethodResult.job2model(job)
+ model["JobParameters"] = MethodResult.job2model(env, job)
return model
@cmpi_logging.trace_method
@@ -124,7 +124,7 @@ class LMI_AssociatedSoftwareJobMethodResult(CIMProvider2):
for job in YumDB.get_instance().get_job_list():
model['Job'] = Job.job2model(job)
- model['JobParameters'] = MethodResult.job2model(job)
+ model['JobParameters'] = MethodResult.job2model(env, job)
yield model
@cmpi_logging.trace_method
diff --git a/src/software/lmi/software/LMI_SoftwareJob.py b/src/software/lmi/software/LMI_SoftwareJob.py
index 9d6b36d..25122f6 100644
--- a/src/software/lmi/software/LMI_SoftwareJob.py
+++ b/src/software/lmi/software/LMI_SoftwareJob.py
@@ -290,7 +290,7 @@ class LMI_SoftwareJob(CIMProvider2):
CIM_ERR_FAILED (some other unspecified error occurred)
"""
job = Job.object_path2job(object_name)
- error = Job.job2error(job)
+ error = Job.job2error(env, job)
out_params = []
if error is not None:
param = pywbem.CIMParameter('Errors', type='instance',
@@ -378,7 +378,7 @@ class LMI_SoftwareJob(CIMProvider2):
CIM_ERR_FAILED (some other unspecified error occurred)
"""
job = Job.object_path2job(object_name)
- error = Job.job2error(job)
+ error = Job.job2error(env, job)
out_params = []
if error is not None:
param = pywbem.CIMParameter('Error', type='instance', value=error)
diff --git a/src/software/lmi/software/LMI_SoftwareMethodResult.py b/src/software/lmi/software/LMI_SoftwareMethodResult.py
index 0117582..cadd8b9 100644
--- a/src/software/lmi/software/LMI_SoftwareMethodResult.py
+++ b/src/software/lmi/software/LMI_SoftwareMethodResult.py
@@ -80,7 +80,7 @@ class LMI_SoftwareMethodResult(CIMProvider2):
"""
job = MethodResult.object_path2job(model.path)
- return MethodResult.job2model(job, keys_only=False, model=model)
+ return MethodResult.job2model(env, job, keys_only=False, model=model)
@cmpi_logging.trace_method
def enum_instances(self, env, model, keys_only):
@@ -111,7 +111,8 @@ class LMI_SoftwareMethodResult(CIMProvider2):
model.path.update({'InstanceID': None})
for job in YumDB.get_instance().get_job_list():
- yield MethodResult.job2model(job, keys_only=keys_only, model=model)
+ yield MethodResult.job2model(env, job,
+ keys_only=keys_only, model=model)
@cmpi_logging.trace_method
def set_instance(self, env, instance, modify_existing):
diff --git a/src/software/lmi/software/core/Error.py b/src/software/lmi/software/core/Error.py
index 2955c0b..af5ac14 100644
--- a/src/software/lmi/software/core/Error.py
+++ b/src/software/lmi/software/core/Error.py
@@ -418,6 +418,7 @@ class Values(object):
@cmpi_logging.trace_function
def make_instance(
+ env,
status_code=Values.CIMStatusCode.CIM_ERR_FAILED,
error_type=Values.ErrorType.Software_Error,
probable_cause=Values.ErrorType.Unknown,
diff --git a/src/software/lmi/software/core/InstMethodCall.py b/src/software/lmi/software/core/InstMethodCall.py
index 0543180..72981ca 100644
--- a/src/software/lmi/software/core/InstMethodCall.py
+++ b/src/software/lmi/software/core/InstMethodCall.py
@@ -86,7 +86,7 @@ class Values(object):
}
@cmpi_logging.trace_function
-def job2model(job, pre=True):
+def job2model(env, job, pre=True):
"""
Create post or pre indication instance used by clients to subscribe
to job's state changes.
@@ -125,7 +125,7 @@ def job2model(job, pre=True):
if not pre:
inst["Error"] = pywbem.CIMProperty("Error", type="instance",
is_array=True, value=[])
- error = Job.job2error(job)
+ error = Job.job2error(env, job)
if error is not None:
inst["Error"].append(error)
inst["ReturnValueType"] = Values.ReturnValueType.uint32
diff --git a/src/software/lmi/software/core/Job.py b/src/software/lmi/software/core/Job.py
index d7667e6..41ba33b 100644
--- a/src/software/lmi/software/core/Job.py
+++ b/src/software/lmi/software/core/Job.py
@@ -757,7 +757,7 @@ def modify_instance(instance):
return job2model(job, keys_only=False, model=instance)
@cmpi_logging.trace_function
-def job2error(job):
+def job2error(env, job):
"""
@return instance of CIM_Error if job is in EXCEPTION state,
None otherwise
@@ -780,5 +780,5 @@ def job2error(job):
CIMStatusCode.CIM_ERR_ALREADY_EXISTS
kwargs['message'] = getattr(errortup[1], 'message',
str(errortup[1]))
- value = Error.make_instance(**kwargs)
+ value = Error.make_instance(env, **kwargs)
return value
diff --git a/src/software/lmi/software/core/MethodResult.py b/src/software/lmi/software/core/MethodResult.py
index 9766a71..685b7d7 100644
--- a/src/software/lmi/software/core/MethodResult.py
+++ b/src/software/lmi/software/core/MethodResult.py
@@ -59,7 +59,7 @@ def object_path2job(op):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND, "No such job.")
@cmpi_logging.trace_function
-def job2model(job, keys_only=True, model=None):
+def job2model(env, job, keys_only=True, model=None):
"""
This accepts job's id and produces corresponding result model.
"""
@@ -81,9 +81,9 @@ def job2model(job, keys_only=True, model=None):
model['ElementName'] = 'MethodResult-%d' % job.jobid
model['PostCallIndication'] = pywbem.CIMProperty("PostCallIndication",
type="instance",
- value=InstMethodCall.job2model(job, pre=False))
+ value=InstMethodCall.job2model(env, job, pre=False))
model['PreCallIndication'] = pywbem.CIMProperty("PreCallIndication",
type="instance",
- value=InstMethodCall.job2model(job))
+ value=InstMethodCall.job2model(env, job))
return model