summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Client/Frame.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Client/Frame.py')
-rw-r--r--src/lib/Bcfg2/Client/Frame.py48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/lib/Bcfg2/Client/Frame.py b/src/lib/Bcfg2/Client/Frame.py
index 6ef686c10..11a82fcc0 100644
--- a/src/lib/Bcfg2/Client/Frame.py
+++ b/src/lib/Bcfg2/Client/Frame.py
@@ -6,8 +6,8 @@ import fnmatch
import logging
import Bcfg2.Client.Tools
from Bcfg2.Client import prompt
-from Bcfg2.Compat import any, all # pylint: disable=W0622
from Bcfg2.Options import get_option_parser
+from Bcfg2.Compat import any, all, cmp # pylint: disable=W0622
def cmpent(ent1, ent2):
@@ -67,8 +67,8 @@ class Frame(object):
self.logger = logging.getLogger(__name__)
drivers = self.setup['drivers']
for driver in drivers[:]:
- if driver not in Bcfg2.Client.Tools.__all__ and \
- isinstance(driver, str):
+ if (driver not in Bcfg2.Client.Tools.__all__ and
+ isinstance(driver, str)):
self.logger.error("Tool driver %s is not available" % driver)
drivers.remove(driver)
@@ -134,7 +134,7 @@ class Frame(object):
if entry.tag == 'Package']
if pkgs:
self.logger.debug("The following packages are specified in bcfg2:")
- self.logger.debug([pkg[0] for pkg in pkgs if pkg[1] == None])
+ self.logger.debug([pkg[0] for pkg in pkgs if pkg[1] is None])
self.logger.debug("The following packages are prereqs added by "
"Packages:")
self.logger.debug([pkg[0] for pkg in pkgs if pkg[1] == 'Packages'])
@@ -193,19 +193,19 @@ class Frame(object):
"""
# Need to process decision stuff early so that dryrun mode
# works with it
- self.whitelist = [entry for entry in self.states \
+ self.whitelist = [entry for entry in self.states
if not self.states[entry]]
if not self.setup['file']:
if self.setup['decision'] == 'whitelist':
dwl = self.setup['decision_list']
- w_to_rem = [e for e in self.whitelist \
+ w_to_rem = [e for e in self.whitelist
if not matches_white_list(e, dwl)]
if w_to_rem:
self.logger.info("In whitelist mode: "
"suppressing installation of:")
self.logger.info(["%s:%s" % (e.tag, e.get('name'))
for e in w_to_rem])
- self.whitelist = [x for x in self.whitelist \
+ self.whitelist = [x for x in self.whitelist
if x not in w_to_rem]
elif self.setup['decision'] == 'blacklist':
b_to_rem = \
@@ -236,7 +236,7 @@ class Frame(object):
cfile not in self.whitelist):
continue
tools = [t for t in self.tools
- if t.handlesEntry(cfile) and t.canVerify(cfile)]
+ if t.handlesEntry(cfile) and t.canVerify(cfile)]
if not tools:
continue
if (self.setup['interactive'] and not
@@ -395,8 +395,8 @@ class Frame(object):
"""Install all entries."""
self.DispatchInstallCalls(self.whitelist)
mods = self.modified
- mbundles = [struct for struct in self.config.findall('Bundle') if \
- [mod for mod in mods if mod in struct]]
+ mbundles = [struct for struct in self.config.findall('Bundle')
+ if any(True for mod in mods if mod in struct)]
if self.modified:
# Handle Bundle interdeps
@@ -411,33 +411,34 @@ class Frame(object):
self.logger.error("%s.Inventory() call failed:" %
tool.name,
exc_info=1)
- clobbered = [entry for bundle in mbundles for entry in bundle \
+ clobbered = [entry for bundle in mbundles for entry in bundle
if (not self.states[entry] and
entry not in self.blacklist)]
if clobbered:
self.logger.debug("Found clobbered entries:")
- self.logger.debug(["%s:%s" % (entry.tag, entry.get('name')) \
+ self.logger.debug(["%s:%s" % (entry.tag, entry.get('name'))
for entry in clobbered])
if not self.setup['interactive']:
self.DispatchInstallCalls(clobbered)
for bundle in self.config.findall('.//Bundle'):
- if self.setup['bundle'] and \
- bundle.get('name') not in self.setup['bundle']:
+ if (self.setup['bundle'] and
+ bundle.get('name') not in self.setup['bundle']):
# prune out unspecified bundles when running with -b
continue
+ if bundle in mbundles:
+ self.logger.debug("Bundle %s was modified" % bundle)
+ func = "BundleUpdated"
+ else:
+ self.logger.debug("Bundle %s was not modified" % bundle)
+ func = "BundleNotUpdated"
for tool in self.tools:
- if bundle in mbundles:
- func = tool.BundleUpdated
- else:
- func = tool.BundleNotUpdated
try:
- self.states.update(func(bundle))
+ self.states.update(getattr(tool, func)(bundle))
except:
self.logger.error("%s.%s(%s:%s) call failed:" %
- (tool.name, func.im_func.func_name,
- bundle.tag, bundle.get("name")),
- exc_info=1)
+ (tool.name, func, bundle.tag,
+ bundle.get("name")), exc_info=1)
for indep in self.config.findall('.//Independent'):
for tool in self.tools:
@@ -468,7 +469,8 @@ class Frame(object):
self.logger.info('Incorrect entries: %d' %
list(self.states.values()).count(False))
if phase == 'final' and list(self.states.values()).count(False):
- for entry in self.states.keys():
+ for entry in sorted(self.states.keys(), key=lambda e: e.tag + ":" +
+ e.get('name')):
if not self.states[entry]:
etype = entry.get('type')
if etype: