summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2014-11-10 19:55:16 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2014-11-10 19:55:16 +0100
commitda93fb540c28be3341ec0d37d1fbd90153fb750c (patch)
tree9615b3ddcc594ba5fb6a89dbce2516adab641153 /tools
parent389ce1a86b704222ddc9458cd49c281e7601b803 (diff)
parentf6b3d6dc89e4ba5c2ec643931394db45b8c7f176 (diff)
downloadbcfg2-da93fb540c28be3341ec0d37d1fbd90153fb750c.tar.gz
bcfg2-da93fb540c28be3341ec0d37d1fbd90153fb750c.tar.bz2
bcfg2-da93fb540c28be3341ec0d37d1fbd90153fb750c.zip
Merge remote branch 'upstream/maint'
* upstream/maint: (59 commits) Client/Tools/APT: fix pylint errors, enable check Client/Tools/APT: fix exception name SYSV: add a migration tool to change simplename attributes to simplefile doc: Update SYSV datastream format docs SYSV: change instances of simplename to simplefile Client/Tools/APT: handle exceptions gracefully Server/Plugins/Packages: add debsrc attribute to url_map schemas/packages.xsd: add default value for debsrc Options.py: Fix database OPTIONS parsing doc: Fix typos doc: Add note about Decisions fix for 1.3.6 testsuite: Fix tools __init__.py unit test Tools: Fix install of non-whitelisted services doc: Add 1.3.6 release notes fix keyboard interrupt during intial event handling Server/Core: also shutdown on exceptions during fam blocking Reporting: better exception handling Packages: add name to additional_data for Sources Packages: add name to sources YUM: Add options to enable and disable Yum plugins ... Conflicts: debian/changelog doc/conf.py doc/releases/index.txt doc/server/database.txt doc/server/plugins/generators/cfg.txt doc/server/plugins/generators/sslca.txt man/bcfg2.conf.5 misc/bcfg2-selinux.spec misc/bcfg2.spec osx/Makefile osx/macports/Portfile schemas/packages.xsd solaris-ips/MANIFEST.bcfg2-server.header solaris-ips/MANIFEST.bcfg2.header solaris-ips/Makefile solaris-ips/pkginfo.bcfg2 solaris-ips/pkginfo.bcfg2-server solaris/Makefile solaris/pkginfo.bcfg2 solaris/pkginfo.bcfg2-server src/lib/Bcfg2/Client/Client.py src/lib/Bcfg2/Client/Proxy.py src/lib/Bcfg2/Client/Tools/APT.py src/lib/Bcfg2/Client/Tools/Action.py src/lib/Bcfg2/Client/Tools/SYSV.py src/lib/Bcfg2/Client/Tools/YUM.py src/lib/Bcfg2/Client/Tools/__init__.py src/lib/Bcfg2/Options.py src/lib/Bcfg2/Reporting/Collector.py src/lib/Bcfg2/Reporting/templates/base.html src/lib/Bcfg2/Server/Admin/__init__.py src/lib/Bcfg2/Server/BuiltinCore.py src/lib/Bcfg2/Server/Core.py src/lib/Bcfg2/Server/Plugins/Packages/Apt.py src/lib/Bcfg2/Server/Plugins/Probes.py src/lib/Bcfg2/settings.py src/lib/Bcfg2/version.py testsuite/Testsrc/Testlib/TestClient/TestTools/Test_init.py testsuite/Testsrc/test_code_checks.py
Diffstat (limited to 'tools')
-rw-r--r--tools/upgrade/1.3/README4
-rwxr-xr-xtools/upgrade/1.3/migrate_sysv_simplename.py51
2 files changed, 55 insertions, 0 deletions
diff --git a/tools/upgrade/1.3/README b/tools/upgrade/1.3/README
index 1a919f869..29fd9886b 100644
--- a/tools/upgrade/1.3/README
+++ b/tools/upgrade/1.3/README
@@ -24,3 +24,7 @@ migrate_probe_groups_to_db.py
- Migrate Probe host and group data from XML to DB backend for Metadata
and Probe plugins. Does not migrate individual probe return data. Assumes
migration to BOTH Metadata and Probe to database backends.
+
+migrate_sysv_simplename.py
+ - Migrate any Pkgmgr entries which may have been using the simplename
+ attribute introduced in 1.3.5 to the simplefile attribute
diff --git a/tools/upgrade/1.3/migrate_sysv_simplename.py b/tools/upgrade/1.3/migrate_sysv_simplename.py
new file mode 100755
index 000000000..f6599756b
--- /dev/null
+++ b/tools/upgrade/1.3/migrate_sysv_simplename.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import glob
+import lxml.etree
+import Bcfg2.Options
+
+def main():
+ opts = dict(repo=Bcfg2.Options.SERVER_REPOSITORY)
+ setup = Bcfg2.Options.OptionParser(opts)
+ setup.parse(sys.argv[1:])
+
+ files = []
+ for plugin in ['Pkgmgr']:
+ files.extend(glob.glob(os.path.join(setup['repo'], plugin, "*")))
+
+ for bfile in files:
+ bdata = lxml.etree.parse(bfile)
+ changed = False
+
+ if not bdata.xpath("//@type='sysv'"):
+ print("%s doesn't contain any sysv packages, skipping" % bfile)
+ continue
+
+ pkglist = bdata.getroot()
+ if pkglist.tag != "PackageList":
+ print("%s doesn't look like a PackageList, skipping" % bfile)
+ continue
+
+ for pkg in bdata.xpath("//Package"):
+ if "simplename" in pkg.attrib:
+ pkg.set("simplefile", pkg.get("simplename"))
+ del pkg.attrib["simplename"]
+ changed = True
+
+ # if we switched to simplefile, we also need to switch to uri
+ if changed and "url" in pkglist.attrib:
+ pkglist.set("uri", pkglist.get("url"))
+ del pkglist.attrib["url"]
+
+ if changed:
+ print("Writing %s" % bfile)
+ try:
+ open(bfile, "w").write(lxml.etree.tostring(bdata))
+ except IOError:
+ err = sys.exc_info()[1]
+ print("Could not write %s: %s" % (bfile, err))
+
+if __name__ == '__main__':
+ sys.exit(main())