summaryrefslogtreecommitdiff
path: root/cloudinit/CloudConfig
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-01-17 12:41:09 -0500
committerScott Moser <smoser@ubuntu.com>2012-01-17 12:41:09 -0500
commitec070cdf8746651d6dea011bd3ea9a445223028c (patch)
treeacc620e1f0423910a4d0ea0d79ee231290e4a393 /cloudinit/CloudConfig
parent1a1da7c11e8bbb7e9f4b06a06ee5d6b18fdc1efc (diff)
downloadvyos-cloud-init-ec070cdf8746651d6dea011bd3ea9a445223028c.tar.gz
vyos-cloud-init-ec070cdf8746651d6dea011bd3ea9a445223028c.zip
[PATCH 4/4] Fix pylint conventions C0301 (line too long)
From: Juerg Haefliger <juerg.haefliger@hp.com>
Diffstat (limited to 'cloudinit/CloudConfig')
-rw-r--r--cloudinit/CloudConfig/__init__.py3
-rw-r--r--cloudinit/CloudConfig/cc_apt_update_upgrade.py3
-rw-r--r--cloudinit/CloudConfig/cc_chef.py21
-rw-r--r--cloudinit/CloudConfig/cc_keys_to_console.py6
-rw-r--r--cloudinit/CloudConfig/cc_mcollective.py12
-rw-r--r--cloudinit/CloudConfig/cc_phone_home.py3
-rw-r--r--cloudinit/CloudConfig/cc_puppet.py9
-rw-r--r--cloudinit/CloudConfig/cc_resizefs.py4
-rw-r--r--cloudinit/CloudConfig/cc_ssh.py7
9 files changed, 43 insertions, 25 deletions
diff --git a/cloudinit/CloudConfig/__init__.py b/cloudinit/CloudConfig/__init__.py
index caf7e333..76cafebd 100644
--- a/cloudinit/CloudConfig/__init__.py
+++ b/cloudinit/CloudConfig/__init__.py
@@ -46,7 +46,8 @@ class CloudConfig():
cfg = util.read_conf(cfgfile)
except:
# TODO: this 'log' could/should be passed in
- cloudinit.log.critical("Failed loading of cloud config '%s'. Continuing with empty config\n" % cfgfile)
+ cloudinit.log.critical("Failed loading of cloud config '%s'. "
+ "Continuing with empty config\n" % cfgfile)
cloudinit.log.debug(traceback.format_exc() + "\n")
cfg = None
if cfg is None:
diff --git a/cloudinit/CloudConfig/cc_apt_update_upgrade.py b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
index 1da4e613..dea89d25 100644
--- a/cloudinit/CloudConfig/cc_apt_update_upgrade.py
+++ b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
@@ -123,7 +123,8 @@ def rename_apt_lists(omirror, new_mirror, lists_d="/var/lib/apt/lists"):
os.rename(filename, "%s%s" % (nprefix, filename[olen:]))
def get_release():
- stdout, _stderr = subprocess.Popen(['lsb_release', '-cs'], stdout=subprocess.PIPE).communicate()
+ stdout, _stderr = subprocess.Popen(['lsb_release', '-cs'],
+ stdout=subprocess.PIPE).communicate()
return(stdout.strip())
def generate_sources_list(codename, mirror):
diff --git a/cloudinit/CloudConfig/cc_chef.py b/cloudinit/CloudConfig/cc_chef.py
index 55ecdab4..4f740aff 100644
--- a/cloudinit/CloudConfig/cc_chef.py
+++ b/cloudinit/CloudConfig/cc_chef.py
@@ -36,7 +36,8 @@ def handle(_name, cfg, cloud, log, _args):
# set the validation key based on the presence of either 'validation_key'
# or 'validation_cert'. In the case where both exist, 'validation_key'
# takes precedence
- if chef_cfg.has_key('validation_key') or chef_cfg.has_key('validation_cert'):
+ if (chef_cfg.has_key('validation_key') or
+ chef_cfg.has_key('validation_cert')):
validation_key = util.get_cfg_option_str(chef_cfg, 'validation_key',
chef_cfg['validation_cert'])
with open('/etc/chef/validation.pem', 'w') as validation_key_fh:
@@ -44,12 +45,12 @@ def handle(_name, cfg, cloud, log, _args):
# create the chef config from template
util.render_to_file('chef_client.rb', '/etc/chef/client.rb',
- {'server_url': chef_cfg['server_url'],
- 'node_name': util.get_cfg_option_str(chef_cfg, 'node_name',
- cloud.datasource.get_instance_id()),
- 'environment': util.get_cfg_option_str(chef_cfg, 'environment',
- '_default'),
- 'validation_name': chef_cfg['validation_name']})
+ {'server_url': chef_cfg['server_url'],
+ 'node_name': util.get_cfg_option_str(chef_cfg, 'node_name',
+ cloud.datasource.get_instance_id()),
+ 'environment': util.get_cfg_option_str(chef_cfg, 'environment',
+ '_default'),
+ 'validation_name': chef_cfg['validation_name']})
# set the firstboot json
with open('/etc/chef/firstboot.json', 'w') as firstboot_json_fh:
@@ -64,7 +65,8 @@ def handle(_name, cfg, cloud, log, _args):
# If chef is not installed, we install chef based on 'install_type'
if not os.path.isfile('/usr/bin/chef-client'):
- install_type = util.get_cfg_option_str(chef_cfg, 'install_type', 'packages')
+ install_type = util.get_cfg_option_str(chef_cfg, 'install_type',
+ 'packages')
if install_type == "gems":
# this will install and run the chef-client from gems
chef_version = util.get_cfg_option_str(chef_cfg, 'version', None)
@@ -73,7 +75,8 @@ def handle(_name, cfg, cloud, log, _args):
install_chef_from_gems(ruby_version, chef_version)
# and finally, run chef-client
log.debug('running chef-client')
- subprocess.check_call(['/usr/bin/chef-client', '-d', '-i', '1800', '-s', '20'])
+ subprocess.check_call(['/usr/bin/chef-client', '-d', '-i', '1800',
+ '-s', '20'])
else:
# this will install and run the chef-client from packages
cc.install_packages(('chef',))
diff --git a/cloudinit/CloudConfig/cc_keys_to_console.py b/cloudinit/CloudConfig/cc_keys_to_console.py
index bbc45c4a..d462a0a8 100644
--- a/cloudinit/CloudConfig/cc_keys_to_console.py
+++ b/cloudinit/CloudConfig/cc_keys_to_console.py
@@ -23,8 +23,10 @@ frequency = per_instance
def handle(_name, cfg, _cloud, log, _args):
cmd = [ '/usr/lib/cloud-init/write-ssh-key-fingerprints' ]
- fp_blacklist = util.get_cfg_option_list_or_str(cfg, "ssh_fp_console_blacklist", [])
- key_blacklist = util.get_cfg_option_list_or_str(cfg, "ssh_key_console_blacklist", ["ssh-dss"])
+ fp_blacklist = util.get_cfg_option_list_or_str(cfg,
+ "ssh_fp_console_blacklist", [])
+ key_blacklist = util.get_cfg_option_list_or_str(cfg,
+ "ssh_key_console_blacklist", ["ssh-dss"])
try:
confp = open('/dev/console', "wb")
cmd.append(','.join(fp_blacklist))
diff --git a/cloudinit/CloudConfig/cc_mcollective.py b/cloudinit/CloudConfig/cc_mcollective.py
index ec5da4f8..8ad8caab 100644
--- a/cloudinit/CloudConfig/cc_mcollective.py
+++ b/cloudinit/CloudConfig/cc_mcollective.py
@@ -53,8 +53,10 @@ def handle(_name, cfg, _cloud, _log, _args):
if mcollective_cfg.has_key('conf'):
# Create object for reading server.cfg values
mcollective_config = ConfigParser.ConfigParser()
- # Read server.cfg values from original file in order to be able to mix the rest up
- mcollective_config.readfp(FakeSecHead(open('/etc/mcollective/server.cfg')))
+ # Read server.cfg values from original file in order to be able to mix
+ # the rest up
+ mcollective_config.readfp(FakeSecHead(open('/etc/mcollective/'
+ 'server.cfg')))
for cfg_name, cfg in mcollective_cfg['conf'].iteritems():
if cfg_name == 'public-cert':
util.write_file(pubcert_file, cfg, mode=0644)
@@ -73,7 +75,8 @@ def handle(_name, cfg, _cloud, _log, _args):
mcollective_config.set(cfg_name, o, v)
# We got all our config as wanted we'll rename
# the previous server.cfg and create our new one
- os.rename('/etc/mcollective/server.cfg', '/etc/mcollective/server.cfg.old')
+ os.rename('/etc/mcollective/server.cfg',
+ '/etc/mcollective/server.cfg.old')
outputfile = StringIO.StringIO()
mcollective_config.write(outputfile)
# Now we got the whole file, write to disk except first line
@@ -83,7 +86,8 @@ def handle(_name, cfg, _cloud, _log, _args):
# search and replace of '=' with ':' could be problematic though.
# this most likely needs fixing.
util.write_file('/etc/mcollective/server.cfg',
- outputfile.getvalue().replace('[nullsection]\n', '').replace(' =', ':'),
+ outputfile.getvalue().replace('[nullsection]\n', '').replace(' =',
+ ':'),
mode=0644)
# Start mcollective
diff --git a/cloudinit/CloudConfig/cc_phone_home.py b/cloudinit/CloudConfig/cc_phone_home.py
index 61b769a7..05caf8eb 100644
--- a/cloudinit/CloudConfig/cc_phone_home.py
+++ b/cloudinit/CloudConfig/cc_phone_home.py
@@ -20,7 +20,8 @@ import cloudinit.util as util
from time import sleep
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:
# url: http://my.foo.bar/$INSTANCE/
diff --git a/cloudinit/CloudConfig/cc_puppet.py b/cloudinit/CloudConfig/cc_puppet.py
index 2686c849..5fb0c1ee 100644
--- a/cloudinit/CloudConfig/cc_puppet.py
+++ b/cloudinit/CloudConfig/cc_puppet.py
@@ -39,8 +39,10 @@ def handle(_name, cfg, cloud, log, _args):
puppet_conf_fh = open('/etc/puppet/puppet.conf', 'r')
# Create object for reading puppet.conf values
puppet_config = ConfigParser.ConfigParser()
- # Read puppet.conf values from original file in order to be able to mix the rest up
- puppet_config.readfp(StringIO.StringIO(''.join(i.lstrip() for i in puppet_conf_fh.readlines())))
+ # Read puppet.conf values from original file in order to be able to
+ # mix the rest up
+ puppet_config.readfp(StringIO.StringIO(''.join(i.lstrip() for i in
+ puppet_conf_fh.readlines())))
# Close original file, no longer needed
puppet_conf_fh.close()
for cfg_name, cfg in puppet_cfg['conf'].iteritems():
@@ -64,7 +66,8 @@ def handle(_name, cfg, cloud, log, _args):
util.restorecon_if_possible('/var/lib/puppet', recursive=True)
else:
#puppet_conf_fh.write("\n[%s]\n" % (cfg_name))
- # If puppet.conf already has this section we don't want to write it again
+ # If puppet.conf already has this section we don't want to
+ # write it again
if puppet_config.has_section(cfg_name) == False:
puppet_config.add_section(cfg_name)
# Iterate throug the config items, we'll use ConfigParser.set
diff --git a/cloudinit/CloudConfig/cc_resizefs.py b/cloudinit/CloudConfig/cc_resizefs.py
index 1fd9f094..d960afd5 100644
--- a/cloudinit/CloudConfig/cc_resizefs.py
+++ b/cloudinit/CloudConfig/cc_resizefs.py
@@ -63,9 +63,9 @@ def handle(_name, cfg, _cloud, log, args):
raise
log.debug("resizing root filesystem (type=%s, maj=%i, min=%i)" %
- (fstype.rstrip("\n"), os.major(st_dev), os.minor(st_dev)))
+ (str(fstype).rstrip("\n"), os.major(st_dev), os.minor(st_dev)))
- if fstype.startswith("ext"):
+ if str(fstype).startswith("ext"):
resize_cmd = [ 'resize2fs', devpth ]
elif fstype == "xfs":
resize_cmd = [ 'xfs_growfs', devpth ]
diff --git a/cloudinit/CloudConfig/cc_ssh.py b/cloudinit/CloudConfig/cc_ssh.py
index 9751bba5..b6ac1edb 100644
--- a/cloudinit/CloudConfig/cc_ssh.py
+++ b/cloudinit/CloudConfig/cc_ssh.py
@@ -21,7 +21,9 @@ import os
import glob
import subprocess
-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\""
+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
@@ -90,7 +92,8 @@ def handle(_name, cfg, cloud, log, _args):
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):
+def apply_credentials(keys, user, disable_root,
+ disable_root_opts=DISABLE_ROOT_OPTS, log=global_log):
keys = set(keys)
if user:
sshutil.setup_user_keys(keys, user, '', log)