summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorctracey <ctracey@craigtracey.com>2013-01-30 19:21:37 -0500
committerctracey <ctracey@craigtracey.com>2013-01-30 19:21:37 -0500
commit9ced60371239eb961e9919f13bda8b496e077411 (patch)
tree0143189be90f618631698a7558885bb02ad89282 /cloudinit/util.py
parentdc3ebfe2416028b78b6a846e939201d894b2c9b6 (diff)
downloadvyos-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.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py23
1 files changed, 13 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