summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2014-11-08 11:10:56 -0600
committerSol Jerome <sol.jerome@gmail.com>2014-11-08 11:10:56 -0600
commit5a9c685c53f13a8bf4dd55cf96ecf11d624d8fcf (patch)
treec3ca7c47ee79361cff53dc3f1198186e2df8d42d
parent6be5de9e8ed7e29d3763b36f870a2f470917f76d (diff)
parentad438f9e17decda2efca0e8974995a6d028f7788 (diff)
downloadbcfg2-5a9c685c53f13a8bf4dd55cf96ecf11d624d8fcf.tar.gz
bcfg2-5a9c685c53f13a8bf4dd55cf96ecf11d624d8fcf.tar.bz2
bcfg2-5a9c685c53f13a8bf4dd55cf96ecf11d624d8fcf.zip
Merge branch 'SYSV-use-simplefile' of https://github.com/fennm/bcfg2 into maint
-rw-r--r--doc/client/tools.txt16
-rw-r--r--src/lib/Bcfg2/Client/Tools/SYSV.py11
-rw-r--r--tools/upgrade/1.3/README4
-rwxr-xr-xtools/upgrade/1.3/migrate_sysv_simplename.py51
4 files changed, 72 insertions, 10 deletions
diff --git a/doc/client/tools.txt b/doc/client/tools.txt
index ce8732454..170b30b2e 100644
--- a/doc/client/tools.txt
+++ b/doc/client/tools.txt
@@ -158,14 +158,22 @@ Handles `System V Packaging <http://docs.oracle.com/cd/E19683-01/806-7008/index.
.. note::
- If the Packages specified in the PackageList are datastream format packages distributed via HTTP, you must specify a simplename attribute. Such packages will be downloaded and installed from a local path.
+ If the Packages specified in the PackageList are datastream format
+ packages distributed via HTTP, you must specify a simplefile attribute.
+ Such packages will be downloaded and installed from a local path.
- datastream format over HTTP:
+ Note the use of the uri attribute in the datastream format example. If
+ the simplefile attribute exists, the
+ :ref:`Pkgmgr <server-plugins-generators-pkgmgr>` plugin will
+ automatically construct the url attribute by concatenating the uri and
+ simplefile attributes (with an intervening slash).
+
+ Datastream format over HTTP:
.. code-block:: xml
- <PackageList url='http://install/packages' type='sysv' priority='0'>
- <Package name='SCbcfg2' version='1.3.4' simplename='bcfg-1.3.4-1' />
+ <PackageList uri='http://install/packages' type='sysv' priority='0'>
+ <Package name='SCbcfg2' version='1.3.4' simplefile='bcfg-1.3.4-1' />
</PackageList>
File system format over NFS or local path:
diff --git a/src/lib/Bcfg2/Client/Tools/SYSV.py b/src/lib/Bcfg2/Client/Tools/SYSV.py
index a29b49efa..27c3d3785 100644
--- a/src/lib/Bcfg2/Client/Tools/SYSV.py
+++ b/src/lib/Bcfg2/Client/Tools/SYSV.py
@@ -52,18 +52,17 @@ class SYSV(Bcfg2.Client.Tools.PkgTool):
self.origpkgtool = self.pkgtool
def pkgmogrify(self, packages):
- """ Take a list of pkg objects, check for a 'simplename' attribute.
+ """ Take a list of pkg objects, check for a 'simplefile' attribute.
If present, insert a _sysv_pkg_path attribute to the package and
download the datastream format SYSV package to a temporary file.
"""
for pkg in packages:
- if pkg.get('simplename'):
+ if pkg.get('simplefile'):
tmpfile = tempfile.NamedTemporaryFile()
self.tmpfiles.append(tmpfile)
- self.logger.info("Downloading %s%s to %s" % (pkg.get('url'),
- pkg.get('simplename'), tmpfile.name))
- urlretrieve("%s/%s" % (pkg.get('url'), pkg.get('simplename')),
- tmpfile.name)
+ self.logger.info("Downloading %s to %s" % (pkg.get('url'),
+ tmpfile.name))
+ urlretrieve(pkg.get('url'), tmpfile.name)
pkg.set('_sysv_pkg_path', tmpfile.name)
def _get_package_command(self, packages):
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())