summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorPaul Meyer <paulmey@microsoft.com>2017-05-02 22:26:50 +0000
committerScott Moser <smoser@ubuntu.com>2017-05-03 21:57:56 -0400
commit4f0f171c29bb9abb5cbb6f9adbe68015089aeed9 (patch)
treec7b219d49280dcdd03477a7d533658baa2adfee9 /cloudinit/config
parent99faf3ece1badc566e7e75e769ff374250196197 (diff)
downloadvyos-cloud-init-4f0f171c29bb9abb5cbb6f9adbe68015089aeed9.tar.gz
vyos-cloud-init-4f0f171c29bb9abb5cbb6f9adbe68015089aeed9.zip
fs_setup: if cmd is specified, use shell interpretation.
If 'cmd' is provided to a fs_setup entry, then cloud-init was trying to execute the rendered string as a single name, rather than splitting the string. The change here will pass the string to shell for interpretation so that it is split there. Also fix some documentation errors and warn when fs_opts or overwrite is provided along with 'cmd'. LP: #1687712
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_disk_setup.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py
index f49386e3..6f827ddc 100644
--- a/cloudinit/config/cc_disk_setup.py
+++ b/cloudinit/config/cc_disk_setup.py
@@ -910,12 +910,23 @@ def mkfs(fs_cfg):
"must be set.", label)
# Create the commands
+ shell = False
if fs_cmd:
fs_cmd = fs_cfg['cmd'] % {
'label': label,
'filesystem': fs_type,
'device': device,
}
+ shell = True
+
+ if overwrite:
+ LOG.warning(
+ "fs_setup:overwrite ignored because cmd was specified: %s",
+ fs_cmd)
+ if fs_opts:
+ LOG.warning(
+ "fs_setup:extra_opts ignored because cmd was specified: %s",
+ fs_cmd)
else:
# Find the mkfs command
mkfs_cmd = util.which("mkfs.%s" % fs_type)
@@ -936,14 +947,14 @@ def mkfs(fs_cfg):
if overwrite or device_type(device) == "disk":
fs_cmd.append(lookup_force_flag(fs_type))
- # Add the extends FS options
- if fs_opts:
- fs_cmd.extend(fs_opts)
+ # Add the extends FS options
+ if fs_opts:
+ fs_cmd.extend(fs_opts)
LOG.debug("Creating file system %s on %s", label, device)
- LOG.debug(" Using cmd: %s", " ".join(fs_cmd))
+ LOG.debug(" Using cmd: %s", str(fs_cmd))
try:
- util.subp(fs_cmd)
+ util.subp(fs_cmd, shell=shell)
except Exception as e:
raise Exception("Failed to exec of '%s':\n%s" % (fs_cmd, e))