summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit')
-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_seed_random.py3
-rw-r--r--cloudinit/config/cc_snap_config.py7
-rwxr-xr-xcloudinit/net/cmdline.py9
-rw-r--r--cloudinit/net/network_state.py8
-rw-r--r--cloudinit/sources/DataSourceAltCloud.py2
-rw-r--r--cloudinit/sources/DataSourceAzure.py6
-rw-r--r--cloudinit/sources/DataSourceOpenNebula.py5
-rw-r--r--cloudinit/sources/helpers/azure.py3
-rw-r--r--cloudinit/util.py3
13 files changed, 45 insertions, 32 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_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:
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
index 38b27a52..7b2cc9db 100755
--- a/cloudinit/net/cmdline.py
+++ b/cloudinit/net/cmdline.py
@@ -116,10 +116,11 @@ def config_from_klibc_net_cfg(files=None, mac_addrs=None):
prev = names[name]['entry']
if prev.get('mac_address') != entry.get('mac_address'):
raise ValueError(
- "device '%s' was defined multiple times (%s)"
- " but had differing mac addresses: %s -> %s.",
- (name, ' '.join(names[name]['files']),
- prev.get('mac_address'), entry.get('mac_address')))
+ "device '{name}' was defined multiple times ({files})"
+ " but had differing mac addresses: {old} -> {new}.".format(
+ name=name, files=' '.join(names[name]['files']),
+ old=prev.get('mac_address'),
+ new=entry.get('mac_address')))
prev['subnets'].extend(entry['subnets'])
names[name]['files'].append(cfg_file)
else:
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index e9e2cf4e..31738c73 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -474,8 +474,9 @@ class NetworkStateInterpreter(object):
elif bridge_stp in ['off', '0', 0]:
bridge_stp = False
else:
- raise ValueError("Cannot convert bridge_stp value"
- "(%s) to boolean", bridge_stp)
+ raise ValueError(
+ 'Cannot convert bridge_stp value ({stp}) to'
+ ' boolean'.format(stp=bridge_stp))
iface.update({'bridge_stp': bridge_stp})
interfaces.update({iface['name']: iface})
@@ -692,7 +693,8 @@ class NetworkStateInterpreter(object):
elif cmd_type == "bond":
self.handle_bond(v1_cmd)
else:
- raise ValueError('Unknown command type: %s', cmd_type)
+ raise ValueError('Unknown command type: {cmd_type}'.format(
+ cmd_type=cmd_type))
def _v2_to_v1_ipcfg(self, cfg):
"""Common ipconfig extraction from v2 to v1 subnets array."""
diff --git a/cloudinit/sources/DataSourceAltCloud.py b/cloudinit/sources/DataSourceAltCloud.py
index be2d6cf8..e1d0055b 100644
--- a/cloudinit/sources/DataSourceAltCloud.py
+++ b/cloudinit/sources/DataSourceAltCloud.py
@@ -145,7 +145,7 @@ class DataSourceAltCloud(sources.DataSource):
else:
cloud_type = self.get_cloud_type()
- LOG.debug('cloud_type: ' + str(cloud_type))
+ LOG.debug('cloud_type: %s', str(cloud_type))
if 'RHEV' in cloud_type:
if self.user_data_rhevm():
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index 6978d4e5..e73b57b9 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -582,12 +582,12 @@ def address_ephemeral_resize(devpath=RESOURCE_DISK_PATH, maxwait=120,
if os.path.exists(sempath):
try:
os.unlink(sempath)
- LOG.debug(bmsg + " removed.")
+ LOG.debug('%s removed.', bmsg)
except Exception as e:
# python3 throws FileNotFoundError, python2 throws OSError
- LOG.warning(bmsg + ": remove failed! (%s)", e)
+ LOG.warning('%s: remove failed! (%s)', bmsg, e)
else:
- LOG.debug(bmsg + " did not exist.")
+ LOG.debug('%s did not exist.', bmsg)
return
diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py
index 5da11847..f66c95d7 100644
--- a/cloudinit/sources/DataSourceOpenNebula.py
+++ b/cloudinit/sources/DataSourceOpenNebula.py
@@ -332,8 +332,9 @@ def read_context_disk_dir(source_dir, asuser=None):
try:
pwd.getpwnam(asuser)
except KeyError as e:
- raise BrokenContextDiskDir("configured user '%s' "
- "does not exist", asuser)
+ raise BrokenContextDiskDir(
+ "configured user '{user}' does not exist".format(
+ user=asuser))
try:
path = os.path.join(source_dir, 'context.sh')
content = util.load_file(path)
diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py
index 959b1bda..6cda5721 100644
--- a/cloudinit/sources/helpers/azure.py
+++ b/cloudinit/sources/helpers/azure.py
@@ -274,7 +274,8 @@ class WALinuxAgentShim(object):
name = os.path.basename(hook_file).replace('.json', '')
dhcp_options[name] = json.loads(util.load_file((hook_file)))
except ValueError:
- raise ValueError("%s is not valid JSON data", hook_file)
+ raise ValueError(
+ '{_file} is not valid JSON data'.format(_file=hook_file))
return dhcp_options
@staticmethod
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 11e96a77..8a9f1ab2 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -2327,7 +2327,8 @@ def pathprefix2dict(base, required=None, optional=None, delim=os.path.sep):
missing.append(f)
if len(missing):
- raise ValueError("Missing required files: %s", ','.join(missing))
+ raise ValueError(
+ 'Missing required files: {files}'.format(files=','.join(missing)))
return ret