summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-06-12 15:12:25 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-06-12 15:12:25 +0000
commit495f950666bb59ebc380101cd902415c211124a2 (patch)
tree8b32215f0d1bd171d5abd212683bee8b9da9eae4
parentf8ccb25a9300942006881bb371fde040d5c87147 (diff)
downloadbcfg2-495f950666bb59ebc380101cd902415c211124a2.tar.gz
bcfg2-495f950666bb59ebc380101cd902415c211124a2.tar.bz2
bcfg2-495f950666bb59ebc380101cd902415c211124a2.zip
RPMng fixes from mbrady
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3288 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--schemas/pkglist.xsd3
-rw-r--r--src/lib/Client/Tools/RPMng.py77
2 files changed, 65 insertions, 15 deletions
diff --git a/schemas/pkglist.xsd b/schemas/pkglist.xsd
index d46f1d9b0..d4828716a 100644
--- a/schemas/pkglist.xsd
+++ b/schemas/pkglist.xsd
@@ -33,6 +33,9 @@
<xsd:attribute name='simplefile' type='xsd:string'/>
<xsd:attribute name='pkg_verify' type='xsd:string'/>
<xsd:attribute name='verify_flags' type='xsd:string'/>
+ <xsd:attribute name='installed_action' type='xsd:string'/>
+ <xsd:attribute name='version_fail_action' type='xsd:string'/>
+ <xsd:attribute name='verify_fail_action' type='xsd:string'/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
diff --git a/src/lib/Client/Tools/RPMng.py b/src/lib/Client/Tools/RPMng.py
index d36a10737..471442fbd 100644
--- a/src/lib/Client/Tools/RPMng.py
+++ b/src/lib/Client/Tools/RPMng.py
@@ -84,6 +84,30 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
self.pkg_verify = 'true'
self.logger.debug('pkg_verify = %s' % self.pkg_verify)
+ # installed_action
+ if RPMng_CP.has_option(self.__name__, 'installed_action'):
+ self.installed_action = RPMng_CP.get(self.__name__, 'installed_action').lower()
+ else:
+ self.installed_action = 'install'
+ self.logger.debug('installed_action = %s' % self.installed_action)
+
+ # version_fail_action
+ if RPMng_CP.has_option(self.__name__, 'version_fail_action'):
+ self.version_fail_action = RPMng_CP.get(self.__name__, 'version_fail_action').lower()
+ else:
+ self.version_fail_action = 'upgrade'
+ self.logger.debug('version_fail_action = %s' % self.version_fail_action)
+
+ # verify_fail_action
+ if self.__name__ == "RPMng":
+ if RPMng_CP.has_option(self.__name__, 'verify_fail_action'):
+ self.verify_fail_action = RPMng_CP.get(self.__name__, 'verify_fail_action').lower()
+ else:
+ self.verify_fail_action = 'reinstall'
+ else: # yum can't reinstall packages.
+ self.verify_fail_action = 'none'
+ self.logger.debug('verify_fail_action = %s' % self.verify_fail_action)
+
def RefreshPackages(self):
'''
Creates self.installed{} which is a dict of installed packages.
@@ -310,6 +334,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
self.str_evra(inst))
qtext_versions = qtext_versions + 'R(%s) ' % self.str_evra(inst)
self.instance_status[inst]['modlist'] = modlist
+ inst.set('verify_status', str(self.instance_status[inst]))
if self.instance_status[inst]['installed'] == False or \
self.instance_status[inst].get('version_fail', False)== True or \
@@ -439,25 +464,50 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
self.RefreshPackages()
self.extra = self.FindExtraPackages()
- def reinstall_check(self, verify_results):
+ def FixInstance(self, instance, inst_status):
'''
Control if a reinstall of a package happens or not based on the
results from RPMng.VerifyPackage().
Return True to reinstall, False to not reintstall.
'''
- reinstall = False
+ fix = False
- for inst in verify_results.get('verify'):
- self.logger.debug('reinstall_check: %s %s:%s-%s.%s' % inst.get('nevra'))
-
- # Parse file results
- for file_result in inst.get('files', []):
- self.logger.debug('reinstall_check: file: %s' % file_result)
- if file_result[-2] != 'c':
- reinstall = True
+ if inst_status.get('installed', False) == False:
+ if instance.get('installed_action', 'install') == "install" and \
+ self.installed_action == "install":
+ fix = True
+ else:
+ self.logger.debug('Installed Action for %s %s is to not install' % \
+ (inst_status.get('pkg').get('name'),
+ self.str_evra(instance)))
+
+ elif inst_status.get('version_fail', False) == True:
+ if instance.get('version_fail_action', 'upgrade') == "upgrade" and \
+ self.version_fail_action == "upgrade":
+ fix = True
+ else:
+ self.logger.debug('Version Fail Action for %s %s is to not upgrade' % \
+ (inst_status.get('pkg').get('name'),
+ self.str_evra(instance)))
+
+ elif inst_status.get('verify_fail', False) == True:
+ if instance.get('verify_fail_action', 'reinstall') == "reinstall" and \
+ self.verify_fail_action == "reinstall":
+ for inst in inst_status.get('verify'):
+ self.logger.debug('reinstall_check: %s %s:%s-%s.%s' % inst.get('nevra'))
+
+ # Parse rpm verify file results
+ for file_result in inst.get('files', []):
+ self.logger.debug('reinstall_check: file: %s' % file_result)
+ if file_result[-2] != 'c':
+ fix = True
+ else:
+ self.logger.debug('Verify Fail Action for %s %s is to not reinstall' % \
+ (inst_status.get('pkg').get('name'),
+ self.str_evra(instance)))
- return reinstall
+ return fix
def Install(self, packages):
'''
@@ -501,10 +551,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
for pkg in packages:
for inst in [instn for instn in pkg if instn.tag \
in ['Instance', 'Package']]:
- if self.instance_status[inst].get('installed', False) == False or \
- self.instance_status[inst].get('version_fail', False) == True or \
- (self.instance_status[inst].get('verify_fail', False) == True and \
- self.reinstall_check(self.instance_status[inst])):
+ if self.FixInstance(inst, self.instance_status[inst]):
if pkg.get('name') == 'gpg-pubkey':
gpg_keys.append(inst)
elif pkg.get('name') in self.installOnlyPkgs: