summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2018-02-02 11:11:36 -0700
committerChad Smith <chad.smith@canonical.com>2018-02-02 11:11:36 -0700
commit78013bc65030421699b5feb66bc8b7a205abfbc0 (patch)
tree2ebf7111129f4aaf8a833ba6d226d4513ed59388 /cloudinit/config
parent192261fe38a32edbd1f605ba25bbb6f4822a0720 (diff)
parentf7deaf15acf382d62554e2b1d70daa9a9109d542 (diff)
downloadvyos-cloud-init-78013bc65030421699b5feb66bc8b7a205abfbc0.tar.gz
vyos-cloud-init-78013bc65030421699b5feb66bc8b7a205abfbc0.zip
merge from master at 17.2-30-gf7deaf15
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_apt_configure.py5
-rw-r--r--cloudinit/config/cc_disk_setup.py8
-rw-r--r--cloudinit/config/cc_landscape.py8
-rw-r--r--cloudinit/config/cc_ntp.py10
-rw-r--r--cloudinit/config/cc_power_state_change.py1
-rw-r--r--cloudinit/config/cc_resizefs.py12
-rw-r--r--cloudinit/config/cc_rh_subscription.py5
-rw-r--r--cloudinit/config/cc_rsyslog.py10
-rw-r--r--cloudinit/config/cc_seed_random.py3
-rw-r--r--cloudinit/config/cc_snap_config.py7
10 files changed, 43 insertions, 26 deletions
diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
index 177cbcf7..5b9cbca0 100644
--- a/cloudinit/config/cc_apt_configure.py
+++ b/cloudinit/config/cc_apt_configure.py
@@ -275,8 +275,9 @@ def handle(name, ocfg, cloud, log, _):
cfg = ocfg.get('apt', {})
if not isinstance(cfg, dict):
- raise ValueError("Expected dictionary for 'apt' config, found %s",
- type(cfg))
+ raise ValueError(
+ "Expected dictionary for 'apt' config, found {config_type}".format(
+ config_type=type(cfg)))
apply_debconf_selections(cfg, target)
apply_apt(cfg, cloud, target)
diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py
index c2b83aea..c3e8c484 100644
--- a/cloudinit/config/cc_disk_setup.py
+++ b/cloudinit/config/cc_disk_setup.py
@@ -788,7 +788,8 @@ def mkpart(device, definition):
# This prevents you from overwriting the device
LOG.debug("Checking if device %s is a valid device", device)
if not is_device_valid(device):
- raise Exception("Device %s is not a disk device!", device)
+ raise Exception(
+ 'Device {device} is not a disk device!'.format(device=device))
# Remove the partition table entries
if isinstance(layout, str) and layout.lower() == "remove":
@@ -945,8 +946,9 @@ def mkfs(fs_cfg):
# Check that we can create the FS
if not (fs_type or fs_cmd):
- raise Exception("No way to create filesystem '%s'. fs_type or fs_cmd "
- "must be set.", label)
+ raise Exception(
+ "No way to create filesystem '{label}'. fs_type or fs_cmd "
+ "must be set.".format(label=label))
# Create the commands
shell = False
diff --git a/cloudinit/config/cc_landscape.py b/cloudinit/config/cc_landscape.py
index 8f9f1abd..eaf1e940 100644
--- a/cloudinit/config/cc_landscape.py
+++ b/cloudinit/config/cc_landscape.py
@@ -94,10 +94,10 @@ def handle(_name, cfg, cloud, log, _args):
ls_cloudcfg = cfg.get("landscape", {})
if not isinstance(ls_cloudcfg, (dict)):
- raise RuntimeError(("'landscape' key existed in config,"
- " but not a dictionary type,"
- " is a %s instead"),
- type_utils.obj_name(ls_cloudcfg))
+ raise RuntimeError(
+ "'landscape' key existed in config, but not a dictionary type,"
+ " is a {_type} instead".format(
+ _type=type_utils.obj_name(ls_cloudcfg)))
if not ls_cloudcfg:
return
diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py
index f50bcb35..cbd0237d 100644
--- a/cloudinit/config/cc_ntp.py
+++ b/cloudinit/config/cc_ntp.py
@@ -106,9 +106,9 @@ def handle(name, cfg, cloud, log, _args):
# TODO drop this when validate_cloudconfig_schema is strict=True
if not isinstance(ntp_cfg, (dict)):
- raise RuntimeError(("'ntp' key existed in config,"
- " but not a dictionary type,"
- " is a %s %instead"), type_utils.obj_name(ntp_cfg))
+ raise RuntimeError(
+ "'ntp' key existed in config, but not a dictionary type,"
+ " is a {_type} instead".format(_type=type_utils.obj_name(ntp_cfg)))
validate_cloudconfig_schema(cfg, schema)
if ntp_installable():
@@ -206,8 +206,8 @@ def write_ntp_config_template(cfg, cloud, path, template=None):
if not template_fn:
template_fn = cloud.get_template_filename('ntp.conf')
if not template_fn:
- raise RuntimeError(("No template found, "
- "not rendering %s"), path)
+ raise RuntimeError(
+ 'No template found, not rendering {path}'.format(path=path))
templater.render_to_file(template_fn, path, params)
diff --git a/cloudinit/config/cc_power_state_change.py b/cloudinit/config/cc_power_state_change.py
index eba58b02..4da3a588 100644
--- a/cloudinit/config/cc_power_state_change.py
+++ b/cloudinit/config/cc_power_state_change.py
@@ -194,6 +194,7 @@ def doexit(sysexit):
def execmd(exe_args, output=None, data_in=None):
+ ret = 1
try:
proc = subprocess.Popen(exe_args, stdin=subprocess.PIPE,
stdout=output, stderr=subprocess.STDOUT)
diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py
index 0d282e63..cec22bb7 100644
--- a/cloudinit/config/cc_resizefs.py
+++ b/cloudinit/config/cc_resizefs.py
@@ -59,7 +59,17 @@ __doc__ = get_schema_doc(schema) # Supplement python help()
def _resize_btrfs(mount_point, devpth):
- return ('btrfs', 'filesystem', 'resize', 'max', mount_point)
+ # If "/" is ro resize will fail. However it should be allowed since resize
+ # makes everything bigger and subvolumes that are not ro will benefit.
+ # Use a subvolume that is not ro to trick the resize operation to do the
+ # "right" thing. The use of ".snapshot" is specific to "snapper" a generic
+ # solution would be walk the subvolumes and find a rw mounted subvolume.
+ if (not util.mount_is_read_write(mount_point) and
+ os.path.isdir("%s/.snapshots" % mount_point)):
+ return ('btrfs', 'filesystem', 'resize', 'max',
+ '%s/.snapshots' % mount_point)
+ else:
+ return ('btrfs', 'filesystem', 'resize', 'max', mount_point)
def _resize_ext(mount_point, devpth):
diff --git a/cloudinit/config/cc_rh_subscription.py b/cloudinit/config/cc_rh_subscription.py
index a9d21e78..530808ce 100644
--- a/cloudinit/config/cc_rh_subscription.py
+++ b/cloudinit/config/cc_rh_subscription.py
@@ -276,9 +276,8 @@ class SubscriptionManager(object):
cmd = ['attach', '--auto']
try:
return_out, return_err = self._sub_man_cli(cmd)
- except util.ProcessExecutionError:
- self.log_warn("Auto-attach failed with: "
- "{0}]".format(return_err.strip()))
+ except util.ProcessExecutionError as e:
+ self.log_warn("Auto-attach failed with: {0}".format(e))
return False
for line in return_out.split("\n"):
if line is not "":
diff --git a/cloudinit/config/cc_rsyslog.py b/cloudinit/config/cc_rsyslog.py
index 50ff9e35..af08788c 100644
--- a/cloudinit/config/cc_rsyslog.py
+++ b/cloudinit/config/cc_rsyslog.py
@@ -20,15 +20,15 @@ which defaults to ``20-cloud-config.conf``. The rsyslog config directory to
write config files to may be specified in ``config_dir``, which defaults to
``/etc/rsyslog.d``.
-A list of configurations for for rsyslog can be specified under the ``configs``
-key in the ``rsyslog`` config. Each entry in ``configs`` is either a string or
-a dictionary. Each config entry contains a configuration string and a file to
+A list of configurations for rsyslog can be specified under the ``configs`` key
+in the ``rsyslog`` config. Each entry in ``configs`` is either a string or a
+dictionary. Each config entry contains a configuration string and a file to
write it to. For config entries that are a dictionary, ``filename`` sets the
target filename and ``content`` specifies the config string to write. For
config entries that are only a string, the string is used as the config string
to write. If the filename to write the config to is not specified, the value of
-the ``config_filename`` key is used. A file with the selected filename will
-be written inside the directory specified by ``config_dir``.
+the ``config_filename`` key is used. A file with the selected filename will be
+written inside the directory specified by ``config_dir``.
The command to use to reload the rsyslog service after the config has been
updated can be specified in ``service_reload_command``. If this is set to
diff --git a/cloudinit/config/cc_seed_random.py b/cloudinit/config/cc_seed_random.py
index e76b9c09..65f6e777 100644
--- a/cloudinit/config/cc_seed_random.py
+++ b/cloudinit/config/cc_seed_random.py
@@ -95,7 +95,8 @@ def handle_random_seed_command(command, required, env=None):
cmd = command[0]
if not util.which(cmd):
if required:
- raise ValueError("command '%s' not found but required=true", cmd)
+ raise ValueError(
+ "command '{cmd}' not found but required=true".format(cmd=cmd))
else:
LOG.debug("command '%s' not found for seed_command", cmd)
return
diff --git a/cloudinit/config/cc_snap_config.py b/cloudinit/config/cc_snap_config.py
index fe0cc73e..e82c0811 100644
--- a/cloudinit/config/cc_snap_config.py
+++ b/cloudinit/config/cc_snap_config.py
@@ -87,7 +87,9 @@ def add_assertions(assertions=None):
assertions = []
if not isinstance(assertions, list):
- raise ValueError('assertion parameter was not a list: %s', assertions)
+ raise ValueError(
+ 'assertion parameter was not a list: {assertions}'.format(
+ assertions=assertions))
snap_cmd = [SNAPPY_CMD, 'ack']
combined = "\n".join(assertions)
@@ -115,7 +117,8 @@ def add_snap_user(cfg=None):
cfg = {}
if not isinstance(cfg, dict):
- raise ValueError('configuration parameter was not a dict: %s', cfg)
+ raise ValueError(
+ 'configuration parameter was not a dict: {cfg}'.format(cfg=cfg))
snapuser = cfg.get('email', None)
if not snapuser: