summaryrefslogtreecommitdiffstats
path: root/tools/upgrade
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-07 15:13:13 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-07 15:13:13 -0400
commita94074b54fa61f593df4945a1ebf4e3edd8cb27d (patch)
treeaeadd1d8df5d28467151020cabf4668b76534ac1 /tools/upgrade
parent12b4a642e1f5b3c9b580646c8fa555cb9a79b1c0 (diff)
downloadbcfg2-a94074b54fa61f593df4945a1ebf4e3edd8cb27d.tar.gz
bcfg2-a94074b54fa61f593df4945a1ebf4e3edd8cb27d.tar.bz2
bcfg2-a94074b54fa61f593df4945a1ebf4e3edd8cb27d.zip
updated migrate_configs.py to handle reports config changes
Diffstat (limited to 'tools/upgrade')
-rwxr-xr-xtools/upgrade/1.3/migrate_configs.py42
1 files changed, 36 insertions, 6 deletions
diff --git a/tools/upgrade/1.3/migrate_configs.py b/tools/upgrade/1.3/migrate_configs.py
index c6e6cd2c3..dd8e5708b 100755
--- a/tools/upgrade/1.3/migrate_configs.py
+++ b/tools/upgrade/1.3/migrate_configs.py
@@ -35,17 +35,47 @@ def main():
setup = Bcfg2.Options.OptionParser(opts)
setup.parse(sys.argv[1:])
- copy_section(os.path.join(setup['repo'], 'Rules', 'rules.conf'), setup.cfp,
- "rules")
+ # files that you should remove manually
+ remove = []
+
+ # move rules config out of rules.conf and into bcfg2.conf
+ rules_conf = os.path.join(setup['repo'], 'Rules', 'rules.conf')
+ 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')
- 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)
+ if os.path.exists(pkgs_conf):
+ remove.append(pkgs_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)
+
+ # move reports database config into [database] section
+ if setup.cfp.has_section("statistics"):
+ if not setup.cfp.has_section("database"):
+ setup.cfp.add_section("database")
+ for opt in setup.cfp.options("statistics"):
+ if opt.startswith("database_"):
+ newopt = opt[9:]
+ if setup.cfp.has_option("database", newopt):
+ print("%s in [database] already populated, skipping" %
+ newopt)
+ else:
+ setup.cfp.set("database", newopt,
+ setup.cfp.get("statistics", opt))
+ setup.cfp.remove_option("statistics", opt)
print("Writing %s" % setup['configfile'])
try:
setup.cfp.write(open(setup['configfile'], "w"))
+ if len(remove):
+ print("Settings were migrated, but you must remove these files "
+ "manually:")
+ for path in remove:
+ print(" %s" % path)
except IOError:
err = sys.exc_info()[1]
print("Could not write %s: %s" % (setup['configfile'], err))