summaryrefslogtreecommitdiff
path: root/cloudinit/distros
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-15 21:33:55 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-15 21:33:55 -0700
commit450261a1fcf1f8929a2f7a25c2c278ba40689289 (patch)
tree83430d74ea63c5a11df3fb774e281d0f8efce8f3 /cloudinit/distros
parent784edb7689d60b81a4334d5171603841cc83da98 (diff)
downloadvyos-cloud-init-450261a1fcf1f8929a2f7a25c2c278ba40689289.tar.gz
vyos-cloud-init-450261a1fcf1f8929a2f7a25c2c278ba40689289.zip
Fixups to ensure that pylint does not find anything major wrong.
Diffstat (limited to 'cloudinit/distros')
-rw-r--r--cloudinit/distros/__init__.py21
-rw-r--r--cloudinit/distros/ubuntu.py23
2 files changed, 22 insertions, 22 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index 90607668..fd4c70c1 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -20,29 +20,32 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from StringIO import StringIO
+
import abc
import copy
from cloudinit import importer
+from cloudinit import log as logging
from cloudinit import util
-from StringIO import StringIO
-
# TODO: Make this via config??
IFACE_ACTIONS = {
'up': ['ifup', '--all'],
'down': ['ifdown', '--all'],
}
+LOG = logging.getLogger(__name__)
+
class Distro(object):
__metaclass__ = abc.ABCMeta
- def __init__(self, cfg, runner):
+ def __init__(self, name, cfg, runner):
self._runner = runner
- self._cfg = util.get_cfg_by_path(cfg, ('system_info', ), {})
- self.name = self._cfg.pop("distro", 'generic')
+ self._cfg = cfg
+ self.name = name
@abc.abstractmethod
def install_packages(self, pkglist):
@@ -135,10 +138,9 @@ class Distro(object):
action, cmd)
(_out, err) = util.subp(cmd)
if len(err):
- LOG.warn("Running %s resulted in stderr output: %s",
- IF_UP_CMD, err)
+ LOG.warn("Running %s resulted in stderr output: %s", cmd, err)
return True
- except util.ProcessExecutionError as exc:
+ except util.ProcessExecutionError:
util.logexc(LOG, "Running %s failed", cmd)
return False
@@ -152,7 +154,8 @@ def fetch(distro_name, mods=(__name__, )):
except RuntimeError:
pass
if not mod:
- raise RuntimeError("No distribution found for distro %s" % (distro_name))
+ raise RuntimeError("No distribution found for distro %s"
+ % (distro_name))
distro_cls = getattr(mod, 'Distro')
return distro_cls
diff --git a/cloudinit/distros/ubuntu.py b/cloudinit/distros/ubuntu.py
index 6b0aff47..9252a1c4 100644
--- a/cloudinit/distros/ubuntu.py
+++ b/cloudinit/distros/ubuntu.py
@@ -20,17 +20,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from StringIO import StringIO
-
import os
-import socket
from cloudinit import distros
from cloudinit import log as logging
-from cloudinit import templater
from cloudinit import util
-from cloudinit.settings import (PER_INSTANCE)
+from cloudinit.settings import PER_INSTANCE
LOG = logging.getLogger(__name__)
@@ -65,9 +61,11 @@ class Distro(distros.Distro):
try:
util.write_file(fn, "%s\n" % hostname, 0644)
except:
- util.logexc(LOG, "Failed to write hostname %s to %s", hostname, fn)
- if hostname_in_etc and hostname_prev and hostname_in_etc != hostname_prev:
- LOG.debug(("%s differs from /etc/hostname."
+ util.logexc(LOG, "Failed to write hostname %s to %s",
+ hostname, fn)
+ if (hostname_in_etc and hostname_prev and
+ hostname_in_etc != hostname_prev):
+ LOG.debug(("%s differs from /etc/hostname."
" Assuming user maintained hostname."), prev_file)
if "/etc/hostname" in update_files:
LOG.debug("Setting hostname to %s", hostname)
@@ -91,7 +89,8 @@ class Distro(distros.Distro):
def set_timezone(self, tz):
tz_file = os.path.join("/usr/share/zoneinfo", tz)
if not os.path.isfile(tz_file):
- raise Exception("Invalid timezone %s, no file found at %s" % (tz, tz_file))
+ raise Exception(("Invalid timezone %s,"
+ " no file found at %s") % (tz, tz_file))
tz_contents = "%s\n" % tz
util.write_file("/etc/timezone", tz_contents)
# TODO, this should be in a rhel distro subclass??
@@ -101,9 +100,6 @@ class Distro(distros.Distro):
# This ensures that the correct tz will be used for the system
util.copy(tz_file, "/etc/localtime")
- def name(self):
- return "ubuntu"
-
# apt_get top level command (install, update...), and args to pass it
def _apt_get(self, tlc, args=None):
e = os.environ.copy()
@@ -116,4 +112,5 @@ class Distro(distros.Distro):
util.subp(cmd, env=e, capture=False)
def _update_package_sources(self):
- self.runner.run("update-sources", self._apt_get, ["update"], freq=PER_INSTANCE) \ No newline at end of file
+ self._runner.run("update-sources", self._apt_get,
+ ["update"], freq=PER_INSTANCE) \ No newline at end of file