diff options
Diffstat (limited to 'src/yum/providers/LMI_YumFileCheck.py')
-rw-r--r-- | src/yum/providers/LMI_YumFileCheck.py | 119 |
1 files changed, 61 insertions, 58 deletions
diff --git a/src/yum/providers/LMI_YumFileCheck.py b/src/yum/providers/LMI_YumFileCheck.py index c5e29bc..7b11af9 100644 --- a/src/yum/providers/LMI_YumFileCheck.py +++ b/src/yum/providers/LMI_YumFileCheck.py @@ -29,12 +29,12 @@ filecheck2model = YumFileCheck.filecheck_wrapper( 'root/cimv2', 'LMI_YumFileCheck') class LMI_YumFileCheck(CIMProvider2): - """Instrument the CIM class LMI_YumFileCheck + """Instrument the CIM class LMI_YumFileCheck Identifies a file contained by RPM package. It's located in directory identified in FileName. The Invoke methods check for file existence and whether its attributes match those given by RPM package. - + """ def __init__ (self, env): @@ -48,24 +48,24 @@ class LMI_YumFileCheck(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__) @@ -79,17 +79,17 @@ class LMI_YumFileCheck(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. @@ -101,7 +101,7 @@ class LMI_YumFileCheck(CIMProvider2): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) - + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement def set_instance(self, env, instance, modify_existing): @@ -109,22 +109,22 @@ class LMI_YumFileCheck(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) @@ -143,22 +143,22 @@ class LMI_YumFileCheck(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()' \ @@ -166,7 +166,7 @@ class LMI_YumFileCheck(CIMProvider2): # TODO delete the resource raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement - + def cim_method_invoke(self, env, object_name): """Implements LMI_YumFileCheck.Invoke() @@ -181,11 +181,11 @@ class LMI_YumFileCheck(CIMProvider2): based on the return value. A zero is returned if the condition is satisfied. A one is returned if the method is not supported. Any other value indicates the condition is not satisfied. - + Keyword arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) - object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName - specifying the object on which the method Invoke() + object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName + specifying the object on which the method Invoke() should be invoked. Returns a two-tuple containing the return value (type pywbem.Uint32) @@ -195,11 +195,11 @@ class LMI_YumFileCheck(CIMProvider2): Possible Errors: CIM_ERR_ACCESS_DENIED - CIM_ERR_INVALID_PARAMETER (including missing, duplicate, + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized or otherwise incorrect parameters) - CIM_ERR_NOT_FOUND (the target CIM Class or instance does not + CIM_ERR_NOT_FOUND (the target CIM Class or instance does not exist in the specified namespace) - CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor + CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor the invocation request) CIM_ERR_FAILED (some other unspecified error occurred) @@ -209,15 +209,16 @@ class LMI_YumFileCheck(CIMProvider2): logger.log_debug('Entering %s.cim_method_invoke()' \ % self.__class__.__name__) - vpkg = YumFileCheck.object_path2yumcheck(env, object_name) - fc = YumFileCheck.test_file(env, - YumFileCheck.checksumtype_str2pywbem( - vpkg.po.yumdb_info.checksum_type), - vpkg._files[object_name["Name"]]) - out_params = [] - ret = 0 if YumFileCheck.filecheck_passed(fc) else 2 + with YumDB.getInstance(env) as yb: + vpkg = YumFileCheck.object_path2yumcheck(env, object_name) + fc = YumFileCheck.test_file(env, + YumFileCheck.checksumtype_str2pywbem( + YumFileCheck.pkg_checksum_type(vpkg.po)), + vpkg._files[object_name["Name"]]) + out_params = [] + ret = 0 if YumFileCheck.filecheck_passed(fc) else 2 return (pywbem.Uint32(ret), out_params) - + def cim_method_invokeonsystem(self, env, object_name, param_targetsystem=None): """Implements LMI_YumFileCheck.InvokeOnSystem() @@ -230,16 +231,18 @@ class LMI_YumFileCheck(CIMProvider2): value. A zero is returned if the condition is satisfied. A one is returned if the method is not supported. Any other value indicates the condition is not satisfied. - + Keyword arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) - object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName - specifying the object on which the method InvokeOnSystem() + object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName + specifying the object on which the method InvokeOnSystem() should be invoked. - param_targetsystem -- The input parameter TargetSystem (type REF (pywbem.CIMInstanceName(classname='CIM_ComputerSystem', ...)) + param_targetsystem -- The input parameter TargetSystem ( + type REF (pywbem.CIMInstanceName( + classname='CIM_ComputerSystem', ...)) Reference to ComputerSystem in whose context the method is to be invoked. - + Returns a two-tuple containing the return value (type pywbem.Uint32) and a list of CIMParameter objects representing the output parameters @@ -248,11 +251,11 @@ class LMI_YumFileCheck(CIMProvider2): Possible Errors: CIM_ERR_ACCESS_DENIED - CIM_ERR_INVALID_PARAMETER (including missing, duplicate, + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized or otherwise incorrect parameters) - CIM_ERR_NOT_FOUND (the target CIM Class or instance does not + CIM_ERR_NOT_FOUND (the target CIM Class or instance does not exist in the specified namespace) - CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor + CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor the invocation request) CIM_ERR_FAILED (some other unspecified error occurred) @@ -267,7 +270,7 @@ class LMI_YumFileCheck(CIMProvider2): out_params = [] #rval = # TODO (type pywbem.Uint32) return (rval, out_params) - + class Values(object): class TargetOperatingSystem(object): Unknown = pywbem.Uint16(0) @@ -398,9 +401,9 @@ class LMI_YumFileCheck(CIMProvider2): Block_Device = pywbem.Uint16(6) ## end of class LMI_YumFileCheckProvider - + ## get_providers() for associating CIM Class Name to python provider class name - -def get_providers(env): - lmi_yumfilecheck_prov = LMI_YumFileCheck(env) - return {'LMI_YumFileCheck': lmi_yumfilecheck_prov} + +def get_providers(env): + lmi_yumfilecheck_prov = LMI_YumFileCheck(env) + return {'LMI_YumFileCheck': lmi_yumfilecheck_prov} |