summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorRémy Léone <rleone@online.net>2018-03-01 18:23:32 +0100
committerScott Moser <smoser@ubuntu.com>2018-03-02 12:53:26 -0500
commitffc6917aa0b97811c1e8503cd4cff9f11c15def1 (patch)
treebb2f58a42472a1d62cc9dfda544f7118a842b80a /cloudinit
parent40e77380e036a24fafe91a63d0cdefada4312348 (diff)
downloadvyos-cloud-init-ffc6917aa0b97811c1e8503cd4cff9f11c15def1.tar.gz
vyos-cloud-init-ffc6917aa0b97811c1e8503cd4cff9f11c15def1.zip
Change some list creation and population to literal.
This will provide a small performance improvement and shorter code.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/cmd/main.py10
-rw-r--r--cloudinit/config/cc_keys_to_console.py4
-rwxr-xr-xcloudinit/config/cc_ssh_authkey_fingerprints.py9
-rw-r--r--cloudinit/distros/arch.py5
-rw-r--r--cloudinit/distros/opensuse.py5
-rw-r--r--cloudinit/sources/DataSourceOpenNebula.py5
-rw-r--r--cloudinit/stages.py3
-rw-r--r--cloudinit/util.py3
8 files changed, 15 insertions, 29 deletions
diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
index d2f1b778..fcddd75c 100644
--- a/cloudinit/cmd/main.py
+++ b/cloudinit/cmd/main.py
@@ -215,12 +215,10 @@ def main_init(name, args):
if args.local:
deps = [sources.DEP_FILESYSTEM]
- early_logs = []
- early_logs.append(
- attempt_cmdline_url(
- path=os.path.join("%s.d" % CLOUD_CONFIG,
- "91_kernel_cmdline_url.cfg"),
- network=not args.local))
+ early_logs = [attempt_cmdline_url(
+ path=os.path.join("%s.d" % CLOUD_CONFIG,
+ "91_kernel_cmdline_url.cfg"),
+ network=not args.local)]
# Cloud-init 'init' stage is broken up into the following sub-stages
# 1. Ensure that the init object fetches its config without errors
diff --git a/cloudinit/config/cc_keys_to_console.py b/cloudinit/config/cc_keys_to_console.py
index efedd4ae..aff4010e 100644
--- a/cloudinit/config/cc_keys_to_console.py
+++ b/cloudinit/config/cc_keys_to_console.py
@@ -63,9 +63,7 @@ def handle(name, cfg, cloud, log, _args):
["ssh-dss"])
try:
- cmd = [helper_path]
- cmd.append(','.join(fp_blacklist))
- cmd.append(','.join(key_blacklist))
+ cmd = [helper_path, ','.join(fp_blacklist), ','.join(key_blacklist)]
(stdout, _stderr) = util.subp(cmd)
util.multi_log("%s\n" % (stdout.strip()),
stderr=False, console=True)
diff --git a/cloudinit/config/cc_ssh_authkey_fingerprints.py b/cloudinit/config/cc_ssh_authkey_fingerprints.py
index 35d8c57f..98b0e665 100755
--- a/cloudinit/config/cc_ssh_authkey_fingerprints.py
+++ b/cloudinit/config/cc_ssh_authkey_fingerprints.py
@@ -77,11 +77,10 @@ def _pprint_key_entries(user, key_fn, key_entries, hash_meth='md5',
tbl = SimpleTable(tbl_fields)
for entry in key_entries:
if _is_printable_key(entry):
- row = []
- row.append(entry.keytype or '-')
- row.append(_gen_fingerprint(entry.base64, hash_meth) or '-')
- row.append(entry.options or '-')
- row.append(entry.comment or '-')
+ row = [entry.keytype or '-',
+ _gen_fingerprint(entry.base64, hash_meth) or '-',
+ entry.options or '-',
+ entry.comment or '-']
tbl.add_row(row)
authtbl_s = tbl.get_string()
authtbl_lines = authtbl_s.splitlines()
diff --git a/cloudinit/distros/arch.py b/cloudinit/distros/arch.py
index f87a3432..b814c8ba 100644
--- a/cloudinit/distros/arch.py
+++ b/cloudinit/distros/arch.py
@@ -129,11 +129,8 @@ class Distro(distros.Distro):
if pkgs is None:
pkgs = []
- cmd = ['pacman']
+ cmd = ['pacman', "-Sy", "--quiet", "--noconfirm"]
# Redirect output
- cmd.append("-Sy")
- cmd.append("--quiet")
- cmd.append("--noconfirm")
if args and isinstance(args, str):
cmd.append(args)
diff --git a/cloudinit/distros/opensuse.py b/cloudinit/distros/opensuse.py
index a219e9fb..162dfa05 100644
--- a/cloudinit/distros/opensuse.py
+++ b/cloudinit/distros/opensuse.py
@@ -67,11 +67,10 @@ class Distro(distros.Distro):
if pkgs is None:
pkgs = []
- cmd = ['zypper']
# No user interaction possible, enable non-interactive mode
- cmd.append('--non-interactive')
+ cmd = ['zypper', '--non-interactive']
- # Comand is the operation, such as install
+ # Command is the operation, such as install
if command == 'upgrade':
command = 'update'
cmd.append(command)
diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py
index ce47b6bd..9450835e 100644
--- a/cloudinit/sources/DataSourceOpenNebula.py
+++ b/cloudinit/sources/DataSourceOpenNebula.py
@@ -173,10 +173,7 @@ class OpenNebulaNetwork(object):
def gen_conf(self):
global_dns = self.context.get('DNS', "").split()
- conf = []
- conf.append('auto lo')
- conf.append('iface lo inet loopback')
- conf.append('')
+ conf = ['auto lo', 'iface lo inet loopback', '']
for mac, dev in self.ifaces.items():
mac = mac.lower()
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index d0452688..bc4ebc85 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -132,8 +132,7 @@ class Init(object):
return initial_dirs
def purge_cache(self, rm_instance_lnk=False):
- rm_list = []
- rm_list.append(self.paths.boot_finished)
+ rm_list = [self.paths.boot_finished]
if rm_instance_lnk:
rm_list.append(self.paths.instance_link)
for f in rm_list:
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 02dc2ce8..b03b80c3 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -716,8 +716,7 @@ def redirect_output(outfmt, errfmt, o_out=None, o_err=None):
def make_url(scheme, host, port=None,
path='', params='', query='', fragment=''):
- pieces = []
- pieces.append(scheme or '')
+ pieces = [scheme or '']
netloc = ''
if host: