diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/README | 16 | ||||
-rw-r--r-- | tools/upgrade/1.1/posixunified.py (renamed from tools/posixunified.py) | 0 | ||||
-rwxr-xr-x | tools/upgrade/1.2/nagiosgen-convert.py (renamed from tools/nagiosgen-convert.py) | 0 | ||||
-rwxr-xr-x | tools/upgrade/1.2/packages-convert.py (renamed from tools/packages-convert.py) | 0 | ||||
-rwxr-xr-x | tools/upgrade/1.3/migrate_configs.py | 54 |
5 files changed, 59 insertions, 11 deletions
diff --git a/tools/README b/tools/README index deb04bf3f..738ec1731 100644 --- a/tools/README +++ b/tools/README @@ -66,12 +66,6 @@ hostbase.py {-l|-c} <hostname> hostinfo.py {-q <query>|--showfields} - Query the hostbase databse -nagios-convert.py - - Convert 1.1.x-style NagiosGen config to 1.2.x-style - -packages-convert.py - - Convert 1.1.x-style Packages config to 1.2.x-style - pkgmgr_gen.py - Generate Pkgmgr XML files from a list of directories that contain RPMS @@ -80,14 +74,14 @@ pkgmgr_update.py - Update Pkgmgr XML files from a list of directories that contain RPMS -posixunified.py - - Convert 1.0.x-style Rules, Bundler, and Base configs to 1.1.x - POSIX unified-style configs (i.e., ConfigFile, Directory, - Permissions, and SymLink all become Path entries) - rpmlisting.py - ??? +upgrade + - This directory contains scripts used to upgrade to the specified + version. E.g., upgrade/1.2 has scripts needed to upgrade to + Bcfg2 1.2.x from bcfg2 1.1.x + yum-listpkgs.xml.py - Produces a list of all packages installed and available in a format suitable for use by Packages or Pkgmgr diff --git a/tools/posixunified.py b/tools/upgrade/1.1/posixunified.py index 8eb4ed734..8eb4ed734 100644 --- a/tools/posixunified.py +++ b/tools/upgrade/1.1/posixunified.py diff --git a/tools/nagiosgen-convert.py b/tools/upgrade/1.2/nagiosgen-convert.py index 2c2142735..2c2142735 100755 --- a/tools/nagiosgen-convert.py +++ b/tools/upgrade/1.2/nagiosgen-convert.py diff --git a/tools/packages-convert.py b/tools/upgrade/1.2/packages-convert.py index c7b43279f..c7b43279f 100755 --- a/tools/packages-convert.py +++ b/tools/upgrade/1.2/packages-convert.py diff --git a/tools/upgrade/1.3/migrate_configs.py b/tools/upgrade/1.3/migrate_configs.py new file mode 100755 index 000000000..c6e6cd2c3 --- /dev/null +++ b/tools/upgrade/1.3/migrate_configs.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +import os +import sys +from Bcfg2.Bcfg2Py3k import ConfigParser +import Bcfg2.Options + +def copy_section(src_file, tgt_cfg, section, newsection=None): + if newsection is None: + newsection = section + + cfg = ConfigParser.ConfigParser() + if len(cfg.read(src_file)) == 1: + if cfg.has_section(section): + try: + tgt_cfg.add_section(newsection) + except ConfigParser.DuplicateSectionError: + print("[%s] section already exists in %s, adding options" % + (newsection, setup['cfile'])) + 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'], + tgt_cfg.get(newsection, opt))) + print(" %s: %s" % (src_file, val)) + else: + print("Set %s in [%s] to %s" % (opt, newsection, val)) + tgt_cfg.set(newsection, opt, val) + +def main(): + opts = dict(repo=Bcfg2.Options.SERVER_REPOSITORY, + configfile=Bcfg2.Options.CFILE) + setup = Bcfg2.Options.OptionParser(opts) + setup.parse(sys.argv[1:]) + + copy_section(os.path.join(setup['repo'], 'Rules', 'rules.conf'), setup.cfp, + "rules") + pkgs_conf = os.path.join(setup['repo'], 'Packages', 'packages.conf') + copy_section(pkgs_conf, setup.cfp, "global", newsection="packages") + for section in ["apt", "yum", "pulp"]: + copy_section(pkgs_conf, setup.cfp, section, + newsection="packages:" + section) + + print("Writing %s" % setup['configfile']) + try: + setup.cfp.write(open(setup['configfile'], "w")) + except IOError: + err = sys.exc_info()[1] + print("Could not write %s: %s" % (setup['configfile'], err)) + +if __name__ == '__main__': + sys.exit(main()) |