summaryrefslogtreecommitdiffstats
path: root/src/software
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2012-10-13 21:53:35 +0200
committerMichal Minar <miminar@redhat.com>2012-10-13 21:53:35 +0200
commite0a86ee1ae193f0622e4cf1a02fa9e84561f12f0 (patch)
treec4c1e89e357dc01cd3a4bb5ad2c9748fe892d48a /src/software
parent95dec00b1efbeb4c756d4141f08f7daf0bb0189c (diff)
downloadopenlmi-providers-e0a86ee1ae193f0622e4cf1a02fa9e84561f12f0.tar.gz
openlmi-providers-e0a86ee1ae193f0622e4cf1a02fa9e84561f12f0.tar.xz
openlmi-providers-e0a86ee1ae193f0622e4cf1a02fa9e84561f12f0.zip
renamed LMI_SoftwarePackage{File,Checks}
corrected some corner cases, when getting/modifying instance with wrong or missing keys
Diffstat (limited to 'src/software')
-rw-r--r--src/software/providers/LMI_SoftwareInstalledPackage.py32
-rw-r--r--src/software/providers/LMI_SoftwarePackageChecks.py (renamed from src/software/providers/LMI_SoftwarePackageFile.py)146
2 files changed, 107 insertions, 71 deletions
diff --git a/src/software/providers/LMI_SoftwareInstalledPackage.py b/src/software/providers/LMI_SoftwareInstalledPackage.py
index 008a47b..5b00508 100644
--- a/src/software/providers/LMI_SoftwareInstalledPackage.py
+++ b/src/software/providers/LMI_SoftwareInstalledPackage.py
@@ -69,6 +69,12 @@ class LMI_SoftwareInstalledPackage(CIMProvider2):
logger.log_debug('Entering %s.get_instance()' \
% self.__class__.__name__)
+ if not "Software" in model:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing Software property.")
+ if not "System" in model:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing System property.")
check_computer_system_op(env, model['System'])
with YumDB.getInstance(env):
pkg = SoftwarePackage.object_path2pkg(env, model['Software'])
@@ -158,9 +164,15 @@ class LMI_SoftwareInstalledPackage(CIMProvider2):
# parse and check arguments
if modify_existing is True:
- raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED,
"MofifyInstance is not supported")
+ if not "Software" in instance:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing Software property.")
+ if not "System" in instance:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing System property.")
check_computer_system_op(env, instance['System'])
with YumDB.getInstance(env) as yb:
@@ -209,6 +221,12 @@ class LMI_SoftwareInstalledPackage(CIMProvider2):
logger.log_debug('Entering %s.delete_instance()' \
% self.__class__.__name__)
+ if not "Software" in instance_name:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing Software property.")
+ if not "System" in instance_name:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing System property.")
check_computer_system_op(env, instance_name['System'])
with YumDB.getInstance(env) as yb:
pkg = SoftwarePackage.object_path2pkg(env, instance_name["Software"])
@@ -335,6 +353,12 @@ class LMI_SoftwareInstalledPackage(CIMProvider2):
% self.__class__.__name__)
failed = []
+ if not "Software" in object_name:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing Software property.")
+ if not "System" in object_name:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing System property.")
with YumDB.getInstance(env) as yb:
pkg = SoftwarePackage.object_path2pkg(env, object_name['Software'])
csum = SoftwareFileCheck.pkg_checksum_type(pkg)
@@ -399,6 +423,12 @@ class LMI_SoftwareInstalledPackage(CIMProvider2):
logger.log_debug('Entering %s.cim_method_update()' \
% self.__class__.__name__)
+ if not "Software" in object_name:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing Software property.")
+ if not "System" in object_name:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing System property.")
check_computer_system_op(env, object_name['System'])
with YumDB.getInstance(env) as yb:
diff --git a/src/software/providers/LMI_SoftwarePackageFile.py b/src/software/providers/LMI_SoftwarePackageChecks.py
index 389dbbf..797e958 100644
--- a/src/software/providers/LMI_SoftwarePackageFile.py
+++ b/src/software/providers/LMI_SoftwarePackageChecks.py
@@ -15,9 +15,9 @@
# 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_SoftwarePackageFile
+"""Python Provider for LMI_SoftwarePackageChecks
-Instruments the CIM class LMI_SoftwarePackageFile
+Instruments the CIM class LMI_SoftwarePackageChecks
"""
@@ -27,15 +27,15 @@ from LMI_SoftwareFileCheck import filecheck2model
from LMI_SoftwarePackage import pkg2model
from util.common import *
-class LMI_SoftwarePackageFile(CIMProvider2):
- """Instrument the CIM class LMI_SoftwarePackageFile
+class LMI_SoftwarePackageChecks(CIMProvider2):
+ """Instrument the CIM class LMI_SoftwarePackageChecks
This association ties a SoftwareElement to a specific Check to validate
its state or its movement to the next state. Note that
SoftwareElements in a running state cannot transition to another
state. Therefore, the value of the Phase property is restricted to 0
("In-State") for SoftwareElements in the running state.
-
+
"""
def __init__ (self, env):
@@ -48,28 +48,34 @@ class LMI_SoftwarePackageFile(CIMProvider2):
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
+ 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
+ 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.
+ 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
+ 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
+ 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)
"""
-
+
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
% self.__class__.__name__)
+ if not "Check" in model:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing Check property.")
+ if not "Element" in model:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
+ "Missing Element property.")
vpkg = SoftwareFileCheck.object_path2yumcheck(env, model['Check'])
model['Check'] = filecheck2model(vpkg, model['Check']['Name'],
env, keys_only=True)
@@ -80,17 +86,17 @@ class LMI_SoftwarePackageFile(CIMProvider2):
"""Enumerate instances.
The WBEM operations EnumerateInstances and EnumerateInstanceNames
- are both mapped to this method.
+ 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.
+ 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.
@@ -102,16 +108,16 @@ class LMI_SoftwarePackageFile(CIMProvider2):
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
-
+
# 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.
+ # we set property values on the model.
model.path.update({'Check': None, 'Element': None})
-
+
while False: # TODO more instances?
# TODO fetch system resource
- # Key properties
- #model['Check'] = pywbem.CIMInstanceName(classname='LMI_SoftwareFileCheck', ...) # TODO (type = REF (pywbem.CIMInstanceName(classname='LMI_SoftwareFileCheck', ...))
+ # Key properties
+ #model['Check'] = pywbem.CIMInstanceName(classname='LMI_SoftwareFileCheck', ...) # TODO (type = REF (pywbem.CIMInstanceName(classname='LMI_SoftwareFileCheck', ...))
#model['Element'] = pywbem.CIMInstanceName(classname='LMI_SoftwarePackage', ...) # TODO (type = REF (pywbem.CIMInstanceName(classname='LMI_SoftwarePackage', ...))
if keys_only:
yield model
@@ -119,7 +125,7 @@ class LMI_SoftwarePackageFile(CIMProvider2):
try:
yield self.get_instance(env, model)
except pywbem.CIMError, (num, msg):
- if num not in (pywbem.CIM_ERR_NOT_FOUND,
+ if num not in (pywbem.CIM_ERR_NOT_FOUND,
pywbem.CIM_ERR_ACCESS_DENIED):
raise
@@ -128,22 +134,22 @@ class LMI_SoftwarePackageFile(CIMProvider2):
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
+ 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.
+ 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
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
or otherwise incorrect parameters)
- CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
+ 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
+ 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)
@@ -162,22 +168,22 @@ class LMI_SoftwarePackageFile(CIMProvider2):
Keyword arguments:
env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance_name -- A pywbem.CIMInstanceName specifying the instance
+ 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
+ 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
+ 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
+ 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)
- """
+ """
logger = env.get_logger()
logger.log_debug('Entering %s.delete_instance()' \
@@ -185,43 +191,43 @@ class LMI_SoftwarePackageFile(CIMProvider2):
# TODO delete the resource
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
-
+
def references(self, env, object_name, model, result_class_name, role,
result_role, keys_only):
"""Instrument Associations.
- All four association-related operations (Associators, AssociatorNames,
- References, ReferenceNames) are mapped to this method.
+ All four association-related operations (Associators, AssociatorNames,
+ References, ReferenceNames) are mapped to this method.
This method is a python generator
Keyword arguments:
env -- Provider Environment (pycimmb.ProviderEnvironment)
- object_name -- A pywbem.CIMInstanceName that defines the source
+ object_name -- A pywbem.CIMInstanceName that defines the source
CIM Object whose associated Objects are to be returned.
model -- A template pywbem.CIMInstance to serve as a model
of the objects to be returned. Only properties present on this
- model need to be set.
- result_class_name -- If not empty, this string acts as a filter on
- the returned set of Instances by mandating that each returned
- Instances MUST represent an association between object_name
+ model need to be set.
+ result_class_name -- If not empty, this string acts as a filter on
+ the returned set of Instances by mandating that each returned
+ Instances MUST represent an association between object_name
and an Instance of a Class whose name matches this parameter
- or a subclass.
- role -- If not empty, MUST be a valid Property name. It acts as a
- filter on the returned set of Instances by mandating that each
- returned Instance MUST refer to object_name via a Property
+ or a subclass.
+ role -- If not empty, MUST be a valid Property name. It acts as a
+ filter on the returned set of Instances by mandating that each
+ returned Instance MUST refer to object_name via a Property
whose name matches the value of this parameter.
- result_role -- If not empty, MUST be a valid Property name. It acts
- as a filter on the returned set of Instances by mandating that
- each returned Instance MUST represent associations of
- object_name to other Instances, where the other Instances play
- the specified result_role in the association (i.e. the
- name of the Property in the Association Class that refers to
- the Object related to object_name MUST match the value of this
+ result_role -- If not empty, MUST be a valid Property name. It acts
+ as a filter on the returned set of Instances by mandating that
+ each returned Instance MUST represent associations of
+ object_name to other Instances, where the other Instances play
+ the specified result_role in the association (i.e. the
+ name of the Property in the Association Class that refers to
+ the Object related to object_name MUST match the value of this
parameter).
keys_only -- A boolean. True if only the key properties should be
set on the generated instances.
- The following diagram may be helpful in understanding the role,
+ The following diagram may be helpful in understanding the role,
result_role, and result_class_name parameters.
+------------------------+ +-------------------+
| object_name.classname | | result_class_name |
@@ -239,7 +245,7 @@ class LMI_SoftwarePackageFile(CIMProvider2):
CIM_ERR_ACCESS_DENIED
CIM_ERR_NOT_SUPPORTED
CIM_ERR_INVALID_NAMESPACE
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
or otherwise incorrect parameters)
CIM_ERR_FAILED (some other unspecified error occurred)
@@ -249,16 +255,16 @@ class LMI_SoftwarePackageFile(CIMProvider2):
logger.log_debug('Entering %s.references()' \
% self.__class__.__name__)
ch = env.get_cimom_handle()
-
+
# 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.
+ # we set property values on the model.
model.path.update({'Check': None, 'Element': None})
with YumDB.getInstance(env):
if ( (not role or role.lower() == 'element')
- and ch.is_subclass(object_name.namespace,
- sub=object_name.classname,
+ and ch.is_subclass(object_name.namespace,
+ sub=object_name.classname,
super='LMI_SoftwarePackage')):
filecheck_model = pywbem.CIMInstanceName(
classname='LMI_SoftwareFileCheck',
@@ -277,8 +283,8 @@ class LMI_SoftwarePackageFile(CIMProvider2):
yield model
if ( (not role or role.lower() == 'check')
- and ch.is_subclass(object_name.namespace,
- sub=object_name.classname,
+ and ch.is_subclass(object_name.namespace,
+ sub=object_name.classname,
super='LMI_SoftwareFileCheck')):
model['Check'] = object_name
@@ -292,10 +298,10 @@ class LMI_SoftwarePackageFile(CIMProvider2):
In_State = pywbem.Uint16(0)
Next_State = pywbem.Uint16(1)
-## end of class LMI_SoftwarePackageFileProvider
-
+## end of class LMI_SoftwarePackageChecksProvider
+
## get_providers() for associating CIM Class Name to python provider class name
-
-def get_providers(env):
- lmi_softwarepackagefile_prov = LMI_SoftwarePackageFile(env)
- return {'LMI_SoftwarePackageFile': lmi_softwarepackagefile_prov}
+
+def get_providers(env):
+ lmi_softwarepackagechecks_prov = LMI_SoftwarePackageChecks(env)
+ return {'LMI_SoftwarePackageChecks': lmi_softwarepackagechecks_prov}