summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-20 17:13:55 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-20 17:13:55 -0700
commitec4bdc4fb8d8d3a8f8b4f498eb47eac740485ede (patch)
tree306886dd731180f1c51583679a7bb33c7c7f10d8 /cloudinit/config
parent5c5525b35970611a5c4dbd44c5c6b6e2d57556cb (diff)
downloadvyos-cloud-init-ec4bdc4fb8d8d3a8f8b4f498eb47eac740485ede.tar.gz
vyos-cloud-init-ec4bdc4fb8d8d3a8f8b4f498eb47eac740485ede.zip
Massive pylint + pep8 fixups!
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/__init__.py2
-rw-r--r--cloudinit/config/cc_chef.py14
-rw-r--r--cloudinit/config/cc_disable_ec2_metadata.py4
-rw-r--r--cloudinit/config/cc_final_message.py8
-rw-r--r--cloudinit/config/cc_foo.py8
-rw-r--r--cloudinit/config/cc_keys_to_console.py8
-rw-r--r--cloudinit/config/cc_landscape.py2
-rw-r--r--cloudinit/config/cc_mcollective.py4
-rw-r--r--cloudinit/config/cc_mounts.py13
-rw-r--r--cloudinit/config/cc_phone_home.py11
-rw-r--r--cloudinit/config/cc_puppet.py2
-rw-r--r--cloudinit/config/cc_resizefs.py10
-rw-r--r--cloudinit/config/cc_salt_minion.py2
-rw-r--r--cloudinit/config/cc_scripts_per_boot.py6
-rw-r--r--cloudinit/config/cc_scripts_per_instance.py6
-rw-r--r--cloudinit/config/cc_scripts_per_once.py6
-rw-r--r--cloudinit/config/cc_scripts_user.py6
-rw-r--r--cloudinit/config/cc_set_passwords.py4
-rw-r--r--cloudinit/config/cc_ssh.py39
19 files changed, 80 insertions, 75 deletions
diff --git a/cloudinit/config/__init__.py b/cloudinit/config/__init__.py
index 74e2f275..02e32462 100644
--- a/cloudinit/config/__init__.py
+++ b/cloudinit/config/__init__.py
@@ -25,7 +25,7 @@ from cloudinit import log as logging
LOG = logging.getLogger(__name__)
-# This prefix is used to make it less
+# This prefix is used to make it less
# of a change that when importing
# we will not find something else with the same
# name in the lookup path...
diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py
index 4e8ef346..74af2a7e 100644
--- a/cloudinit/config/cc_chef.py
+++ b/cloudinit/config/cc_chef.py
@@ -24,7 +24,7 @@ import os
from cloudinit import templater
from cloudinit import util
-ruby_version_default = "1.8"
+RUBY_VERSION_DEFAULT = "1.8"
def handle(name, cfg, cloud, log, _args):
@@ -38,11 +38,11 @@ def handle(name, cfg, cloud, log, _args):
# Ensure the chef directories we use exist
c_dirs = [
- '/etc/chef',
- '/var/log/chef',
- '/var/lib/chef',
- '/var/cache/chef',
- '/var/backups/chef',
+ '/etc/chef',
+ '/var/log/chef',
+ '/var/lib/chef',
+ '/var/cache/chef',
+ '/var/backups/chef',
'/var/run/chef',
]
for d in c_dirs:
@@ -92,7 +92,7 @@ def handle(name, cfg, cloud, log, _args):
# this will install and run the chef-client from gems
chef_version = util.get_cfg_option_str(chef_cfg, 'version', None)
ruby_version = util.get_cfg_option_str(chef_cfg, 'ruby_version',
- ruby_version_default)
+ RUBY_VERSION_DEFAULT)
install_chef_from_gems(cloud.distro, ruby_version, chef_version)
# and finally, run chef-client
log.debug('Running chef-client')
diff --git a/cloudinit/config/cc_disable_ec2_metadata.py b/cloudinit/config/cc_disable_ec2_metadata.py
index c7d26029..62cca7cc 100644
--- a/cloudinit/config/cc_disable_ec2_metadata.py
+++ b/cloudinit/config/cc_disable_ec2_metadata.py
@@ -24,13 +24,13 @@ from cloudinit.settings import PER_ALWAYS
frequency = PER_ALWAYS
-reject_cmd = ['route', 'add', '-host', '169.254.169.254', 'reject']
+REJECT_CMD = ['route', 'add', '-host', '169.254.169.254', 'reject']
def handle(name, cfg, _cloud, log, _args):
disabled = util.get_cfg_option_bool(cfg, "disable_ec2_metadata", False)
if disabled:
- util.subp(reject_cmd)
+ util.subp(REJECT_CMD)
else:
log.debug(("Skipping transform named %s,"
" disabling the ec2 route not enabled"), name)
diff --git a/cloudinit/config/cc_final_message.py b/cloudinit/config/cc_final_message.py
index c257b6d0..fd59aa1e 100644
--- a/cloudinit/config/cc_final_message.py
+++ b/cloudinit/config/cc_final_message.py
@@ -28,7 +28,7 @@ from cloudinit.settings import PER_ALWAYS
frequency = PER_ALWAYS
-final_message_def = ("Cloud-init v. {{version}} finished at {{timestamp}}."
+FINAL_MESSAGE_DEF = ("Cloud-init v. {{version}} finished at {{timestamp}}."
" Up {{uptime}} seconds.")
@@ -39,21 +39,21 @@ def handle(_name, cfg, cloud, log, args):
msg_in = args[0]
else:
msg_in = util.get_cfg_option_str(cfg, "final_message")
-
+
if not msg_in:
template_fn = cloud.get_template_filename('final_message')
if template_fn:
msg_in = util.load_file(template_fn)
if not msg_in:
- msg_in = final_message_def
+ msg_in = FINAL_MESSAGE_DEF
uptime = util.uptime()
ts = util.time_rfc2822()
cver = version.version_string()
try:
subs = {
- 'uptime': uptime,
+ 'uptime': uptime,
'timestamp': ts,
'version': cver,
}
diff --git a/cloudinit/config/cc_foo.py b/cloudinit/config/cc_foo.py
index 99135704..e81e7faa 100644
--- a/cloudinit/config/cc_foo.py
+++ b/cloudinit/config/cc_foo.py
@@ -30,19 +30,19 @@ from cloudinit.settings import PER_INSTANCE
# as well as any datasource provided configuration
# c) A cloud object that can be used to access various
# datasource and paths for the given distro and data provided
-# by the various datasource instance types.
+# by the various datasource instance types.
# d) A argument list that may or may not be empty to this module.
# Typically those are from module configuration where the module
# is defined with some extra configuration that will eventually
# be translated from yaml into arguments to this module.
# 2. A optional 'frequency' that defines how often this module should be ran.
-# Typically one of PER_INSTANCE, PER_ALWAYS, PER_ONCE. If not
-# provided PER_INSTANCE will be assumed.
+# Typically one of PER_INSTANCE, PER_ALWAYS, PER_ONCE. If not
+# provided PER_INSTANCE will be assumed.
# See settings.py for these constants.
# 3. A optional 'distros' array/set/tuple that defines the known distros
# this module will work with (if not all of them). This is used to write
# a warning out if a module is being ran on a untested distribution for
-# informational purposes. If non existent all distros are assumed and
+# informational purposes. If non existent all distros are assumed and
# no warning occurs.
frequency = PER_INSTANCE
diff --git a/cloudinit/config/cc_keys_to_console.py b/cloudinit/config/cc_keys_to_console.py
index 40758198..a8fb3ba7 100644
--- a/cloudinit/config/cc_keys_to_console.py
+++ b/cloudinit/config/cc_keys_to_console.py
@@ -26,13 +26,13 @@ from cloudinit import util
frequency = PER_INSTANCE
# This is a tool that cloud init provides
-helper_tool = '/usr/lib/cloud-init/write-ssh-key-fingerprints'
+HELPER_TOOL = '/usr/lib/cloud-init/write-ssh-key-fingerprints'
def handle(name, cfg, cloud, log, _args):
- if not os.path.exists(helper_tool):
+ if not os.path.exists(HELPER_TOOL):
log.warn(("Unable to activate transform %s,"
- " helper tool not found at %s"), name, helper_tool)
+ " helper tool not found at %s"), name, HELPER_TOOL)
return
fp_blacklist = util.get_cfg_option_list(cfg,
@@ -42,7 +42,7 @@ def handle(name, cfg, cloud, log, _args):
["ssh-dss"])
try:
- cmd = [helper_tool]
+ cmd = [HELPER_TOOL]
cmd.append(','.join(fp_blacklist))
cmd.append(','.join(key_blacklist))
(stdout, _stderr) = util.subp(cmd)
diff --git a/cloudinit/config/cc_landscape.py b/cloudinit/config/cc_landscape.py
index 29ce41b9..599276a7 100644
--- a/cloudinit/config/cc_landscape.py
+++ b/cloudinit/config/cc_landscape.py
@@ -62,7 +62,7 @@ def handle(name, cfg, cloud, log, _args):
ls_cloudcfg = cfg.get("landscape", {})
if not isinstance(ls_cloudcfg, dict):
- raise Exception(("'landscape' key existed in config,"
+ raise Exception(("'landscape' key existed in config,"
" but not a dictionary type,"
" is a %s instead"), util.obj_name(ls_cloudcfg))
diff --git a/cloudinit/config/cc_mcollective.py b/cloudinit/config/cc_mcollective.py
index 4cec6494..ba5e13ca 100644
--- a/cloudinit/config/cc_mcollective.py
+++ b/cloudinit/config/cc_mcollective.py
@@ -52,7 +52,7 @@ def handle(name, cfg, cloud, log, _args):
# It doesn't contain any sections so just add one temporarily
# Use a hash id based off the contents,
# just incase of conflicts... (try to not have any...)
- # This is so that an error won't occur when reading (and no
+ # This is so that an error won't occur when reading (and no
# sections exist in the file)
section_tpl = "[nullsection_%s]"
attempts = 0
@@ -85,7 +85,7 @@ def handle(name, cfg, cloud, log, _args):
# the previous server.cfg and create our new one
old_fn = "%s.old" % (server_cfg_fn)
util.rename(server_cfg_fn, old_fn)
- # Now we got the whole file, write to disk except the section
+ # Now we got the whole file, write to disk except the section
# we added so that config parser won't error out when trying to read.
# Note below, that we've just used ConfigParser because it generally
# works. Below, we remove the initial 'nullsection' header.
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py
index 700fbc44..ab097c2a 100644
--- a/cloudinit/config/cc_mounts.py
+++ b/cloudinit/config/cc_mounts.py
@@ -24,10 +24,10 @@ import re
from cloudinit import util
-# shortname matches 'sda', 'sda1', 'xvda', 'hda', 'sdb', xvdb, vda, vdd1
-shortname_filter = r"^[x]{0,1}[shv]d[a-z][0-9]*$"
-shortname = re.compile(shortname_filter)
-ws = re.compile("[%s]+" % (whitespace))
+# Shortname matches 'sda', 'sda1', 'xvda', 'hda', 'sdb', xvdb, vda, vdd1
+SHORTNAME_FILTER = r"^[x]{0,1}[shv]d[a-z][0-9]*$"
+SHORTNAME = re.compile(SHORTNAME_FILTER)
+WS = re.compile("[%s]+" % (whitespace))
def is_mdname(name):
@@ -55,7 +55,6 @@ def handle(_name, cfg, cloud, log, _args):
if "mounts" in cfg:
cfgmnt = cfg["mounts"]
-
for i in range(len(cfgmnt)):
# skip something that wasn't a list
if not isinstance(cfgmnt[i], list):
@@ -85,7 +84,7 @@ def handle(_name, cfg, cloud, log, _args):
cfgmnt[i][0] = renamed
log.debug("Mapped metadata name %s to %s", startname, renamed)
else:
- if shortname.match(startname):
+ if SHORTNAME.match(startname):
renamed = "/dev/%s" % startname
log.debug("Mapped shortname name %s to %s", startname, renamed)
cfgmnt[i][0] = renamed
@@ -171,7 +170,7 @@ def handle(_name, cfg, cloud, log, _args):
fstab = util.load_file(cloud.paths.join(True, "/etc/fstab"))
for line in fstab.splitlines():
try:
- toks = ws.split(line)
+ toks = WS.split(line)
if toks[3].find(comment) != -1:
continue
except:
diff --git a/cloudinit/config/cc_phone_home.py b/cloudinit/config/cc_phone_home.py
index a8752527..dcb07b66 100644
--- a/cloudinit/config/cc_phone_home.py
+++ b/cloudinit/config/cc_phone_home.py
@@ -26,8 +26,13 @@ from cloudinit.settings import PER_INSTANCE
frequency = PER_INSTANCE
-post_list_all = ['pub_key_dsa', 'pub_key_rsa', 'pub_key_ecdsa',
- 'instance_id', 'hostname']
+POST_LIST_ALL = [
+ 'pub_key_dsa',
+ 'pub_key_rsa',
+ 'pub_key_ecdsa',
+ 'instance_id',
+ 'hostname'
+]
# phone_home:
@@ -63,7 +68,7 @@ def handle(name, cfg, cloud, log, args):
" is not an integer, using %s instead"), tries)
if post_list == "all":
- post_list = post_list_all
+ post_list = POST_LIST_ALL
all_keys = {}
all_keys['instance_id'] = cloud.get_instance_id()
diff --git a/cloudinit/config/cc_puppet.py b/cloudinit/config/cc_puppet.py
index 5fb88bf2..5154efba 100644
--- a/cloudinit/config/cc_puppet.py
+++ b/cloudinit/config/cc_puppet.py
@@ -63,7 +63,7 @@ def handle(name, cfg, cloud, log, _args):
util.ensure_dir(pp_ssl_dir, 0771)
util.chownbyid(pp_ssl_dir,
pwd.getpwnam('puppet').pw_uid, 0)
- pp_ssl_certs = cloud.paths.join(False,
+ pp_ssl_certs = cloud.paths.join(False,
'/var/lib/puppet/ssl/certs/')
util.ensure_dir(pp_ssl_certs)
util.chownbyid(pp_ssl_certs,
diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py
index 1690094a..c019989e 100644
--- a/cloudinit/config/cc_resizefs.py
+++ b/cloudinit/config/cc_resizefs.py
@@ -27,7 +27,7 @@ from cloudinit.settings import PER_ALWAYS
frequency = PER_ALWAYS
-resize_fs_prefixes_cmds = [
+RESIZE_FS_PREFIXES_CMDS = [
('ext', 'resize2fs'),
('xfs', 'xfs_growfs'),
]
@@ -89,16 +89,16 @@ def handle(name, cfg, cloud, log, args):
# occurs this temporary file will still benefit from
# auto deletion
tfh.unlink_now()
-
+
st_dev = nodeify_path(devpth, resize_what, log)
fs_type = get_fs_type(st_dev, devpth, log)
if not fs_type:
log.warn("Could not determine filesystem type of %s", resize_what)
return
-
+
resizer = None
fstype_lc = fs_type.lower()
- for (pfix, root_cmd) in resize_fs_prefixes_cmds:
+ for (pfix, root_cmd) in RESIZE_FS_PREFIXES_CMDS:
if fstype_lc.startswith(pfix):
resizer = root_cmd
break
@@ -112,7 +112,7 @@ def handle(name, cfg, cloud, log, args):
resize_cmd = [resizer, devpth]
if resize_root == "noblock":
- # Fork to a child that will run
+ # Fork to a child that will run
# the resize command
util.fork_cb(do_resize, resize_cmd, log)
# Don't delete the file now in the parent
diff --git a/cloudinit/config/cc_salt_minion.py b/cloudinit/config/cc_salt_minion.py
index 16f5286d..986e6db6 100644
--- a/cloudinit/config/cc_salt_minion.py
+++ b/cloudinit/config/cc_salt_minion.py
@@ -32,7 +32,7 @@ def handle(name, cfg, cloud, log, _args):
# Start by installing the salt package ...
cloud.distro.install_packages(["salt"])
-
+
# Ensure we can configure files at the right dir
config_dir = salt_cfg.get("config_dir", '/etc/salt')
config_dir = cloud.paths.join(False, config_dir)
diff --git a/cloudinit/config/cc_scripts_per_boot.py b/cloudinit/config/cc_scripts_per_boot.py
index 364e1d02..d3c47442 100644
--- a/cloudinit/config/cc_scripts_per_boot.py
+++ b/cloudinit/config/cc_scripts_per_boot.py
@@ -26,16 +26,16 @@ from cloudinit.settings import PER_ALWAYS
frequency = PER_ALWAYS
-script_subdir = 'per-boot'
+SCRIPT_SUBDIR = 'per-boot'
def handle(name, _cfg, cloud, log, _args):
# Comes from the following:
# https://forums.aws.amazon.com/thread.jspa?threadID=96918
- runparts_path = os.path.join(cloud.get_cpath(), 'scripts', script_subdir)
+ runparts_path = os.path.join(cloud.get_cpath(), 'scripts', SCRIPT_SUBDIR)
try:
util.runparts(runparts_path)
except:
log.warn("Failed to run transform %s (%s in %s)",
- name, script_subdir, runparts_path)
+ name, SCRIPT_SUBDIR, runparts_path)
raise
diff --git a/cloudinit/config/cc_scripts_per_instance.py b/cloudinit/config/cc_scripts_per_instance.py
index d75ab47d..8e428ac2 100644
--- a/cloudinit/config/cc_scripts_per_instance.py
+++ b/cloudinit/config/cc_scripts_per_instance.py
@@ -26,16 +26,16 @@ from cloudinit.settings import PER_INSTANCE
frequency = PER_INSTANCE
-script_subdir = 'per-instance'
+SCRIPT_SUBDIR = 'per-instance'
def handle(name, _cfg, cloud, log, _args):
# Comes from the following:
# https://forums.aws.amazon.com/thread.jspa?threadID=96918
- runparts_path = os.path.join(cloud.get_cpath(), 'scripts', script_subdir)
+ runparts_path = os.path.join(cloud.get_cpath(), 'scripts', SCRIPT_SUBDIR)
try:
util.runparts(runparts_path)
except:
log.warn("Failed to run transform %s (%s in %s)",
- name, script_subdir, runparts_path)
+ name, SCRIPT_SUBDIR, runparts_path)
raise
diff --git a/cloudinit/config/cc_scripts_per_once.py b/cloudinit/config/cc_scripts_per_once.py
index 80f8c325..e7a29a44 100644
--- a/cloudinit/config/cc_scripts_per_once.py
+++ b/cloudinit/config/cc_scripts_per_once.py
@@ -26,16 +26,16 @@ from cloudinit.settings import PER_ONCE
frequency = PER_ONCE
-script_subdir = 'per-once'
+SCRIPT_SUBDIR = 'per-once'
def handle(name, _cfg, cloud, log, _args):
# Comes from the following:
# https://forums.aws.amazon.com/thread.jspa?threadID=96918
- runparts_path = os.path.join(cloud.get_cpath(), 'scripts', script_subdir)
+ runparts_path = os.path.join(cloud.get_cpath(), 'scripts', SCRIPT_SUBDIR)
try:
util.runparts(runparts_path)
except:
log.warn("Failed to run transform %s (%s in %s)",
- name, script_subdir, runparts_path)
+ name, SCRIPT_SUBDIR, runparts_path)
raise
diff --git a/cloudinit/config/cc_scripts_user.py b/cloudinit/config/cc_scripts_user.py
index f4fe3a2a..1ff05aae 100644
--- a/cloudinit/config/cc_scripts_user.py
+++ b/cloudinit/config/cc_scripts_user.py
@@ -26,17 +26,17 @@ from cloudinit.settings import PER_INSTANCE
frequency = PER_INSTANCE
-script_subdir = 'scripts'
+SCRIPT_SUBDIR = 'scripts'
def handle(name, _cfg, cloud, log, _args):
# This is written to by the user data handlers
# Ie, any custom shell scripts that come down
# go here...
- runparts_path = os.path.join(cloud.get_ipath_cur(), script_subdir)
+ runparts_path = os.path.join(cloud.get_ipath_cur(), SCRIPT_SUBDIR)
try:
util.runparts(runparts_path)
except:
log.warn("Failed to run transform %s (%s in %s)",
- name, script_subdir, runparts_path)
+ name, SCRIPT_SUBDIR, runparts_path)
raise
diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py
index e7049f22..ce17f357 100644
--- a/cloudinit/config/cc_set_passwords.py
+++ b/cloudinit/config/cc_set_passwords.py
@@ -25,7 +25,7 @@ from cloudinit import util
from string import letters, digits # pylint: disable=W0402
# We are removing certain 'painful' letters/numbers
-pw_set = (letters.translate(None, 'loLOI') +
+PW_SET = (letters.translate(None, 'loLOI') +
digits.translate(None, '01'))
@@ -148,4 +148,4 @@ def handle(_name, cfg, cloud, log, args):
def rand_user_password(pwlen=9):
- return util.rand_str(pwlen, select_from=pw_set)
+ return util.rand_str(pwlen, select_from=PW_SET)
diff --git a/cloudinit/config/cc_ssh.py b/cloudinit/config/cc_ssh.py
index e5e99560..4019ae90 100644
--- a/cloudinit/config/cc_ssh.py
+++ b/cloudinit/config/cc_ssh.py
@@ -24,11 +24,11 @@ import glob
from cloudinit import util
from cloudinit import ssh_util
-DISABLE_ROOT_OPTS = ( "no-port-forwarding,no-agent-forwarding,"
-"no-X11-forwarding,command=\"echo \'Please login as the user \\\"$USER\\\" "
+DISABLE_ROOT_OPTS = ("no-port-forwarding,no-agent-forwarding,"
+"no-X11-forwarding,command=\"echo \'Please login as the user \\\"$USER\\\" "
"rather than the user \\\"root\\\".\';echo;sleep 10\"")
-key2file = {
+KEY_2_FILE = {
"rsa_private": ("/etc/ssh/ssh_host_rsa_key", 0600),
"rsa_public": ("/etc/ssh/ssh_host_rsa_key.pub", 0644),
"dsa_private": ("/etc/ssh/ssh_host_dsa_key", 0600),
@@ -37,15 +37,17 @@ key2file = {
"ecdsa_public": ("/etc/ssh/ssh_host_ecdsa_key.pub", 0644),
}
-priv2pub = {
- 'rsa_private': 'rsa_public',
+PRIV_2_PUB = {
+ 'rsa_private': 'rsa_public',
'dsa_private': 'dsa_public',
'ecdsa_private': 'ecdsa_public',
}
-key_gen_tpl = 'o=$(ssh-keygen -yf "%s") && echo "$o" root@localhost > "%s"'
+KEY_GEN_TPL = 'o=$(ssh-keygen -yf "%s") && echo "$o" root@localhost > "%s"'
-generate_keys = ['rsa', 'dsa', 'ecdsa']
+GENERATE_KEY_NAMES = ['rsa', 'dsa', 'ecdsa']
+
+KEY_FILE_TPL = '/etc/ssh/ssh_host_%s_key'
def handle(_name, cfg, cloud, log, _args):
@@ -58,21 +60,21 @@ def handle(_name, cfg, cloud, log, _args):
util.del_file(f)
except:
util.logexc(log, "Failed deleting key file %s", f)
-
+
if "ssh_keys" in cfg:
# if there are keys in cloud-config, use them
for (key, val) in cfg["ssh_keys"].iteritems():
- if key in key2file:
- tgt_fn = key2file[key][0]
- tgt_perms = key2file[key][1]
+ if key in KEY_2_FILE:
+ tgt_fn = KEY_2_FILE[key][0]
+ tgt_perms = KEY_2_FILE[key][1]
util.write_file(cloud.paths.join(False, tgt_fn),
val, tgt_perms)
- for (priv, pub) in priv2pub.iteritems():
+ for (priv, pub) in PRIV_2_PUB.iteritems():
if pub in cfg['ssh_keys'] or not priv in cfg['ssh_keys']:
continue
- pair = (key2file[priv][0], key2file[pub][0])
- cmd = ['sh', '-xc', key_gen_tpl % pair]
+ pair = (KEY_2_FILE[priv][0], KEY_2_FILE[pub][0])
+ cmd = ['sh', '-xc', KEY_GEN_TPL % pair]
try:
# TODO: Is this guard needed?
with util.SeLinuxGuard("/etc/ssh", recursive=True):
@@ -84,12 +86,11 @@ def handle(_name, cfg, cloud, log, _args):
else:
# if not, generate them
genkeys = util.get_cfg_option_list(cfg,
- 'ssh_genkeytypes',
- generate_keys)
+ 'ssh_genkeytypes',
+ GENERATE_KEY_NAMES)
for keytype in genkeys:
- keyfile = '/etc/ssh/ssh_host_%s_key' % (keytype)
- keyfile = cloud.paths.join(False, keyfile)
- util.ensure_dir(os.path.dirname(keyfile))
+ keyfile = cloud.paths.join(False, KEY_FILE_TPL % (keytype))
+ util.ensure_dir(os.path.dirname(keyfile))
if not os.path.exists(keyfile):
cmd = ['ssh-keygen', '-t', keytype, '-N', '', '-f', keyfile]
try: