diff options
author | ctracey <ctracey@craigtracey.com> | 2013-01-30 19:21:37 -0500 |
---|---|---|
committer | ctracey <ctracey@craigtracey.com> | 2013-01-30 19:21:37 -0500 |
commit | 9ced60371239eb961e9919f13bda8b496e077411 (patch) | |
tree | 0143189be90f618631698a7558885bb02ad89282 | |
parent | dc3ebfe2416028b78b6a846e939201d894b2c9b6 (diff) | |
download | vyos-cloud-init-9ced60371239eb961e9919f13bda8b496e077411.tar.gz vyos-cloud-init-9ced60371239eb961e9919f13bda8b496e077411.zip |
Support package versions for the generic package config module
Augmenting the package version support to be available when specifying
extra packages to be installed at boot via the 'packages:' yaml key. This
change also improves type checking and add a configuration example to the
docs.
-rw-r--r-- | cloudinit/util.py | 23 | ||||
-rw-r--r-- | doc/examples/cloud-config-install-packages.txt | 4 |
2 files changed, 17 insertions, 10 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index c9c5f794..ffe844b2 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -402,10 +402,9 @@ def get_cfg_option_list(yobj, key, default=None): return [] val = yobj[key] if isinstance(val, (list)): - # Should we ensure they are all strings?? - cval = [str(v) for v in val] + cval = [v for v in val] return cval - if not isinstance(val, (str, basestring)): + if not isinstance(val, (basestring)): val = str(val) return [val] @@ -1569,17 +1568,21 @@ def expand_package_list(version_fmt, pkgs): pkglist = [] for pkg in pkgs: - if isinstance(pkg, str): + if isinstance(pkg, basestring): pkglist.append(pkg) continue - if len(pkg) < 1 or len(pkg) > 2: - raise RuntimeError("Invalid package_command tuple.") + if isinstance(pkg, (tuple, list)): + if len(pkg) < 1 or len(pkg) > 2: + raise RuntimeError("Invalid package & version tuple.") - if len(pkg) == 2 and pkg[1]: - pkglist.append(version_fmt % pkg) - continue + if len(pkg) == 2 and pkg[1]: + pkglist.append(version_fmt % tuple(pkg)) + continue - pkglist.append(pkg[0]) + pkglist.append(pkg[0]) + + else: + raise RuntimeError("Invalid package type.") return pkglist diff --git a/doc/examples/cloud-config-install-packages.txt b/doc/examples/cloud-config-install-packages.txt index 4984818f..2edc63da 100644 --- a/doc/examples/cloud-config-install-packages.txt +++ b/doc/examples/cloud-config-install-packages.txt @@ -6,6 +6,10 @@ # # if packages are specified, this apt_update will be set to true # +# packages may be supplied as a single package name or as a list +# with the format [<package>, <version>] wherein the specifc +# package version will be installed. packages: - pwgen - pastebinit + - [libpython2.7, 2.7.3-0ubuntu3.1] |