diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/bcfg2-profile-templates.py | 15 | ||||
-rwxr-xr-x | tools/export.py | 38 | ||||
-rwxr-xr-x | tools/upgrade/1.3/migrate_dbstats.py | 3 | ||||
-rwxr-xr-x | tools/upgrade/1.3/migrate_info.py | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | tools/upgrade/1.3/migrate_perms_to_mode.py | 20 |
5 files changed, 48 insertions, 34 deletions
diff --git a/tools/bcfg2-profile-templates.py b/tools/bcfg2-profile-templates.py index cc7a1a3d8..3cd3786f9 100755 --- a/tools/bcfg2-profile-templates.py +++ b/tools/bcfg2-profile-templates.py @@ -4,7 +4,6 @@ import os import sys import time -import signal import logging import operator import Bcfg2.Logger @@ -13,19 +12,6 @@ import Bcfg2.Server.Core LOGGER = None -def get_sigint_handler(core): - """ Get a function that handles SIGINT/Ctrl-C by shutting down the - core and exiting properly.""" - - def hdlr(sig, frame): # pylint: disable=W0613 - """ Handle SIGINT/Ctrl-C by shutting down the core and exiting - properly. """ - core.shutdown() - os._exit(1) # pylint: disable=W0212 - - return hdlr - - def main(): optinfo = \ dict(client=Bcfg2.Options.Option("Benchmark templates for one client", @@ -53,7 +39,6 @@ def main(): logger = logging.getLogger(sys.argv[0]) core = Bcfg2.Server.Core.BaseCore(setup) - signal.signal(signal.SIGINT, get_sigint_handler(core)) logger.info("Bcfg2 server core loaded") core.fam.handle_events_in_interval(0.1) logger.debug("Repository events processed") diff --git a/tools/export.py b/tools/export.py index 33c42d238..716c831d9 100755 --- a/tools/export.py +++ b/tools/export.py @@ -164,11 +164,17 @@ E.G. 1.2.0pre1 is a valid version. print(help_message) quit() - rpmchangelog = ["* %s %s <%s> %s-0.0%s\n" % - (datetime.datetime.now().strftime("%a %b %d %Y"), - name, email, - version_release, version_info['build']), - "- New upstream release\n", "\n"] + if version_info['build'] == '': + rpmchangelog = ["* %s %s <%s> %s-1\n" % + (datetime.datetime.now().strftime("%a %b %d %Y"), + name, email, version_release), + "- New upstream release\n", "\n"] + else: + rpmchangelog = ["* %s %s <%s> %s-0.%s.%s\n" % + (datetime.datetime.now().strftime("%a %b %d %Y"), + name, email, version_release, + version_info['build'][-1], version_info['build']), + "- New upstream release\n", "\n"] # write out the new RPM changelog specs = ["misc/bcfg2.spec", "misc/bcfg2-selinux.spec", "redhat/bcfg2.spec.in"] @@ -236,12 +242,22 @@ E.G. 1.2.0pre1 is a valid version. find_and_replace('misc/bcfg2-selinux.spec', 'Version:', 'Version: %s\n' % version_release, dryrun=options.dryrun) - find_and_replace('misc/bcfg2.spec', 'Release: ', - 'Release: 0.0%s\n' % version_info['build'], - dryrun=options.dryrun) - find_and_replace('misc/bcfg2-selinux.spec', 'Release: ', - 'Release: 0.0%s\n' % version_info['build'], - dryrun=options.dryrun) + if version_info['build'] == '': + find_and_replace('misc/bcfg2.spec', 'Release: ', + 'Release: 1\n', + dryrun=options.dryrun) + find_and_replace('misc/bcfg2-selinux.spec', 'Release: ', + 'Release: 1\n', + dryrun=options.dryrun) + else: + find_and_replace('misc/bcfg2.spec', 'Release: ', + 'Release: 0.%s.%s\n' % + (version_info['build'][-1], version_info['build']), + dryrun=options.dryrun) + find_and_replace('misc/bcfg2-selinux.spec', 'Release: ', + 'Release: 0.%s.%s\n' % + (version_info['build'][-1], version_info['build']), + dryrun=options.dryrun) find_and_replace('misc/bcfg2.spec', '%setup', '%%setup -q -n %%{name}-%%{version}%s\n' % version_info['build'], diff --git a/tools/upgrade/1.3/migrate_dbstats.py b/tools/upgrade/1.3/migrate_dbstats.py index 69d9514df..cbd2a6099 100755 --- a/tools/upgrade/1.3/migrate_dbstats.py +++ b/tools/upgrade/1.3/migrate_dbstats.py @@ -246,6 +246,9 @@ def _restructure(): failures = [] int_count = legacy_models.Interaction.objects.count() + if int_count == 0: + logger.error("Found no legacy interactions") + return False int_ctr = 0 start_time = 0 for inter in BatchFetch(legacy_models.Interaction.objects.\ diff --git a/tools/upgrade/1.3/migrate_info.py b/tools/upgrade/1.3/migrate_info.py index 5ff4b73b7..e72599daf 100755 --- a/tools/upgrade/1.3/migrate_info.py +++ b/tools/upgrade/1.3/migrate_info.py @@ -4,7 +4,8 @@ import os import sys import lxml.etree import Bcfg2.Options -from Bcfg2.Server.Plugin import info_regex +from Bcfg2.Server.Plugin import INFO_REGEX + def convert(info_file): info_xml = os.path.join(os.path.dirname(info_file), "info.xml") @@ -15,7 +16,7 @@ def convert(info_file): fileinfo = lxml.etree.Element("FileInfo") info = lxml.etree.SubElement(fileinfo, "Info") for line in open(info_file).readlines(): - match = info_regex.match(line) + match = INFO_REGEX.match(line) if match: mgd = match.groupdict() for key, value in list(mgd.items()): @@ -25,6 +26,7 @@ def convert(info_file): open(info_xml, "w").write(lxml.etree.tostring(fileinfo, pretty_print=True)) os.unlink(info_file) + def main(): opts = dict(repo=Bcfg2.Options.SERVER_REPOSITORY, configfile=Bcfg2.Options.CFILE, diff --git a/tools/upgrade/1.3/migrate_perms_to_mode.py b/tools/upgrade/1.3/migrate_perms_to_mode.py index 0aa9c574c..e061558d3 100644..100755 --- a/tools/upgrade/1.3/migrate_perms_to_mode.py +++ b/tools/upgrade/1.3/migrate_perms_to_mode.py @@ -24,7 +24,12 @@ def writefile(f, xdata): def convertinfo(ifile): """Do perms -> mode conversion for info.xml files.""" - xdata = lxml.etree.parse(ifile) + try: + xdata = lxml.etree.parse(ifile) + except lxml.etree.XMLSyntaxError: + err = sys.exc_info()[1] + print("Could not parse %s, skipping: %s" % (ifile, err)) + return found = False for i in xdata.findall('//Info'): found = setmodeattr(i) @@ -34,11 +39,14 @@ def convertinfo(ifile): def convertstructure(structfile): """Do perms -> mode conversion for structure files.""" - xdata = lxml.etree.parse(structfile) + try: + xdata = lxml.etree.parse(structfile) + except lxml.etree.XMLSyntaxError: + err = sys.exc_info()[1] + print("Could not parse %s, skipping: %s" % (structfile, err)) + return found = False - for path in xdata.findall('//BoundPath'): - found = setmodeattr(path) - for path in xdata.findall('//Path'): + for path in xdata.xpath('//BoundPath|//Path'): found = setmodeattr(path) if found: writefile(structfile, xdata) @@ -57,7 +65,7 @@ def main(): for root, dirs, files in os.walk(os.path.join(repo, plugin)): for fname in files: convertstructure(os.path.join(root, fname)) - if plugin not in ['Cfg', 'TGenshi', 'TCheetah']: + if plugin not in ['Cfg', 'TGenshi', 'TCheetah', 'SSHbase', 'SSLCA']: continue for root, dirs, files in os.walk(os.path.join(repo, plugin)): for fname in files: |