summaryrefslogtreecommitdiff
path: root/cloudinit/CloudConfig
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-01-17 15:59:21 -0500
committerScott Moser <smoser@ubuntu.com>2012-01-17 15:59:21 -0500
commit1e746f00edbf478cf0ae43b66ff7899b6819fa33 (patch)
tree533a5f7b80ce1ec9a5cd2c670d2a781b6a54a4f1 /cloudinit/CloudConfig
parentd4c5cfd23e693959a1478e4bf59a08e4dce9ca6c (diff)
parentdcb543887bcb0770bbb7b102e9d6a7c732d0228d (diff)
downloadvyos-cloud-init-1e746f00edbf478cf0ae43b66ff7899b6819fa33.tar.gz
vyos-cloud-init-1e746f00edbf478cf0ae43b66ff7899b6819fa33.zip
miscellaneous cleanups, and add tools/run-pylint
adding run-pylint makes it easy to run pylint with given configuration against the code.
Diffstat (limited to 'cloudinit/CloudConfig')
-rw-r--r--cloudinit/CloudConfig/cc_mounts.py4
-rw-r--r--cloudinit/CloudConfig/cc_set_passwords.py8
-rw-r--r--cloudinit/CloudConfig/cc_ssh.py8
3 files changed, 8 insertions, 12 deletions
diff --git a/cloudinit/CloudConfig/cc_mounts.py b/cloudinit/CloudConfig/cc_mounts.py
index dbd9c454..2fa57362 100644
--- a/cloudinit/CloudConfig/cc_mounts.py
+++ b/cloudinit/CloudConfig/cc_mounts.py
@@ -18,7 +18,7 @@
import cloudinit.util as util
import os
import re
-import string
+from string import whitespace # pylint: disable=W0402
def is_mdname(name):
@@ -139,7 +139,7 @@ def handle(_name, cfg, cloud, log, _args):
fstab_lines = []
fstab = open("/etc/fstab", "r+")
- ws = re.compile("[%s]+" % string.whitespace)
+ ws = re.compile("[%s]+" % whitespace)
for line in fstab.read().splitlines():
try:
toks = ws.split(line)
diff --git a/cloudinit/CloudConfig/cc_set_passwords.py b/cloudinit/CloudConfig/cc_set_passwords.py
index 05384f4f..f40544b3 100644
--- a/cloudinit/CloudConfig/cc_set_passwords.py
+++ b/cloudinit/CloudConfig/cc_set_passwords.py
@@ -19,7 +19,7 @@
import cloudinit.util as util
import sys
import random
-import string
+from string import letters, digits # pylint: disable=W0402
def handle(_name, cfg, _cloud, log, args):
@@ -117,11 +117,11 @@ def handle(_name, cfg, _cloud, log, args):
return
-def rand_str(strlen=32, select_from=string.letters + string.digits):
+def rand_str(strlen=32, select_from=letters + digits):
return("".join([random.choice(select_from) for _x in range(0, strlen)]))
def rand_user_password(pwlen=9):
- selfrom = (string.letters.translate(None, 'loLOI') +
- string.digits.translate(None, '01'))
+ selfrom = (letters.translate(None, 'loLOI') +
+ digits.translate(None, '01'))
return(rand_str(pwlen, select_from=selfrom))
diff --git a/cloudinit/CloudConfig/cc_ssh.py b/cloudinit/CloudConfig/cc_ssh.py
index 39862117..cdf90bdc 100644
--- a/cloudinit/CloudConfig/cc_ssh.py
+++ b/cloudinit/CloudConfig/cc_ssh.py
@@ -25,12 +25,8 @@ 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\""
-global_log = None
-
def handle(_name, cfg, cloud, log, _args):
- global global_log
- global_log = log
# remove the static keys from the pristine image
if cfg.get("ssh_deletekeys", True):
@@ -87,14 +83,14 @@ def handle(_name, cfg, cloud, log, _args):
cfgkeys = cfg["ssh_authorized_keys"]
keys.extend(cfgkeys)
- apply_credentials(keys, user, disable_root, disable_root_opts)
+ apply_credentials(keys, user, disable_root, disable_root_opts, log)
except:
util.logexc(log)
log.warn("applying credentials failed!\n")
def apply_credentials(keys, user, disable_root,
- disable_root_opts=DISABLE_ROOT_OPTS, log=global_log):
+ disable_root_opts=DISABLE_ROOT_OPTS, log=None):
keys = set(keys)
if user:
sshutil.setup_user_keys(keys, user, '', log)