summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2005-04-11 17:54:33 +0000
committerNarayan Desai <desai@mcs.anl.gov>2005-04-11 17:54:33 +0000
commitca48c30a9c66425f02c06f68e2834e364ada37b1 (patch)
treed6c1b46133ee591d627c6e222fb62d56f4b5697b /src
parent3dc6a1d179462464c21dce9dc0f1a31d5e224456 (diff)
downloadbcfg2-ca48c30a9c66425f02c06f68e2834e364ada37b1.tar.gz
bcfg2-ca48c30a9c66425f02c06f68e2834e364ada37b1.tar.bz2
bcfg2-ca48c30a9c66425f02c06f68e2834e364ada37b1.zip
pylint cleanups
(Logical change 1.220) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@918 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Client/Redhat.py149
1 files changed, 2 insertions, 147 deletions
diff --git a/src/lib/Client/Redhat.py b/src/lib/Client/Redhat.py
index 591aa20e9..1b0223ade 100644
--- a/src/lib/Client/Redhat.py
+++ b/src/lib/Client/Redhat.py
@@ -4,7 +4,6 @@
'''This is redhat client support'''
__revision__ = '$Revision$'
-from copy import deepcopy
from os import popen, system
from popen2 import Popen4
@@ -12,13 +11,10 @@ from Bcfg2.Client.Toolset import Toolset
class Redhat(Toolset):
'''This class implelements support for rpm packages and standard chkconfig services'''
- rpmcmd = "rpm --oldpackage --replacepkgs --quiet -U %s"
+ pkgtool = ("rpm --oldpackage --replacepkgs --quiet -U %s", ("%s", ["name"]))
def __init__(self, cfg, setup):
Toolset.__init__(self, cfg, setup)
- #self.pkgtodo = []
- self.installed = {}
- self.installed_this_run = []
self.pkgwork = {'add':[], 'update':[], 'remove':[]}
self.Refresh()
@@ -70,7 +66,7 @@ class Redhat(Toolset):
else:
return False
- def VerifyPackage(self, entry, modlist = []):
+ def VerifyPackage(self, entry, modlist):
'''Verify Package status for entry'''
if not (entry.get('name') and entry.get('version')):
print "Can't install package, not enough data."
@@ -103,144 +99,3 @@ class Redhat(Toolset):
self.CondPrint('debug',
"Package %s content verification failed" % entry.get('name'))
return False
-
- def Inventory(self):
- '''Build up workqueue for installation'''
- self.CondPrint('verbose', "Inventorying system...")
- Toolset.Inventory(self)
- self.pkgwork = {'add':[], 'update':[], 'remove':[]}
- all = deepcopy(self.installed)
- desired = {}
- for entry in self.cfg.findall(".//Package"):
- desired[entry.attrib['name']] = entry
-
- for pkg, entry in desired.iteritems():
- if self.states.get(entry, True):
- # package entry verifies
- del all[pkg]
- else:
- if all.has_key(pkg):
- # wrong version
- del all[pkg]
- self.pkgwork['update'].append(entry)
- else:
- # new pkg
- self.pkgwork['add'].append(entry)
-
- # pkgwork contains all one-way verification data now
- # all data remaining in all is extra packages
- self.pkgwork['remove'] = all.keys()
-
-
-
-# def InstallPackage(self, entry):
-# '''Install Package entry'''
-# self.pkgtodo.append(entry)
-# return False
-
- def Install(self):
- '''Fix detected misconfigurations'''
- self.CondPrint("verbose", "Installing needed configuration changes")
-
- # Dry run info
- self.CondPrint('dryrun', "Packages to update: %s" % (" ".join([pkg.get('name') for pkg in self.pkgwork['update']])))
- self.CondPrint('dryrun', "Packages to add: %s" % (" ".join([pkg.get('name') for pkg in self.pkgwork['add']])))
- self.CondPrint('dryrun', "Packages to remove %s" % (" ".join(self.pkgwork['remove'])))
- for entry in [entry for entry in self.states if (not self.states[entry]
- and (entry.tag != 'Package'))]:
- self.CondPrint('dryrun', "Entry %s %s updated" % (entry.tag, entry.get('name')))
- if self.setup['dryrun']:
- return
-
- # build up work queue
- work = self.pkgwork['add'] + self.pkgwork['update']
- # add non-package entries
- work += [ent for ent in self.states if ent.tag != 'Package' and not self.states[ent]]
-
- # Counters
- ## Packages left to install
- left = len(work) + len(self.pkgwork['remove'])
- ## Packages installed in last review
- old = left + 1
- ## Loops gone through
- count = 1
-
- # Installation loop
- while ((0 < left < old) and (count < 20)):
- # Print pass info
- self.CondPrint('verbose', "Starting pass %s" % (count))
- self.CondPrint("verbose", "%s Entries left" % (len(work)))
- self.CondPrint('verbose', "%s new, %s update, %s remove" %
- (len(self.pkgwork['add']), len(self.pkgwork['update']),
- len(self.pkgwork['remove'])))
-
- # Update counters
- count = count + 1
- old = left
-
- self.CondPrint("verbose", "Installing Non Package entries")
- [self.InstallEntry(ent) for ent in work if ent.tag != 'Package']
-
- packages = [pkg for pkg in work if pkg.tag == 'Package']
- if packages:
- # try single large install
- self.CondPrint("verbose", "Trying single pass package install")
- cmdrc = system(self.rpmcmd % " ".join([pkg.get('url') for pkg in packages]))
-
- if cmdrc == 0:
- self.CondPrint('verbose', "Single Pass Succeded")
- # set all states to true and flush workqueues
- for pkg in packages:
- self.states[pkg] = True
- self.Refresh()
- else:
- self.CondPrint("verbose", "Single Pass Failed")
- # do single pass installs
- self.Refresh()
- for pkg in packages:
- # handle state tracking updates
- if self.VerifyPackage(pkg, []):
- self.CondPrint("verbose", "Forcing state to true for pkg %s" % (pkg.get('name')))
- self.states[pkg] = True
- else:
- self.CondPrint("verbose", "Installing pkg %s version %s" %
- (pkg.get('name'), pkg.get('version')))
- cmdrc = system(self.rpmcmd % (pkg.get('url')))
- if cmdrc == 0:
- self.states[pkg] = True
- else:
- self.CondPrint('verbose', "Failed to install package %s" % (pkg.get('name')))
- for entry in [ent for ent in work if self.states[ent]]:
- work.remove(entry)
- self.installed_this_run.append(entry)
- left = len(work) + len(self.pkgwork['remove'])
- self.HandleBundleDeps()
-
- def HandleBundleDeps(self):
- '''Handle bundles depending on what has been modified'''
- for entry in [child for child in self.structures if child.tag == 'Bundle']:
- bchildren = entry.getchildren()
- if [b_ent for b_ent in bchildren if b_ent in self.installed_this_run]:
- # This bundle has been modified
- self.CondPrint('verbose', "%s %s needs update" % (entry.tag, entry.get('name', '???')))
- modfiles = [cfile.get('name') for cfile in bchildren if cfile.tag == 'ConfigFile']
- for child in bchildren:
- if child.tag == 'Package':
- self.VerifyPackage(child, modfiles)
- else:
- self.VerifyEntry(child)
- self.CondPrint('debug', "Re-checked entry %s %s: %s" %
- (child.tag, child.get('name'), self.states[child]))
- for svc in [svc for svc in bchildren if svc.tag == 'Service']:
- if self.setup['build']:
- # stop services in miniroot
- system('/etc/init.d/%s stop' % svc.get('name'))
- else:
- self.CondPrint('debug', 'Restarting service %s' % svc.get('name'))
- system('/etc/init.d/%s %s' % (svc.get('name'), svc.get('reload', 'reload')))
-
- for entry in self.structures:
- if [strent for strent in entry.getchildren() if not self.states[strent]]:
- self.CondPrint('verbose', "%s %s incomplete" % (entry.tag, entry.get('name', "")))
- else:
- self.structures[entry] = True