summaryrefslogtreecommitdiffstats
path: root/src/software/lmi/software/LMI_SoftwareMethodResult.py
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-07-03 18:15:23 +0200
committerMichal Minar <miminar@redhat.com>2013-07-04 10:33:48 +0200
commita4e6cc3c9f273cbbf911340edd02fa17a8379917 (patch)
tree11e5616c41385a9a9a455f4874e12cf5bbd0c376 /src/software/lmi/software/LMI_SoftwareMethodResult.py
parent4c0ec0ef72a6aef0413b9e8eca9380bd31bf4444 (diff)
downloadopenlmi-providers-a4e6cc3c9f273cbbf911340edd02fa17a8379917.tar.gz
openlmi-providers-a4e6cc3c9f273cbbf911340edd02fa17a8379917.tar.xz
openlmi-providers-a4e6cc3c9f273cbbf911340edd02fa17a8379917.zip
renamed openlmi namespace to lmi
To comply with lmi shell, which is placed in *lmi* package, and to make our imports shorter, we are renaming *openlmi* namespace to *lmi*.
Diffstat (limited to 'src/software/lmi/software/LMI_SoftwareMethodResult.py')
-rw-r--r--src/software/lmi/software/LMI_SoftwareMethodResult.py163
1 files changed, 163 insertions, 0 deletions
diff --git a/src/software/lmi/software/LMI_SoftwareMethodResult.py b/src/software/lmi/software/LMI_SoftwareMethodResult.py
new file mode 100644
index 0000000..b4d5a21
--- /dev/null
+++ b/src/software/lmi/software/LMI_SoftwareMethodResult.py
@@ -0,0 +1,163 @@
+# -*- encoding: utf-8 -*-
+# Software Management Providers
+#
+# Copyright (C) 2012-2013 Red Hat, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""Python Provider for LMI_SoftwareMethodResult
+
+Instruments the CIM class LMI_SoftwareMethodResult
+
+"""
+
+import pywbem
+from pywbem.cim_provider2 import CIMProvider2
+
+from lmi.common import cmpi_logging
+from lmi.software.core import MethodResult
+from lmi.software.yumdb import YumDB
+
+class LMI_SoftwareMethodResult(CIMProvider2):
+ """Instrument the CIM class LMI_SoftwareMethodResult
+
+ Jobs are sometimes used to represent extrinsic method invocations that
+ execute for times longer than the length of time is reasonable to
+ require a client to wait. The method executing continues beyond the
+ method return to the client. The class provides the result of the
+ execution of a Job that was itself started by the side-effect of this
+ extrinsic method invocation. The indication instances embedded an
+ instance of this class shall be the same indications delivered to
+ listening clients or recorded, all or in part, to logs. Basically,
+ this approach is a corollary to the functionality provided by an
+ instance of ListenerDestinationLog (as defined in the Interop Model).
+ The latter provides a comprehensive, persistent mechanism for
+ recording Job results, but is also more resource-intensive and
+ requires supporting logging functionality. Both the extra resources
+ and logging may not be available in all environments (for example,
+ embedded environments). Therefore, this instance-based approach is
+ also provided. The MethodResult instances shall not exist after the
+ associated ConcreteJob is deleted.
+
+ """
+
+ def __init__ (self, _env):
+ cmpi_logging.logger.debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+
+ def get_instance(self, env, model):
+ """Return an instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ model -- A template of the pywbem.CIMInstance to be returned. The
+ key properties are set on this instance to correspond to the
+ instanceName that was requested. The properties of the model
+ are already filtered according to the PropertyList from the
+ request. Only properties present in the model need to be
+ given values. If you prefer, you can set all of the
+ values, and the instance will be filtered for you.
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
+ Instance does not exist in the specified namespace)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+ job = MethodResult.object_path2job(model.path)
+ return MethodResult.job2model(job, keys_only=False, model=model)
+
+ def enum_instances(self, env, model, keys_only):
+ """Enumerate instances.
+
+ The WBEM operations EnumerateInstances and EnumerateInstanceNames
+ are both mapped to this method.
+ This method is a python generator
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ model -- A template of the pywbem.CIMInstances to be generated.
+ The properties of the model are already filtered according to
+ the PropertyList from the request. Only properties present in
+ the model need to be given values. If you prefer, you can
+ always set all of the values, and the instance will be filtered
+ for you.
+ keys_only -- A boolean. True if only the key properties should be
+ set on the generated instances.
+
+ Possible Errors:
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+ # Prime model.path with knowledge of the keys, so key values on
+ # the CIMInstanceName (model.path) will automatically be set when
+ # we set property values on the model.
+ model.path.update({'InstanceID': None})
+
+ for job in YumDB.get_instance().get_job_list():
+ yield MethodResult.job2model(job, keys_only=keys_only, model=model)
+
+ def set_instance(self, env, instance, modify_existing):
+ """Return a newly created or modified instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ instance -- The new pywbem.CIMInstance. If modifying an existing
+ instance, the properties on this instance have been filtered by
+ the PropertyList from the request.
+ modify_existing -- True if ModifyInstance, False if CreateInstance
+
+ Return the new instance. The keys must be set on the new instance.
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_NOT_SUPPORTED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
+ valid if modify_existing is False, indicating that the operation
+ was CreateInstance)
+ CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid
+ if modify_existing is True, indicating that the operation
+ was ModifyInstance)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+ def delete_instance(self, env, instance_name):
+ """Delete an instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ instance_name -- A pywbem.CIMInstanceName specifying the instance
+ to delete.
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_NOT_SUPPORTED
+ CIM_ERR_INVALID_NAMESPACE
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified
+ namespace)
+ CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
+ Instance does not exist in the specified namespace)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)