diff options
Diffstat (limited to 'tools/upgrade')
-rwxr-xr-x | tools/upgrade/1.3/migrate_configs.py | 8 | ||||
-rwxr-xr-x | tools/upgrade/1.3/migrate_dbstats.py | 9 | ||||
-rwxr-xr-x | tools/upgrade/1.3/migrate_perms_to_mode.py | 15 |
3 files changed, 23 insertions, 9 deletions
diff --git a/tools/upgrade/1.3/migrate_configs.py b/tools/upgrade/1.3/migrate_configs.py index b7adb2528..76b2392e7 100755 --- a/tools/upgrade/1.3/migrate_configs.py +++ b/tools/upgrade/1.3/migrate_configs.py @@ -16,13 +16,13 @@ def copy_section(src_file, tgt_cfg, section, newsection=None): tgt_cfg.add_section(newsection) except ConfigParser.DuplicateSectionError: print("[%s] section already exists in %s, adding options" % - (newsection, setup['cfile'])) + (newsection, setup['configfile'])) for opt in cfg.options(section): val = cfg.get(section, opt) if tgt_cfg.has_option(newsection, opt): print("%s in [%s] already populated in %s, skipping" % - (opt, newsection, setup['cfile'])) - print(" %s: %s" % (setup['cfile'], + (opt, newsection, setup['configfile'])) + print(" %s: %s" % (setup['configfile'], tgt_cfg.get(newsection, opt))) print(" %s: %s" % (src_file, val)) else: @@ -43,7 +43,7 @@ def main(): if os.path.exists(rules_conf): remove.append(rules_conf) copy_section(rules_conf, setup.cfp, "rules") - + # move packages config out of packages.conf and into bcfg2.conf pkgs_conf = os.path.join(setup['repo'], 'Packages', 'packages.conf') if os.path.exists(pkgs_conf): diff --git a/tools/upgrade/1.3/migrate_dbstats.py b/tools/upgrade/1.3/migrate_dbstats.py index 07def2ac8..34430e3df 100755 --- a/tools/upgrade/1.3/migrate_dbstats.py +++ b/tools/upgrade/1.3/migrate_dbstats.py @@ -10,11 +10,12 @@ import time import Bcfg2.Logger import Bcfg2.Options from django.core.cache import cache -from django.db import connection, transaction, backend +from django.db import connection, backend from Bcfg2.Server.Admin.Reports import Reports from Bcfg2.Reporting import models as new_models from Bcfg2.Reporting.utils import BatchFetch +from Bcfg2.Reporting.Compat import transaction from Bcfg2.Server.Reports.reports import models as legacy_models logger = logging.getLogger(__name__) @@ -38,7 +39,7 @@ def _quote(value): return _our_backend.quote_name(value) -@transaction.commit_on_success +@transaction.atomic def _migrate_perms(): """helper""" @@ -57,7 +58,7 @@ def _migrate_perms(): return fperms -@transaction.commit_on_success +@transaction.atomic def _migrate_transaction(inter, entries, fperms): """helper""" @@ -187,7 +188,7 @@ def _shove(old_table, new_table, columns): cursor.close() -@transaction.commit_on_success +@transaction.atomic def migrate_stage1(): logger.info("Migrating clients") try: diff --git a/tools/upgrade/1.3/migrate_perms_to_mode.py b/tools/upgrade/1.3/migrate_perms_to_mode.py index 18abffec2..ee440bc8e 100755 --- a/tools/upgrade/1.3/migrate_perms_to_mode.py +++ b/tools/upgrade/1.3/migrate_perms_to_mode.py @@ -3,7 +3,8 @@ import lxml.etree import os import sys - +from fnmatch import fnmatch +from Bcfg2.Compat import any import Bcfg2.Options @@ -53,9 +54,15 @@ def convertstructure(structfile): writefile(structfile, xdata) +def skip_path(path, setup): + return any(fnmatch(path, p) or fnmatch(os.path.basename(path), p) + for p in setup['ignore']) + + def main(): opts = dict(repo=Bcfg2.Options.SERVER_REPOSITORY, configfile=Bcfg2.Options.CFILE, + ignore=Bcfg2.Options.SERVER_FAM_IGNORE, plugins=Bcfg2.Options.SERVER_PLUGINS) setup = Bcfg2.Options.OptionParser(opts) setup.parse(sys.argv[1:]) @@ -64,11 +71,17 @@ def main(): for plugin in setup['plugins']: if plugin in ['Base', 'Bundler', 'Rules']: for root, dirs, files in os.walk(os.path.join(repo, plugin)): + if skip_path(root, setup): + continue for fname in files: + if skip_path(fname, setup): + continue convertstructure(os.path.join(root, fname)) if plugin not in ['Cfg', 'TGenshi', 'TCheetah', 'SSHbase', 'SSLCA']: continue for root, dirs, files in os.walk(os.path.join(repo, plugin)): + if skip_path(root, setup): + continue for fname in files: if fname == 'info.xml': convertinfo(os.path.join(root, fname)) |