~smoser/cloud-init/lp-1077700

« back to all changes in this revision

Viewing changes to cloudinit/distros/__init__.py

  • Committer: Scott Moser
  • Author(s): Joshua Harlow
  • Date: 2012-11-07 15:42:54 UTC
  • mfrom: (696.1.2 pylint-join-cleanup)
  • Revision ID: smoser@ubuntu.com-20121107154254-lhs4c0cu79unybbs
test and path cleanups.

1. Remove the usage of the path.join function now that all code should
   be going through the util file methods (and they can be mocked out as
   needed).
2. Adjust all occurences of the above join function to either not use it
   or replace it with the standard os.path.join (which can also be mocked
   out as needed)
3. Fix pylint from complaining about the tests folder 'helpers.py' not
   being found.
4. Add a pylintrc file that is used instead of the options hidden in the
   'run_pylint' tool.

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
        new_etchosts = StringIO()
123
123
        need_write = False
124
124
        need_change = True
125
 
        hosts_ro_fn = self._paths.join(True, "/etc/hosts")
126
 
        for line in util.load_file(hosts_ro_fn).splitlines():
 
125
        for line in util.load_file("/etc/hosts").splitlines():
127
126
            if line.strip().startswith(header):
128
127
                continue
129
128
            if not line.strip() or line.strip().startswith("#"):
147
146
            need_write = True
148
147
        if need_write:
149
148
            contents = new_etchosts.getvalue()
150
 
            util.write_file(self._paths.join(False, "/etc/hosts"),
151
 
                            contents, mode=0644)
 
149
            util.write_file("/etc/hosts", contents, mode=0644)
152
150
 
153
151
    def _bring_up_interface(self, device_name):
154
152
        cmd = ['ifup', device_name]
262
260
        # Import SSH keys
263
261
        if 'ssh_authorized_keys' in kwargs:
264
262
            keys = set(kwargs['ssh_authorized_keys']) or []
265
 
            ssh_util.setup_user_keys(keys, name, None, self._paths)
 
263
            ssh_util.setup_user_keys(keys, name, key_prefix=None)
266
264
 
267
265
        return True
268
266