summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_snappy.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-03-27 11:11:05 -0400
committerScott Moser <smoser@ubuntu.com>2015-03-27 11:11:05 -0400
commitb7b8004bc58f1243d023092e67f3b78743086ff2 (patch)
tree81e9c19b0c82a5514801c52727ad6547f921c8c0 /cloudinit/config/cc_snappy.py
parentb9cdcb6a8ef499c6e3be178fb5f59d369eb3b169 (diff)
downloadvyos-cloud-init-b7b8004bc58f1243d023092e67f3b78743086ff2.tar.gz
vyos-cloud-init-b7b8004bc58f1243d023092e67f3b78743086ff2.zip
change 'configs' to 'config', and namespace input to 'snappy config'
the input to 'snappy config <packagename>' is expected to have config: <packagename>: content: So here we pad that input correctly. Note, that a .config file on disk is not modified. Also, we change 'configs' to just be 'config', to be possibly compatible with the a future 'snappy config /' that dumped: config: pkg1: data1 pkg2: data2
Diffstat (limited to 'cloudinit/config/cc_snappy.py')
-rw-r--r--cloudinit/config/cc_snappy.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/cloudinit/config/cc_snappy.py b/cloudinit/config/cc_snappy.py
index e664234a..a3af98a6 100644
--- a/cloudinit/config/cc_snappy.py
+++ b/cloudinit/config/cc_snappy.py
@@ -8,9 +8,11 @@ Example config:
system_snappy: auto
ssh_enabled: False
packages: [etcd, pkg2]
- configs:
- pkgname: pkgname-config-blob
- pkg2: config-blob
+ config:
+ pkgname:
+ key2: value2
+ pkg2:
+ key1: value1
packages_dir: '/writable/user-data/cloud-init/snaps'
- ssh_enabled:
@@ -31,7 +33,7 @@ Example config:
<packages_dir>/foo.snap
snappy install <packages_dir>/bar.snap
- Note, that if provided a 'configs' entry for 'ubuntu-core', then
+ Note, that if provided a 'config' entry for 'ubuntu-core', then
cloud-init will invoke: snappy config ubuntu-core <config>
Allowing you to configure ubuntu-core in this way.
"""
@@ -56,7 +58,7 @@ BUILTIN_CFG = {
'packages_dir': '/writable/user-data/cloud-init/snaps',
'ssh_enabled': False,
'system_snappy': "auto",
- 'configs': {},
+ 'config': {},
}
@@ -119,15 +121,14 @@ def render_snap_op(op, name, path=None, cfgfile=None, config=None):
try:
cfg_tmpf = None
if config is not None:
- if isinstance(config, six.binary_type):
- cfg_bytes = config
- elif isinstance(config, six.text_type):
- cfg_bytes = config.encode()
- else:
- cfg_bytes = util.yaml_dumps(config).encode()
-
+ # input to 'snappy config packagename' must have nested data. odd.
+ # config:
+ # packagename:
+ # config
+ # Note, however, we do not touch config files on disk.
+ nested_cfg = {'config': {name: config}}
(fd, cfg_tmpf) = tempfile.mkstemp()
- os.write(fd, cfg_bytes)
+ os.write(fd, util.yaml_dumps(nested_cfg).encode())
os.close(fd)
cfgfile = cfg_tmpf
@@ -218,7 +219,7 @@ def handle(name, cfg, cloud, log, args):
return
pkg_ops = get_package_ops(packages=mycfg['packages'],
- configs=mycfg['configs'],
+ configs=mycfg['config'],
fspath=mycfg['packages_dir'])
set_snappy_command()