diff options
-rw-r--r-- | src/yum/providers/LMI_YumInstalledPackage.py | 37 | ||||
-rw-r--r-- | src/yum/providers/util/common.py | 8 |
2 files changed, 34 insertions, 11 deletions
diff --git a/src/yum/providers/LMI_YumInstalledPackage.py b/src/yum/providers/LMI_YumInstalledPackage.py index cf956aa..f4c4cba 100644 --- a/src/yum/providers/LMI_YumInstalledPackage.py +++ b/src/yum/providers/LMI_YumInstalledPackage.py @@ -26,7 +26,8 @@ import itertools import pywbem import socket from pywbem.cim_provider2 import CIMProvider2 -from LMI_YumPackage import LMI_YumPackage, pkg2model +from LMI_YumPackage import pkg2model +from LMI_YumFileCheck import filecheck2model from util.common import * def get_computer_system_op(): @@ -117,7 +118,6 @@ class LMI_YumInstalledPackage(CIMProvider2): # we set property values on the model. model.path.update({'System': None, 'Software': None}) - yum_package = LMI_YumPackage(env) yum_package_path = pywbem.CIMInstanceName("LMI_YumPackage", namespace=model.path.namespace, host=model.path.host) @@ -325,13 +325,32 @@ class LMI_YumInstalledPackage(CIMProvider2): logger.log_debug('Entering %s.cim_method_checkintegrity()' \ % self.__class__.__name__) - # TODO do something - raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented - out_params = [] - #out_params+= [pywbem.CIMParameter('failed', type='reference', - # value=[pywbem.CIMInstanceName(classname='LMI_YumFileCheck', ...),])] # TODO - #rval = # TODO (type pywbem.Uint32 self.Values.CheckIntegrity) - return (rval, out_params) + failed = [] + with YumDB.getInstance(env): + pkg = YumPackage.object_path2pkg(env, object_name['Software']) + vpkg = yum.packages._RPMVerifyPackage( + pkg, pkg.hdr.fiFromHeader(), + pkg.yumdb_info.checksum_type, [], True) + filecheck_model = pywbem.CIMInstanceName( + classname='LMI_YumFileCheck', + namespace=object_name.namespace, + host=object_name.host) + csum = YumFileCheck.checksumtype_str2pywbem( + pkg.yumdb_info.checksum_type) + for vpf in vpkg: + fc = YumFileCheck.test_file(env, csum, vpf) + if ( fc.exists + and all( v[0] == v[1] + for v in fc if isinstance(v, tuple))): + continue + failed.append(filecheck2model( + vpkg, vpf.filename, env, keys_only=True, + model=filecheck_model, fc=fc)) + out_params = [ pywbem.CIMParameter('Failed', type='reference', + value=failed) ] + return ( getattr(self.Values.CheckIntegrity, + 'Pass' if len(failed) == 0 else 'Not_passed') + , out_params ) def cim_method_update(self, env, object_name, param_epoch=None, diff --git a/src/yum/providers/util/common.py b/src/yum/providers/util/common.py index f70d22b..00f702f 100644 --- a/src/yum/providers/util/common.py +++ b/src/yum/providers/util/common.py @@ -909,7 +909,7 @@ class YumFileCheck: flags.append(v) return flags - def filecheck2model(vpkg, fn, env, keys_only=True, model=None): + def filecheck2model(vpkg, fn, env, keys_only=True, model=None, fc=None): if not isinstance(vpkg, yum.packages._RPMVerifyPackage): raise TypeError( "vpkg must be an instance of _RPMVerifyPackage") @@ -920,6 +920,9 @@ class YumFileCheck: model = pywbem.CIMInstanceName(classname, namespace=namespace) if not keys_only: model = pywbem.CIMInstance(classname, path=model) + if fc is not None: + if not isinstance(fc, YumFileCheck.FileCheck): + raise TypeError("fc must be an instance of FileCheck") pkg = vpkg.po vpf = vpkg._files[fn] model['Name'] = vpf.filename @@ -942,7 +945,8 @@ class YumFileCheck: model['ChecksumType'] = csumt = \ YumFileCheck.checksumtype_str2pywbem( pkg.yumdb_info.checksum_type) - fc = YumFileCheck.test_file(env, csumt, vpf) + if fc is None: + fc = YumFileCheck.test_file(env, csumt, vpf) for mattr, fattr in ( ('FileType', 'file_type'), ('FileUserID', 'user_id'), |