summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-12-04 10:01:46 -0500
committerScott Moser <smoser@ubuntu.com>2012-12-04 10:01:46 -0500
commit81ea305461777d5e5bec9f92a0b14c544aa6fd1e (patch)
treedde2cd2ef65f03cf48cdd51638d0332b0a32d4cc /cloudinit
parent52a1884822ecb9474e12e6c16b62dbd0728a4a0e (diff)
parent1e7b96743314f566814848ad05c5bc7271a5de91 (diff)
downloadvyos-cloud-init-81ea305461777d5e5bec9f92a0b14c544aa6fd1e.tar.gz
vyos-cloud-init-81ea305461777d5e5bec9f92a0b14c544aa6fd1e.zip
merge from trunk
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/config/cc_ca_certs.py9
-rw-r--r--cloudinit/config/cc_resizefs.py8
-rw-r--r--cloudinit/distros/__init__.py9
3 files changed, 19 insertions, 7 deletions
diff --git a/cloudinit/config/cc_ca_certs.py b/cloudinit/config/cc_ca_certs.py
index 20f24357..4f2a46a1 100644
--- a/cloudinit/config/cc_ca_certs.py
+++ b/cloudinit/config/cc_ca_certs.py
@@ -45,8 +45,15 @@ def add_ca_certs(certs):
# First ensure they are strings...
cert_file_contents = "\n".join([str(c) for c in certs])
util.write_file(CA_CERT_FULL_PATH, cert_file_contents, mode=0644)
+
# Append cert filename to CA_CERT_CONFIG file.
- util.write_file(CA_CERT_CONFIG, "\n%s" % CA_CERT_FILENAME, omode="ab")
+ # We have to strip the content because blank lines in the file
+ # causes subsequent entries to be ignored. (LP: #1077020)
+ orig = util.load_file(CA_CERT_CONFIG)
+ cur_cont = '\n'.join([l for l in orig.splitlines()
+ if l != CA_CERT_FILENAME])
+ out = "%s\n%s\n" % (cur_cont.rstrip(), CA_CERT_FILENAME)
+ util.write_file(CA_CERT_CONFIG, out, omode="wb")
def remove_default_ca_certs():
diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py
index b958f332..70294eda 100644
--- a/cloudinit/config/cc_resizefs.py
+++ b/cloudinit/config/cc_resizefs.py
@@ -32,6 +32,8 @@ RESIZE_FS_PREFIXES_CMDS = [
('xfs', 'xfs_growfs'),
]
+NOBLOCK = "noblock"
+
def nodeify_path(devpth, where, log):
try:
@@ -68,7 +70,7 @@ def handle(name, cfg, _cloud, log, args):
else:
resize_root = util.get_cfg_option_str(cfg, "resize_rootfs", True)
- if not util.translate_bool(resize_root):
+ if not util.translate_bool(resize_root, addons=[NOBLOCK]):
log.debug("Skipping module named %s, resizing disabled", name)
return
@@ -110,7 +112,7 @@ def handle(name, cfg, _cloud, log, args):
log.debug("Resizing %s (%s) using %s", resize_what, fs_type, resizer)
resize_cmd = [resizer, devpth]
- if resize_root == "noblock":
+ if resize_root == NOBLOCK:
# Fork to a child that will run
# the resize command
util.fork_cb(do_resize, resize_cmd, log)
@@ -120,7 +122,7 @@ def handle(name, cfg, _cloud, log, args):
do_resize(resize_cmd, log)
action = 'Resized'
- if resize_root == "noblock":
+ if resize_root == NOBLOCK:
action = 'Resizing (via forking)'
log.debug("%s root filesystem (type=%s, maj=%i, min=%i, val=%s)",
action, fs_type, os.major(st_dev), os.minor(st_dev), resize_root)
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index ea0bac23..6a684b89 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -24,7 +24,6 @@
from StringIO import StringIO
import abc
-import collections
import itertools
import os
import re
@@ -421,12 +420,16 @@ class Distro(object):
'',
"# User rules for %s" % user,
]
- if isinstance(rules, collections.Iterable):
+ if isinstance(rules, (list, tuple)):
for rule in rules:
lines.append("%s %s" % (user, rule))
- else:
+ elif isinstance(rules, (basestring, str)):
lines.append("%s %s" % (user, rules))
+ else:
+ msg = "Can not create sudoers rule addition with type %r"
+ raise TypeError(msg % (util.obj_name(rules)))
content = "\n".join(lines)
+ content += "\n" # trailing newline
self.ensure_sudo_dir(os.path.dirname(sudo_file))
if not os.path.exists(sudo_file):