summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-03-17 18:28:10 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-03-17 18:28:10 +0000
commit58b5e071c9b7c3fb27b0c918beca8f8d4fd557ee (patch)
tree1233255cfc8bd9467eeec36c7146102d936b20b0
parentb7e58e817e6326a6317387fe06db2a6448aea469 (diff)
downloadbcfg2-58b5e071c9b7c3fb27b0c918beca8f8d4fd557ee.tar.gz
bcfg2-58b5e071c9b7c3fb27b0c918beca8f8d4fd557ee.tar.bz2
bcfg2-58b5e071c9b7c3fb27b0c918beca8f8d4fd557ee.zip
Remove validation states from Tool instances (in preparation for DecisionList stuff)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4423 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Client/Frame.py12
-rw-r--r--src/lib/Client/Tools/APT.py14
-rw-r--r--src/lib/Client/Tools/Action.py11
-rw-r--r--src/lib/Client/Tools/Blast.py4
-rw-r--r--src/lib/Client/Tools/DebInit.py2
-rw-r--r--src/lib/Client/Tools/Portage.py4
-rw-r--r--src/lib/Client/Tools/PostInstall.py2
-rw-r--r--src/lib/Client/Tools/RPMng.py20
-rw-r--r--src/lib/Client/Tools/SMF.py2
-rw-r--r--src/lib/Client/Tools/SYSV.py4
-rw-r--r--src/lib/Client/Tools/YUMng.py16
-rw-r--r--src/lib/Client/Tools/__init__.py36
-rw-r--r--src/lib/Client/Tools/launchd.py2
13 files changed, 65 insertions, 64 deletions
diff --git a/src/lib/Client/Frame.py b/src/lib/Client/Frame.py
index 6d761317d..30aec7924 100644
--- a/src/lib/Client/Frame.py
+++ b/src/lib/Client/Frame.py
@@ -64,7 +64,7 @@ class Frame:
for tool in tclass.values():
try:
- self.tools.append(tool(self.logger, setup, config, self.states))
+ self.tools.append(tool(self.logger, setup, config))
except Bcfg2.Client.Tools.toolInstantiationError:
continue
except:
@@ -126,7 +126,7 @@ class Frame:
self.states[entry] = False
for tool in self.tools:
try:
- tool.Inventory()
+ tool.Inventory(self.states)
except:
self.logger.error("%s.Inventory() call failed:" % tool.__name__, exc_info=1)
@@ -205,7 +205,7 @@ class Frame:
if not handled:
continue
try:
- tool.Install(handled)
+ tool.Install(handled, self.states)
except:
self.logger.error("%s.Install() call failed:" % tool.__name__, exc_info=1)
@@ -225,7 +225,7 @@ class Frame:
tbm = [(t, b) for t in self.tools for b in mbundles]
for tool, bundle in tbm:
try:
- tool.Inventory([bundle])
+ tool.Inventory(self.states, [bundle])
except:
self.logger.error("%s.Inventory() call failed:" % tool.__name__, exc_info=1)
clobbered = [entry for bundle in mbundles for entry in bundle \
@@ -241,9 +241,9 @@ class Frame:
for tool in self.tools:
try:
if bundle in mbundles:
- tool.BundleUpdated(bundle)
+ tool.BundleUpdated(bundle, self.states)
else:
- tool.BundleNotUpdated(bundle)
+ tool.BundleNotUpdated(bundle, self.states)
except:
self.logger.error("%s.BundleNotUpdated() call failed:" % \
(tool.__name__), exc_info=1)
diff --git a/src/lib/Client/Tools/APT.py b/src/lib/Client/Tools/APT.py
index 89e01aaac..6782667fb 100644
--- a/src/lib/Client/Tools/APT.py
+++ b/src/lib/Client/Tools/APT.py
@@ -10,8 +10,10 @@ class APT(Bcfg2.Client.Tools.PkgTool):
the rest from Toolset.Toolset'''
__name__ = 'APT'
__execs__ = ['/usr/bin/debsums', '/usr/bin/apt-get', '/usr/bin/dpkg']
- __important__ = ["/etc/apt/sources.list", "/var/cache/debconf/config.dat", \
- "/var/cache/debconf/templates.dat", '/etc/passwd', '/etc/group', \
+ __important__ = ["/etc/apt/sources.list",
+ "/var/cache/debconf/config.dat",
+ "/var/cache/debconf/templates.dat",
+ '/etc/passwd', '/etc/group',
'/etc/apt/apt.conf', '/etc/dpkg/dpkg.cfg']
__handles__ = [('Package', 'deb')]
__req__ = {'Package': ['name', 'version']}
@@ -21,8 +23,8 @@ class APT(Bcfg2.Client.Tools.PkgTool):
svcre = re.compile("/etc/.*/[SK]\d\d(?P<name>\S+)")
- def __init__(self, logger, cfg, setup, states):
- Bcfg2.Client.Tools.PkgTool.__init__(self, logger, cfg, setup, states)
+ def __init__(self, logger, cfg, setup):
+ Bcfg2.Client.Tools.PkgTool.__init__(self, logger, cfg, setup)
self.cfg = cfg
os.environ["DEBIAN_FRONTEND"] = 'noninteractive'
self.installed = {}
@@ -98,10 +100,10 @@ class APT(Bcfg2.Client.Tools.PkgTool):
self.RefreshPackages()
self.extra = self.FindExtraPackages()
- def Install(self, packages):
+ def Install(self, packages, states):
if self.setup['kevlar'] and not self.setup['dryrun'] and not self.updated:
self.cmd.run("dpkg --force-confold --configure --pending")
self.cmd.run("apt-get clean")
self.cmd.run("apt-get -q=2 -y update")
self.updated = True
- Bcfg2.Client.Tools.PkgTool.Install(self, packages)
+ Bcfg2.Client.Tools.PkgTool.Install(self, packages, states)
diff --git a/src/lib/Client/Tools/Action.py b/src/lib/Client/Tools/Action.py
index a69405764..9ec3418e9 100644
--- a/src/lib/Client/Tools/Action.py
+++ b/src/lib/Client/Tools/Action.py
@@ -41,24 +41,23 @@ class Action(Bcfg2.Client.Tools.Tool):
def InstallAction(self, entry):
'''Run actions as pre-checks for bundle installation'''
if entry.get('timing') != 'post':
- self.states[entry] = self.RunAction(entry)
- return self.states[entry]
+ return self.RunAction(entry)
return True
def InstallPostInstall(self, entry):
return self.InstallAction(self, entry)
- def BundleUpdated(self, bundle):
+ def BundleUpdated(self, bundle, states):
'''Run postinstalls when bundles have been updated'''
for postinst in bundle.findall("PostInstall"):
self.cmd.run(postinst.get('name'))
for action in bundle.findall("Action"):
if action.get('timing') in ['post', 'both']:
- self.states[action] = self.RunAction(action)
+ states[action] = self.RunAction(action)
- def BundleNotUpdated(self, bundle):
+ def BundleNotUpdated(self, bundle, states):
'''Run Actions when bundles have not been updated'''
for action in bundle.findall("Action"):
if action.get('timing') in ['post', 'both'] and \
action.get('when') != 'modified':
- self.states[action] = self.RunAction(action)
+ states[action] = self.RunAction(action)
diff --git a/src/lib/Client/Tools/Blast.py b/src/lib/Client/Tools/Blast.py
index f5a1f275a..0a65ff6f0 100644
--- a/src/lib/Client/Tools/Blast.py
+++ b/src/lib/Client/Tools/Blast.py
@@ -13,9 +13,9 @@ class Blast(Bcfg2.Client.Tools.SYSV.SYSV):
__handles__ = [('Package', 'blast')]
__ireq__ = {'Package': ['name', 'version', 'bname']}
- def __init__(self, logger, setup, config, states):
+ def __init__(self, logger, setup, config):
# dont use the sysv constructor
- Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config, states)
+ Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config)
self.noaskname = tempfile.mktemp()
try:
open(self.noaskname, 'w+').write(Bcfg2.Client.Tools.SYSV.noask)
diff --git a/src/lib/Client/Tools/DebInit.py b/src/lib/Client/Tools/DebInit.py
index 0e0bb2319..f23046273 100644
--- a/src/lib/Client/Tools/DebInit.py
+++ b/src/lib/Client/Tools/DebInit.py
@@ -94,7 +94,7 @@ class DebInit(Bcfg2.Client.Tools.SvcTool):
# Extra services need to be reflected in the config
return
- def BundleUpdated(self, bundle):
+ def BundleUpdated(self, bundle, states):
'''The Bundle has been updated'''
for entry in bundle:
if self.handlesEntry(entry):
diff --git a/src/lib/Client/Tools/Portage.py b/src/lib/Client/Tools/Portage.py
index f509b6d3e..7d9ecc3ca 100644
--- a/src/lib/Client/Tools/Portage.py
+++ b/src/lib/Client/Tools/Portage.py
@@ -16,8 +16,8 @@ class Portage(Bcfg2.Client.Tools.PkgTool):
# requires a working PORTAGE_BINHOST in make.conf
pkgtool = ('emerge --getbinpkgonly %s', ('=%s-%s', ['name', 'version']))
- def __init__(self, logger, cfg, setup, states):
- Bcfg2.Client.Tools.PkgTool.__init__(self, logger, cfg, setup, states)
+ def __init__(self, logger, cfg, setup):
+ Bcfg2.Client.Tools.PkgTool.__init__(self, logger, cfg, setup)
self.cfg = cfg
self.installed = {}
self.RefreshPackages()
diff --git a/src/lib/Client/Tools/PostInstall.py b/src/lib/Client/Tools/PostInstall.py
index 34627cacf..0a529f4fd 100644
--- a/src/lib/Client/Tools/PostInstall.py
+++ b/src/lib/Client/Tools/PostInstall.py
@@ -13,7 +13,7 @@ class PostInstall(Bcfg2.Client.Tools.Tool):
'''PostInstalls always verify true'''
return True
- def BundleUpdated(self, bundle):
+ def BundleUpdated(self, bundle, states):
'''Run postinstalls when bundles have been updated'''
for entry in bundle:
if entry.tag == 'PostInstall':
diff --git a/src/lib/Client/Tools/RPMng.py b/src/lib/Client/Tools/RPMng.py
index a93c0ee12..21813e283 100644
--- a/src/lib/Client/Tools/RPMng.py
+++ b/src/lib/Client/Tools/RPMng.py
@@ -34,8 +34,8 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
pkgtype = 'rpm'
pkgtool = ("rpm --oldpackage --replacepkgs --quiet -U %s", ("%s", ["url"]))
- def __init__(self, logger, setup, config, states):
- Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config, states)
+ def __init__(self, logger, setup, config):
+ Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config)
self.instance_status = {}
self.extra_instances = []
@@ -524,7 +524,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
return fix
- def Install(self, packages):
+ def Install(self, packages, states):
'''
Try and fix everything that RPMng.VerifyPackages() found wrong for
each Package Entry. This can result in individual RPMs being
@@ -532,14 +532,14 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
or upgraded.
packages is a list of Package Elements that has
- self.states[<Package Element>] == False
+ states[<Package Element>] == False
The following effects occur:
- - self.states{} is conditionally updated for each package.
+ - states{} is conditionally updated for each package.
- self.installed{} is rebuilt, possibly multiple times.
- self.instance_statusi{} is conditionally updated for each instance
of a package.
- - Each package will be added to self.modified[] if its self.states{}
+ - Each package will be added to self.modified[] if its states{}
entry is set to True.
'''
self.logger.info('Runing RPMng.Install()')
@@ -628,7 +628,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
self.RefreshPackages()
self.gpg_keyids = self.getinstalledgpg()
pkg = self.instance_status[gpg_keys[0]].get('pkg')
- self.states[pkg] = self.VerifyPackage(pkg, [])
+ states[pkg] = self.VerifyPackage(pkg, [])
# Fix upgradeable packages.
if len(upgrade_pkgs) > 0:
@@ -669,10 +669,10 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
if not self.setup['kevlar']:
for pkg_entry in packages:
self.logger.debug("Reverifying Failed Package %s" % (pkg_entry.get('name')))
- self.states[pkg_entry] = self.VerifyPackage(pkg_entry, \
- self.modlists.get(pkg_entry, []))
+ states[pkg_entry] = self.VerifyPackage(pkg_entry, \
+ self.modlists.get(pkg_entry, []))
- for entry in [ent for ent in packages if self.states[ent]]:
+ for entry in [ent for ent in packages if states[ent]]:
self.modified.append(entry)
def canInstall(self, entry):
diff --git a/src/lib/Client/Tools/SMF.py b/src/lib/Client/Tools/SMF.py
index e2ad2f80b..455e5af60 100644
--- a/src/lib/Client/Tools/SMF.py
+++ b/src/lib/Client/Tools/SMF.py
@@ -112,7 +112,7 @@ class SMF(Bcfg2.Client.Tools.Tool):
return [Bcfg2.Client.XML.Element("Service", type='smf', name=name) \
for name in allsrv]
- def BundleUpdated(self, bundle):
+ def BundleUpdated(self, bundle, states):
'''Restart smf services'''
for entry in [entry for entry in bundle if self.handlesEntry(entry)]:
if not self.canInstall(entry):
diff --git a/src/lib/Client/Tools/SYSV.py b/src/lib/Client/Tools/SYSV.py
index fb2e71dd2..42147c786 100644
--- a/src/lib/Client/Tools/SYSV.py
+++ b/src/lib/Client/Tools/SYSV.py
@@ -29,8 +29,8 @@ class SYSV(Bcfg2.Client.Tools.PkgTool):
pkgtype = 'sysv'
pkgtool = ("/usr/sbin/pkgadd %s -n -d %%s", (('%s %s', ['url', 'name'])))
- def __init__(self, logger, setup, config, states):
- Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config, states)
+ def __init__(self, logger, setup, config):
+ Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config)
self.noaskname = tempfile.mktemp()
try:
open(self.noaskname, 'w+').write(noask)
diff --git a/src/lib/Client/Tools/YUMng.py b/src/lib/Client/Tools/YUMng.py
index 7bf6e8bc7..d41c27425 100644
--- a/src/lib/Client/Tools/YUMng.py
+++ b/src/lib/Client/Tools/YUMng.py
@@ -49,7 +49,7 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng):
conflicts = ['RPMng']
- def Install(self, packages):
+ def Install(self, packages, states):
'''
Try and fix everything that RPMng.VerifyPackages() found wrong for
each Package Entry. This can result in individual RPMs being
@@ -60,14 +60,14 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng):
installed.
packages is a list of Package Elements that has
- self.states[<Package Element>] == False
+ states[<Package Element>] == False
The following effects occur:
- - self.states{} is conditionally updated for each package.
+ - states{} is conditionally updated for each package.
- self.installed{} is rebuilt, possibly multiple times.
- self.instance_status{} is conditionally updated for each instance
of a package.
- - Each package will be added to self.modified[] if its self.states{}
+ - Each package will be added to self.modified[] if its states{}
entry is set to True.
'''
self.logger.info('Running YUMng.Install()')
@@ -124,7 +124,7 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng):
self.RefreshPackages()
self.gpg_keyids = self.getinstalledgpg()
pkg = self.instance_status[gpg_keys[0]].get('pkg')
- self.states[pkg] = self.VerifyPackage(pkg, [])
+ states[pkg] = self.VerifyPackage(pkg, [])
# Install packages.
if len(install_pkgs) > 0:
@@ -241,10 +241,10 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng):
if not self.setup['kevlar']:
for pkg_entry in [p for p in packages if self.canVerify(p)]:
self.logger.debug("Reverifying Failed Package %s" % (pkg_entry.get('name')))
- self.states[pkg_entry] = self.VerifyPackage(pkg_entry, \
- self.modlists.get(pkg_entry, []))
+ states[pkg_entry] = self.VerifyPackage(pkg_entry, \
+ self.modlists.get(pkg_entry, []))
- for entry in [ent for ent in packages if self.states[ent]]:
+ for entry in [ent for ent in packages if states[ent]]:
self.modified.append(entry)
def RemovePackages(self, packages):
diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py
index c4427b25e..4caf1abcd 100644
--- a/src/lib/Client/Tools/__init__.py
+++ b/src/lib/Client/Tools/__init__.py
@@ -70,14 +70,13 @@ class Tool:
__req__ = {}
__important__ = []
- def __init__(self, logger, setup, config, states):
+ def __init__(self, logger, setup, config):
self.setup = setup
self.logger = logger
if not hasattr(self, '__ireq__'):
self.__ireq__ = self.__req__
self.config = config
self.cmd = executor(logger)
- self.states = states
self.modified = []
self.extra = []
self.handled = [entry for struct in self.config for entry in struct \
@@ -95,15 +94,15 @@ class Tool:
self.logger.debug("%s failed" % filename, exc_info=1)
raise toolInstantiationError
- def BundleUpdated(self, _):
+ def BundleUpdated(self, _, states):
'''This callback is used when bundle updates occur'''
return
- def BundleNotUpdated(self, _):
+ def BundleNotUpdated(self, _, states):
'''This callback is used when a bundle is not updated'''
return
- def Inventory(self, structures=[]):
+ def Inventory(self, states, structures=[]):
'''Dispatch verify calls to underlying methods'''
if not structures:
structures = self.config.getchildren()
@@ -114,19 +113,19 @@ class Tool:
func = getattr(self, "Verify%s" % (entry.tag))
mods = self.buildModlist(entry, struct)
mods += [c.get('name') for c in entry.findall("Ignore")]
- self.states[entry] = func(entry, mods)
+ states[entry] = func(entry, mods)
except:
self.logger.error(
"Unexpected failure of verification method for entry type %s" \
% (entry.tag), exc_info=1)
self.extra = self.FindExtra()
- def Install(self, entries):
+ def Install(self, entries, states):
'''Install all entries in sublist'''
for entry in entries:
try:
func = getattr(self, "Install%s" % (entry.tag))
- self.states[entry] = func(entry)
+ states[entry] = func(entry)
self.modified.append(entry)
except:
self.logger.error("Unexpected failure of install method for entry type %s" \
@@ -201,8 +200,8 @@ class PkgTool(Tool):
pkgtype = 'echo'
__name__ = 'PkgTool'
- def __init__(self, logger, setup, config, states):
- Tool.__init__(self, logger, setup, config, states)
+ def __init__(self, logger, setup, config):
+ Tool.__init__(self, logger, setup, config)
self.installed = {}
self.Remove = self.RemovePackages
self.FindExtra = self.FindExtraPackages
@@ -212,7 +211,7 @@ class PkgTool(Tool):
'''Dummy verification method'''
return False
- def Install(self, packages):
+ def Install(self, packages, states):
'''Run a one-pass install, followed by single pkg installs in case of failure'''
self.logger.info("Trying single pass package install for pkgtype %s" % \
self.pkgtype)
@@ -228,11 +227,12 @@ class PkgTool(Tool):
self.logger.info("Single Pass Succeded")
# set all package states to true and flush workqueues
pkgnames = [pkg.get('name') for pkg in packages]
- for entry in [entry for entry in self.states.keys()
- if entry.tag == 'Package' and entry.get('type') == self.pkgtype
+ for entry in [entry for entry in states.keys()
+ if entry.tag == 'Package'
+ and entry.get('type') == self.pkgtype
and entry.get('name') in pkgnames]:
self.logger.debug('Setting state to true for pkg %s' % (entry.get('name')))
- self.states[entry] = True
+ states[entry] = True
self.RefreshPackages()
else:
self.logger.error("Single Pass Failed")
@@ -242,7 +242,7 @@ class PkgTool(Tool):
# handle state tracking updates
if self.VerifyPackage(pkg, []):
self.logger.info("Forcing state to true for pkg %s" % (pkg.get('name')))
- self.states[pkg] = True
+ states[pkg] = True
else:
self.logger.info("Installing pkg %s version %s" %
(pkg.get('name'), pkg.get('version')))
@@ -250,11 +250,11 @@ class PkgTool(Tool):
(self.pkgtool[1][0] %
tuple([pkg.get(field) for field in self.pkgtool[1][1]])))
if cmdrc[0] == 0:
- self.states[pkg] = True
+ states[pkg] = True
else:
self.logger.error("Failed to install package %s" % (pkg.get('name')))
self.RefreshPackages()
- for entry in [ent for ent in packages if self.states[ent]]:
+ for entry in [ent for ent in packages if states[ent]]:
self.modified.append(entry)
def RefreshPackages(self):
@@ -278,7 +278,7 @@ class SvcTool(Tool):
__name__ = 'SvcTool'
__svcrestart__ = 'reload'
- def BundleUpdated(self, bundle):
+ def BundleUpdated(self, bundle, states):
'''The Bundle has been updated'''
for entry in bundle:
if self.handlesEntry(entry):
diff --git a/src/lib/Client/Tools/launchd.py b/src/lib/Client/Tools/launchd.py
index 3a8a07f05..84ed4177e 100644
--- a/src/lib/Client/Tools/launchd.py
+++ b/src/lib/Client/Tools/launchd.py
@@ -82,7 +82,7 @@ class launchd(Bcfg2.Client.Tools.Tool):
in self.getSupportedEntries()] if svc in allsrv]
return [Bcfg2.Client.XML.Element("Service", type='launchd', name=name, status='on') for name in allsrv]
- def BundleUpdated(self, bundle):
+ def BundleUpdated(self, bundle, states):
'''Reload launchd plist'''
for entry in [entry for entry in bundle if self.handlesEntry(entry)]:
if not self.canInstall(entry):