summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Olla <ollan@deshawresearch.com>2014-07-16 10:06:25 -0400
committerNathan Olla <ollan@deshawresearch.com>2014-07-16 10:06:25 -0400
commita4bf68d3c32e6654f53d8e151104850a54ad1e41 (patch)
treef99913fbd6e68adf509e9d524804bee92b7c0f44
parentf84558cbad0d35ef557f8b767b00f2c14f8907a1 (diff)
downloadbcfg2-a4bf68d3c32e6654f53d8e151104850a54ad1e41.tar.gz
bcfg2-a4bf68d3c32e6654f53d8e151104850a54ad1e41.tar.bz2
bcfg2-a4bf68d3c32e6654f53d8e151104850a54ad1e41.zip
Implement _get_package_command and append _sysv_pkg_path attribute
Instead of doing a partially complete Install() method for SYSV, implements a custom _get_package_command that will use the _sysv_pkg_path attribute added by the pkgmogrify call. This will allow the installs to complete. Unfortunately, the single-pass install will still fail if there are any packages with an http:// URL. The pkgadd invocation for 'device' sources doesn't take multiple packages and the 'datastream' invocation doesn't handle packages with an HTTP URL. Finally, there is no reliable standard naming convention for SYSV datastream files, so the simplename attribute is re-used. There is a known issue with this patch - if any packages specified in the PackageList have an http url, the single-pass install will produce an error like: Trying single pass package install for pkgtype sysv pkgadd: ERROR: Failure occurred with http(s) negotiation: <'Peername' doesn't match 'host' or no matching entry> pkgadd: ERROR: unable to download package datastream from <http://install1.d.stor.en.desres.deshaw.com/jumpstart10U10/packages>. Single Pass Failed because the command that results isn't valid syntax for pkgadd. A workaround would be to add code to skip the single-pass install if any packages had the simplename attribute, or by checking the url for the presence of 'http'. I'm not sure if that should be fixed or if this is reasonable in this case.
-rw-r--r--src/lib/Bcfg2/Client/Tools/SYSV.py60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/SYSV.py b/src/lib/Bcfg2/Client/Tools/SYSV.py
index 811711723..4f3eea668 100644
--- a/src/lib/Bcfg2/Client/Tools/SYSV.py
+++ b/src/lib/Bcfg2/Client/Tools/SYSV.py
@@ -50,44 +50,38 @@ class SYSV(Bcfg2.Client.Tools.PkgTool):
self.pkgtool[1])
except: # pylint: disable=W0702
self.pkgtool = (self.pkgtool[0] % "", self.pkgtool[1])
+ self.origpkgtool = self.pkgtool
- def pkgmogrify(self, pkg):
- """ Take a pkg object, check for a 'simplename' attribute. If found,
- return a modified pkg object that points to to a temporary file
+ def pkgmogrify(self, packages):
+ """ Take a list of pkg objects, check for a 'simplename' attribute.
+ If present, insert a _sysv_pkg_path attribute to the package and
+ download the datastream format SYSV package to a temporary file.
"""
- if pkg.get('simplename'):
- self.logger.debug("Pkgmogrifying %s because simplename %s found" %
- (pkg.get('name'), pkg.get('simplename')))
- tmpfile = tempfile.NamedTemporaryFile()
- self.tmpfiles.append(tmpfile)
- self.logger.debug("URL: %s/%s" % (pkg.get('url'),
- pkg.get('simplename')))
- urlretrieve("%s/%s" % (pkg.get('url'), pkg.get('simplename')),
- tmpfile.name)
- newpkg = copy.copy(pkg)
- newpkg.set('url', tmpfile.name)
- return newpkg
- return pkg
-
- def Install(self, packages, states):
for pkg in packages:
- pkg = self.pkgmogrify(pkg)
- if self.VerifyPackage(pkg, []):
- self.logger.info("Forcing state to true for pkg %s" %
- (pkg.get('name')))
- states[pkg] = True
- else:
- self.logger.info("Installing pkg %s version %s" %
- (pkg.get('name'), pkg.get('version')))
+ if pkg.get('simplename'):
+ tmpfile = tempfile.NamedTemporaryFile()
+ self.tmpfiles.append(tmpfile)
+ urlretrieve("%s/%s" % (pkg.get('url'), pkg.get('simplename')),
+ tmpfile.name)
+ pkg.set('_sysv_pkg_path', tmpfile.name)
- if self.cmd.run(self._get_package_command([pkg])):
- states[pkg] = True
- else:
- self.logger.error("Failed to install package %s" %
- pkg.get('name'))
+ def _get_package_command(self, packages):
+ """Override the default _get_package_command, replacing the attribute
+ 'url' if '_sysv_pkg_path' if necessary in the returned command
+ string"""
+ if len(packages) == 1 and '_sysv_pkg_path' in packages[0].keys():
+ self.pkgtool = (self.pkgtool[0], ('%s %s',
+ ['_sysv_pkg_path', 'name']))
+ else:
+ self.pkgtool = self.origpkgtool
+
+ pkgcmd = super(SYSV, self)._get_package_command(packages)
+ self.logger.debug("Calling install command: %s" % pkgcmd)
+ return pkgcmd
- self.RefreshPackages()
- self.modified.extend(entry for entry in packages if states[entry])
+ def Install(self, packages, states):
+ self.pkgmogrify(packages)
+ super(SYSV, self).Install(packages, states)
def RefreshPackages(self):
"""Refresh memory hashes of packages."""