diff options
-rw-r--r-- | cloudinit/CloudConfig/__init__.py | 3 | ||||
-rw-r--r-- | cloudinit/CloudConfig/cc_apt_update_upgrade.py | 3 | ||||
-rw-r--r-- | cloudinit/CloudConfig/cc_chef.py | 21 | ||||
-rw-r--r-- | cloudinit/CloudConfig/cc_keys_to_console.py | 6 | ||||
-rw-r--r-- | cloudinit/CloudConfig/cc_mcollective.py | 12 | ||||
-rw-r--r-- | cloudinit/CloudConfig/cc_phone_home.py | 3 | ||||
-rw-r--r-- | cloudinit/CloudConfig/cc_puppet.py | 9 | ||||
-rw-r--r-- | cloudinit/CloudConfig/cc_resizefs.py | 4 | ||||
-rw-r--r-- | cloudinit/CloudConfig/cc_ssh.py | 7 | ||||
-rw-r--r-- | cloudinit/DataSourceEc2.py | 12 | ||||
-rw-r--r-- | cloudinit/DataSourceOVF.py | 2 | ||||
-rw-r--r-- | cloudinit/SshUtil.py | 7 | ||||
-rw-r--r-- | cloudinit/UserDataHandler.py | 3 | ||||
-rw-r--r-- | cloudinit/__init__.py | 6 | ||||
-rw-r--r-- | cloudinit/util.py | 10 |
15 files changed, 70 insertions, 38 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) diff --git a/cloudinit/DataSourceEc2.py b/cloudinit/DataSourceEc2.py index 35aa75d5..14484bdd 100644 --- a/cloudinit/DataSourceEc2.py +++ b/cloudinit/DataSourceEc2.py @@ -46,9 +46,12 @@ class DataSourceEc2(DataSource.DataSource): if not self.wait_for_metadata_service(): return False start = time.time() - self.userdata_raw = boto_utils.get_instance_userdata(self.api_ver, None, self.metadata_address) - self.metadata = boto_utils.get_instance_metadata(self.api_ver, self.metadata_address) - log.debug("crawl of metadata service took %ds" % (time.time()-start)) + self.userdata_raw = boto_utils.get_instance_userdata(self.api_ver, + None, self.metadata_address) + self.metadata = boto_utils.get_instance_metadata(self.api_ver, + self.metadata_address) + log.debug("crawl of metadata service took %ds" % (time.time() - + start)) return True except Exception as e: print e @@ -201,7 +204,8 @@ class DataSourceEc2(DataSource.DataSource): return False -def wait_for_metadata_service(urls, max_wait=None, timeout=None, status_cb=None): +def wait_for_metadata_service(urls, max_wait=None, timeout=None, + status_cb=None): """ urls: a list of urls to try max_wait: roughly the maximum time to wait before giving up diff --git a/cloudinit/DataSourceOVF.py b/cloudinit/DataSourceOVF.py index 995dbe67..4e960ffa 100644 --- a/cloudinit/DataSourceOVF.py +++ b/cloudinit/DataSourceOVF.py @@ -242,6 +242,7 @@ def transport_iso9660(require_iso=False): return(False, None, None) def transport_vmware_guestd(): + # pylint: disable=C0301 # http://blogs.vmware.com/vapp/2009/07/selfconfiguration-and-the-ovf-environment.html # try: # cmd = ['vmware-guestd', '--cmd', 'info-get guestinfo.ovfEnv'] @@ -251,6 +252,7 @@ def transport_vmware_guestd(): # # would need to error check here and see why this failed # # to know if log/error should be raised # return(False, None, None) + # pylint: enable=C0301 return(False, None, None) diff --git a/cloudinit/SshUtil.py b/cloudinit/SshUtil.py index 32370ff1..7ca60388 100644 --- a/cloudinit/SshUtil.py +++ b/cloudinit/SshUtil.py @@ -64,8 +64,9 @@ class AuthKeyEntry(): return def debug(self): - print("line_in=%s\ncomment: %s\noptions=%s\nkeytype=%s\nbase64=%s\ncomment=%s\n" % - (self.line_in, self.is_comment, self.options, self.keytype, self.base64, self.comment)), + print("line_in=%s\ncomment: %s\noptions=%s\nkeytype=%s\nbase64=%s\n" + "comment=%s\n" % (self.line_in, self.is_comment, self.options, + self.keytype, self.base64, self.comment)), def __repr__(self): if self.is_comment: return(self.line_in) @@ -153,6 +154,7 @@ def setup_user_keys(keys, user, key_prefix, log=None): if __name__ == "__main__": import sys + # pylint: disable=C0301 # usage: orig_file, new_keys, [key_prefix] # prints out merged, where 'new_keys' will trump old ## example @@ -168,6 +170,7 @@ if __name__ == "__main__": # # Then run as: # program authorized_keys new_keys 'no-port-forwarding,command=\"echo hi world;\"' + # pylint: enable=C0301 def_prefix = None orig_key_file = sys.argv[1] new_key_file = sys.argv[2] diff --git a/cloudinit/UserDataHandler.py b/cloudinit/UserDataHandler.py index 6372dc09..19c331be 100644 --- a/cloudinit/UserDataHandler.py +++ b/cloudinit/UserDataHandler.py @@ -214,7 +214,8 @@ def preprocess_userdata(data): process_includes(message_from_string(decomp_str(data)), newmsg) return(newmsg.as_string()) -# callback is a function that will be called with (data, content_type, filename, payload) +# callback is a function that will be called with (data, content_type, +# filename, payload) def walk_userdata(istr, callback, data = None): partnum = 0 for part in message_from_string(istr).walk(): diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py index 449e4648..3bc6516a 100644 --- a/cloudinit/__init__.py +++ b/cloudinit/__init__.py @@ -350,7 +350,8 @@ class CloudInit: try: mod = __import__(modname) handler_register(mod, part_handlers, data, frequency) - log.debug("added handler for [%s] from %s" % (mod.list_types(), fname)) + log.debug("added handler for [%s] from %s" % (mod.list_types(), + fname)) except: log.warn("failed to initialize handler in %s" % fname) util.logexc(log) @@ -420,7 +421,8 @@ class CloudInit: self.cloud_config_str += "\n#%s\n%s" % (filename, payload) - def handle_cloud_boothook(self, _data, ctype, filename, payload, _frequency): + def handle_cloud_boothook(self, _data, ctype, filename, payload, + _frequency): if ctype == "__end__": return if ctype == "__begin__": diff --git a/cloudinit/util.py b/cloudinit/util.py index e59ad3a0..7df773ce 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -177,7 +177,8 @@ def subp(args, input_=None): return(out, err) def render_to_file(template, outfile, searchList): - t = Template(file='/etc/cloud/templates/%s.tmpl' % template, searchList=[searchList]) + t = Template(file='/etc/cloud/templates/%s.tmpl' % template, + searchList=[searchList]) f = open(outfile, 'w') f.write(t.respond()) f.close() @@ -320,7 +321,8 @@ def read_conf_with_confd(cfgfile): if cfg['conf_d'] is not None: confd = cfg['conf_d'] if not isinstance(confd, str): - raise Exception("cfgfile %s contains 'conf_d' with non-string" % cfgfile) + raise Exception("cfgfile %s contains 'conf_d' " + "with non-string" % cfgfile) elif os.path.isdir("%s.d" % cfgfile): confd = "%s.d" % cfgfile @@ -455,8 +457,8 @@ def islxc(): raise try: - # try to run a program named 'lxc-is-container'. if it returns true, then - # we're inside a container. otherwise, no + # try to run a program named 'lxc-is-container'. if it returns true, + # then we're inside a container. otherwise, no sp = subprocess.Popen(['lxc-is-container'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) sp.communicate(None) |