summaryrefslogtreecommitdiffstats
path: root/src/python/openlmi/common/JobManager.py
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-04-18 22:04:03 +0200
committerMichal Minar <miminar@redhat.com>2013-04-26 10:18:18 +0200
commit272c051e8453d0a98771d8741e08478f18bbf638 (patch)
treea56724b4537491217700576678b1b93d68dd7292 /src/python/openlmi/common/JobManager.py
parent59e8bf604c382b9269b4448f10223de631b40036 (diff)
downloadopenlmi-providers-272c051e8453d0a98771d8741e08478f18bbf638.tar.gz
openlmi-providers-272c051e8453d0a98771d8741e08478f18bbf638.tar.xz
openlmi-providers-272c051e8453d0a98771d8741e08478f18bbf638.zip
modified indication filters
And moved software static filters to shared JobManager. Indication filters now reflect the name of indication class, which is instrumented by particular provider. This ensures, that cimom knows, which provider to call and does not bother the others. So instead of selecting indication instances from general class CIM_InstModification, it will be LMI_SoftwareInstModification. This is a common pattern for indication queries. Avoided another shortcoming of sfcbmof parser: /* comment */ something useful is also ignored :-( Static filters of JobManager made more generic for any provider to use. Software jobmanager is now using them. This reduces redundation of code.
Diffstat (limited to 'src/python/openlmi/common/JobManager.py')
-rw-r--r--src/python/openlmi/common/JobManager.py101
1 files changed, 61 insertions, 40 deletions
diff --git a/src/python/openlmi/common/JobManager.py b/src/python/openlmi/common/JobManager.py
index f2d0c71..e78967c 100644
--- a/src/python/openlmi/common/JobManager.py
+++ b/src/python/openlmi/common/JobManager.py
@@ -47,10 +47,33 @@ import threading
from Queue import Queue
import pywbem
import openlmi.common.cmpi_logging as cmpi_logging
+from openlmi.common.IndicationManager import IndicationManager
from pywbem.cim_provider2 import CIMProvider2
import socket
import traceback
+@cmpi_logging.trace_function
+def register_filters(job_clsname, indication_manager=None):
+ """
+ This function registers static indication filters at IndicationManager.
+ It should be called upon provider's initialization.
+
+ :param job_clsname: (``String``) CIM class name for asynchonous jobs.
+ Will be part of filter queries.
+ :param indication_manager: If not given, global instance will be obtained.
+ """
+ if indication_manager is None:
+ ind_manager = IndicationManager.get_instance()
+ filters = {}
+ query_args = {
+ "classname" : job_clsname,
+ "prefix" : indication_manager.nameprefix
+ }
+ for fltr_id, fltr_props in JobManager.IND_FILTERS.items():
+ filters[fltr_id] = fltr_props.copy()
+ filters[fltr_id]['Query'] = fltr_props['Query'] % query_args
+ indication_manager.add_filters(job_clsname, filters)
+
# Too many instance attributes
# pylint: disable-msg=R0902
class Job(object):
@@ -660,6 +683,43 @@ class JobManager(object):
IND_JOB_CHANGED = "Changed"
IND_JOB_CREATED = "Created"
+ IND_FILTERS = {
+ IND_JOB_PERCENT_UPDATED: {
+ "Query" : "SELECT * FROM LMI_%(prefix)sInstModification WHERE "
+ "SourceInstance ISA %(classname)s AND "
+ "SourceInstance.CIM_ConcreteJob::PercentComplete <> "
+ "PreviousInstance.CIM_ConcreteJob::PercentComplete",
+ "Description" : "Modification of Percentage Complete for a "
+ "Concrete Job.",
+ },
+ IND_JOB_SUCCEEDED: {
+ "Query" : "SELECT * FROM LMI_%(prefix)sInstModification WHERE "
+ "SourceInstance ISA %(classname)s AND "
+ "SourceInstance.CIM_ConcreteJob::JobState = 17",
+ "Description": "Modification of Job State for a "
+ "Concrete Job to 'Complete'.",
+ },
+ IND_JOB_FAILED: {
+ "Query" : "SELECT * FROM LMI_%(prefix)sInstModification WHERE "
+ "SourceInstance ISA %(classname)s AND "
+ "SourceInstance.CIM_ConcreteJob::JobState = 10",
+ "Description": "Modification of Job State for a "
+ "Concrete Job to 'Exception'.",
+ },
+ IND_JOB_CHANGED: {
+ "Query" : "SELECT * FROM LMI_%(prefix)sInstModification WHERE "
+ "SourceInstance ISA %(classname)s AND "
+ "SourceInstance.CIM_ConcreteJob::JobState <> "
+ "PreviousInstance.CIM_ConcreteJob::JobState",
+ "Description": "Modification of Job State for a ConcreteJob.",
+ },
+ IND_JOB_CREATED: {
+ "Query" : "SELECT * FROM LMI_%(prefix)sInstCreation WHERE "
+ "SourceInstance ISA %(classname)s",
+ "Description": "Creation of a ConcreteJob.",
+ },
+ }
+
@cmpi_logging.trace_method
def __init__(self, name, namespace, indication_manager, timer_manager):
"""
@@ -710,46 +770,7 @@ class JobManager(object):
"""
Add all job-related ``IndicationFilters`` to indication manager.
"""
- filters = {
- self.IND_JOB_PERCENT_UPDATED: {
- "Query" : "SELECT * FROM CIM_InstModification WHERE "
- "SourceInstance ISA %(classname)s AND "
- "SourceInstance.CIM_ConcreteJob::PercentComplete <> "
- "PreviousInstance.CIM_ConcreteJob::PercentComplete",
- "Description" : "Modification of Percentage Complete for a "
- "Concrete Job.",
- },
- self.IND_JOB_SUCCEEDED: {
- "Query" : "SELECT * FROM CIM_InstModification WHERE "
- "SourceInstance ISA %(classname)s AND "
- "SourceInstance.CIM_ConcreteJob::JobState = 17",
- "Description": "Modification of Job State for a "
- "Concrete Job to 'Complete'.",
- },
- self.IND_JOB_FAILED: {
- "Query" : "SELECT * FROM CIM_InstModification WHERE "
- "SourceInstance ISA %(classname)s AND "
- "SourceInstance.CIM_ConcreteJob::JobState = 10",
- "Description": "Modification of Job State for a "
- "Concrete Job to 'Exception'.",
- },
- self.IND_JOB_CHANGED: {
- "Query" : "SELECT * FROM CIM_InstModification WHERE "
- "SourceInstance ISA %(classname)s AND "
- "SourceInstance.CIM_ConcreteJob::JobState <> "
- "PreviousInstance.CIM_ConcreteJob::JobState",
- "Description": "Modification of Job State for a ConcreteJob.",
- },
- self.IND_JOB_CREATED: {
- "Query" : "SELECT * FROM CIM_InstCreation WHERE "
- "SourceInstance ISA %(classname)s",
- "Description": "Creation of a ConcreteJob.",
- },
- }
- # add class name
- for f in filters.itervalues():
- f['Query'] = f['Query'] % {"classname" : self.job_classname }
- self.indication_manager.add_filters(self.job_classname, filters)
+ register_filters(self.job_classname, self.indication_manager)
@cmpi_logging.trace_method
def get_providers(self):