summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2006-03-09 20:23:35 +0000
committerNarayan Desai <desai@mcs.anl.gov>2006-03-09 20:23:35 +0000
commit5e494a8be31724d0b2f990f60337c83e545d4c1e (patch)
tree89aa1e4b25395b776a41a77d2c33f91fc5e925cc
parent40c0c342fcdd1cea0b9b8972ea539d7368b85f82 (diff)
downloadbcfg2-5e494a8be31724d0b2f990f60337c83e545d4c1e.tar.gz
bcfg2-5e494a8be31724d0b2f990f60337c83e545d4c1e.tar.bz2
bcfg2-5e494a8be31724d0b2f990f60337c83e545d4c1e.zip
* Remove messages describing extra configuration elements when running in bundle mode
* Handle garbage filenames in Cfg more gracefully git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1799 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Client/Debian.py10
-rw-r--r--src/lib/Client/Toolset.py35
-rw-r--r--src/lib/Server/Plugins/Cfg.py7
-rwxr-xr-xsrc/sbin/bcfg24
4 files changed, 44 insertions, 12 deletions
diff --git a/src/lib/Client/Debian.py b/src/lib/Client/Debian.py
index 7b915edc4..72a47a82f 100644
--- a/src/lib/Client/Debian.py
+++ b/src/lib/Client/Debian.py
@@ -124,8 +124,9 @@ class ToolsetImpl(Bcfg2.Client.Toolset.Toolset):
if not self.saferun("apt-get remove -y --force-yes %s" % " ".join(self.pkgwork['remove']))[0]:
self.pkgwork['remove'] = []
else:
- self.logger.info("Need to remove packages:")
- self.logger.info(self.pkgwork['remove'])
+ if not self.setup['bundle']:
+ self.logger.info("Need to remove packages:")
+ self.logger.info(self.pkgwork['remove'])
if len(self.extra_services) > 0:
if self.setup['remove'] in ['all', 'services']:
@@ -134,6 +135,7 @@ class ToolsetImpl(Bcfg2.Client.Toolset.Toolset):
[self.extra_services.remove(serv) for serv in self.extra_services if
not self.saferun("rm -f /etc/rc*.d/S??%s" % serv)[0]]
else:
- self.logger.info('Need to remove services:')
- self.logger.info(self.extra_services)
+ if not self.setup['bundle']:
+ self.logger.info('Need to remove services:')
+ self.logger.info(self.extra_services)
diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py
index 067f50926..5341d3c84 100644
--- a/src/lib/Client/Toolset.py
+++ b/src/lib/Client/Toolset.py
@@ -5,7 +5,7 @@ from stat import S_ISVTX, S_ISGID, S_ISUID, S_IXUSR, S_IWUSR, S_IRUSR, S_IXGRP
from stat import S_IWGRP, S_IRGRP, S_IXOTH, S_IWOTH, S_IROTH, ST_MODE, S_ISDIR
from stat import S_IFREG, ST_UID, ST_GID, S_ISREG, S_IFDIR, S_ISLNK
-import binascii, copy, grp, logging, lxml.etree, os, popen2, pwd, stat, sys
+import binascii, copy, grp, logging, lxml.etree, os, popen2, pwd, stat, sys, ConfigParser, cStringIO
def calcPerms(initial, perms):
'''This compares ondisk permissions with specified ones'''
@@ -62,6 +62,27 @@ class Toolset(object):
self.VerifyEntry(cfile)
if not self.states[cfile]:
self.InstallConfigFile(cfile)
+ self.statistics = lxml.etree.Element("Statistics")
+ # handle $Revision string processing here
+ cfp = ConfigParser.ConfigParser()
+ cfp.read('/etc/bcfg2.conf')
+ initial = ''
+ try:
+ initial = cfp.get('Specification', 'Revision')
+ except ConfigParser.NoOptionError:
+ pass
+ self.statistics.set('initial', initial)
+ goal = ''
+ upstream = [cfl for cfl in cfg.findall(".//ConfigFile") if cfg.get('name') == '/etc/bcfg2.conf']
+ if upstream:
+ cfp = ConfigParser.ConfigParser()
+ cfp.readfp(cStringIO.StringIO(upstream[0].text))
+ try:
+ goal = cfp.get('Specification', 'Revision')
+ except ConfigParser.NoOptionError:
+ pass
+ if goal != initial:
+ self.logger.info("Specification revision: %s should be upgraded to %s" % (initial, goal))
def saferun(self, command):
'''Run a command in a pipe dealing with stdout buffer overloads'''
@@ -86,7 +107,8 @@ class Toolset(object):
self.logger.info('Correct entries:\t%d' % self.states.values().count(True))
self.logger.info('Incorrect entries:\t%d' % self.states.values().count(False))
self.logger.info('Total managed entries:\t%d' % len(self.states.values()))
- self.logger.info('Unmanaged entries:\t%d' % len(self.pkgwork['remove']))
+ if not self.setup['bundle']:
+ self.logger.info('Unmanaged entries:\t%d' % len(self.pkgwork['remove']))
if ((self.states.values().count(False) > 0) and not self.pkgwork['remove']):
self.logger.info('All entries correct.')
@@ -541,9 +563,12 @@ class Toolset(object):
# Print pass info
self.logger.info("Starting pass %s" % (count))
self.logger.info("%s Entries left" % (len(work)))
- self.logger.info("%s new, %s update, %s remove" %
- (len(self.pkgwork['add']), len(self.pkgwork['update']),
- len(self.pkgwork['remove'])))
+ if self.setup['bundle']:
+ self.logger.info("%s new, %s update" % (len(self.pkgwork['add']), len(self.pkgwork['update'])))
+ else:
+ self.logger.info("%s new, %s update, %s remove" %
+ (len(self.pkgwork['add']), len(self.pkgwork['update']),
+ len(self.pkgwork['remove'])))
# Update counters
count = count + 1
diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py
index 157243e50..73e078748 100644
--- a/src/lib/Server/Plugins/Cfg.py
+++ b/src/lib/Server/Plugins/Cfg.py
@@ -105,7 +105,12 @@ class ConfigFileEntry(object):
def AddEntry(self, name):
'''add new file additions for a single cf file'''
- if name[-5:] == ':info':
+ basename = name.split('/')[-1]
+ rbasename = self.repopath.split('/')[-1]
+ if not ((basename == ':info') or (basename[:len(rbasename)] == rbasename)):
+ logger.error("Confused about file %s; ignoring" % (name))
+ return
+ if basename == ':info':
return self.read_info()
try:
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2
index 3c97e8bab..5b9270595 100755
--- a/src/sbin/bcfg2
+++ b/src/sbin/bcfg2
@@ -349,7 +349,7 @@ class Client:
if self.setup['bundle']:
replacement_xml = Element("Configuration", version='2.0')
- for child in self.config.getroot().getchildren():
+ for child in self.config.getchildren():
if ((child.tag == 'Bundle') and
(child.attrib['name'] == self.setup['bundle'])):
replacement_xml.append(child)
@@ -376,7 +376,7 @@ class Client:
times['install'] = time.time()
times['finished'] = time.time()
- if not self.setup['file']:
+ if not self.setup['file'] and not self.setup['bundle']:
# upload statistics
feedback = Element("upload-statistics")
timeinfo = Element("OpStamps")