summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcloud-init-run-module.py4
-rw-r--r--cloudinit/CloudConfig/cc_apt_update_upgrade.py5
-rw-r--r--cloudinit/CloudConfig/cc_mounts.py49
-rw-r--r--doc/examples/cloud-config.txt2
-rw-r--r--doc/examples/part-handler.txt13
-rwxr-xr-xsetup.py2
-rw-r--r--upstart/cloud-config.conf1
7 files changed, 50 insertions, 26 deletions
diff --git a/cloud-init-run-module.py b/cloud-init-run-module.py
index 1877ab2c..1bb99698 100755
--- a/cloud-init-run-module.py
+++ b/cloud-init-run-module.py
@@ -44,7 +44,9 @@ def main():
fail("Failed to get instance data\n\t%s" % traceback.format_exc(),log)
if cloud.sem_has_run(semname,freq):
- err("%s already ran %s" % (semname,freq),log)
+ msg="%s already ran %s" % (semname,freq)
+ sys.stderr.write("%s\n" % msg)
+ log.debug(msg)
sys.exit(0)
try:
diff --git a/cloudinit/CloudConfig/cc_apt_update_upgrade.py b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
index 50c93222..e1226c85 100644
--- a/cloudinit/CloudConfig/cc_apt_update_upgrade.py
+++ b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
@@ -65,7 +65,10 @@ def handle(name,cfg,cloud,log,args):
e['DEBIAN_FRONTEND']='noninteractive'
if upgrade:
- subprocess.Popen(['apt-get', 'upgrade', '--assume-yes'], env=e).communicate()
+ cmd=[ 'apt-get', '--option', 'Dpkg::Options::=--force-confold',
+ 'upgrade', '--assume-yes' ]
+
+ subprocess.Popen(cmd, env=e).communicate()
if pkglist:
cmd=['apt-get', 'install', '--assume-yes']
diff --git a/cloudinit/CloudConfig/cc_mounts.py b/cloudinit/CloudConfig/cc_mounts.py
index ffc647aa..0ce45373 100644
--- a/cloudinit/CloudConfig/cc_mounts.py
+++ b/cloudinit/CloudConfig/cc_mounts.py
@@ -20,18 +20,33 @@ import os
import re
import string
+def is_mdname(name):
+ # return true if this is a metadata service name
+ if name in [ "ami", "root", "swap" ]:
+ return True
+ # names 'ephemeral0' or 'ephemeral1'
+ # 'ebs[0-9]' appears when '--block-device-mapping sdf=snap-d4d90bbc'
+ for enumname in ( "ephemeral", "ebs" ):
+ if name.startswith(enumname) and name.find(":") == -1:
+ return True
+ return False
+
def handle(name,cfg,cloud,log,args):
# these are our default set of mounts
- defmnts = [ [ "ephemeral0", "/mnt", "auto", "defaults", "0", "0" ],
+ defmnts = [ [ "ephemeral0", "/mnt", "auto", "defaults", "0", "2" ],
[ "swap", "none", "swap", "sw", "0", "0" ] ]
# fs_spec, fs_file, fs_vfstype, fs_mntops, fs-freq, fs_passno
- defvals = [ None, None, "auto", "defaults", "0", "0" ]
+ defvals = [ None, None, "auto", "defaults,nobootwait", "0", "2" ]
cfgmnt = [ ]
if cfg.has_key("mounts"):
cfgmnt = cfg["mounts"]
+ # shortname matches 'sda', 'sda1', 'xvda', 'hda'
+ shortname_filter = r"^[x]{0,1}[shv]d[a-z][0-9]*$"
+ shortname = re.compile(shortname_filter)
+
for i in range(len(cfgmnt)):
# skip something that wasn't a list
if not isinstance(cfgmnt[i],list): continue
@@ -41,24 +56,19 @@ def handle(name,cfg,cloud,log,args):
if cfgmnt[i][0] == "ephemeral":
cfgmnt[i][0] = "ephemeral0"
- newname = cfgmnt[i][0]
- if not newname.startswith("/"):
+ if is_mdname(cfgmnt[i][0]):
newname = cloud.device_name_to_device(cfgmnt[i][0])
- if newname is not None:
- cfgmnt[i][0] = newname
- else:
- # there is no good way of differenciating between
- # a name that *couldn't* exist in the md service and
- # one that merely didnt
- # in order to allow user to specify 'sda3' rather
- # than '/dev/sda3', go through some hoops
- ok = False
- for f in [ "/", "sd", "hd", "vd", "xvd" ]:
- if cfgmnt[i][0].startswith(f):
- ok = True
- break
- if not ok:
+ if not newname:
+ log.debug("ignoring nonexistant named mount %s" % cfgmnt[i][0])
cfgmnt[i][1] = None
+ else:
+ if newname.startswith("/"):
+ cfgmnt[i][0] = newname
+ else:
+ cfgmnt[i][0] = "/dev/%s" % newname
+ else:
+ if shortname.match(cfgmnt[i][0]):
+ cfgmnt[i][0] = "/dev/%s" % cfgmnt[i][0]
for i in range(len(cfgmnt)):
# fill in values with
@@ -68,9 +78,6 @@ def handle(name,cfg,cloud,log,args):
elif cfgmnt[i][j] is None:
cfgmnt[i][j] = defvals[j]
- if not cfgmnt[i][0].startswith("/"):
- cfgmnt[i][0]="/dev/%s" % cfgmnt[i][0]
-
# if the second entry in the list is 'None' this
# clears all previous entries of that same 'fs_spec'
# (fs_spec is the first field in /etc/fstab, ie, that device)
diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt
index e036feba..ec1ad17b 100644
--- a/doc/examples/cloud-config.txt
+++ b/doc/examples/cloud-config.txt
@@ -102,7 +102,7 @@ packages:
# written to /etc/fstab.
# - '/dev' can be ommitted for device names that begin with: xvd, sd, hd, vd
# - if an entry does not have all 6 fields, they will be filled in
-# from the following: [ None, None, "auto", "defaults", "0", "0" ]
+# from the following: [ None, None, "auto", "defaults,nobootwait", "0", "2" ]
#
# Note, that you should set 'nobootwait' (see man fstab) for volumes that may
# not be attached at instance boot (or reboot)
diff --git a/doc/examples/part-handler.txt b/doc/examples/part-handler.txt
index 1fe37f3a..a6e66415 100644
--- a/doc/examples/part-handler.txt
+++ b/doc/examples/part-handler.txt
@@ -2,10 +2,21 @@
# vi: syntax=python ts=4
def list_types():
+ # return a list of mime-types that are handled by this module
return(["text/plain", "text/go-cubs-go"])
def handle_part(data,ctype,filename,payload):
- if ctype == "__end__" or ctype == "__begin__": return
+ # data: the cloudinit object
+ # ctype: '__begin__', '__end__', or the specific mime-type of the part
+ # filename: the filename for the part, or dynamically generated part if
+ # no filename is given attribute is present
+ # payload: the content of the part (empty for begin or end)
+ if ctype == "__begin__":
+ print "my handler is beginning"
+ return
+ if ctype == "__end__":
+ print "my handler is ending"
+ return
print "==== received ctype=%s filename=%s ====" % (ctype,filename)
print payload
diff --git a/setup.py b/setup.py
index 7a1d7bf3..017a350e 100755
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@ import os.path
import subprocess
setup(name='cloud-init',
- version='0.5.12',
+ version='0.5.13',
description='EC2 initialisation magic',
author='Scott Moser',
author_email='scott.moser@canonical.com',
diff --git a/upstart/cloud-config.conf b/upstart/cloud-config.conf
index 7c4d3370..6649a99d 100644
--- a/upstart/cloud-config.conf
+++ b/upstart/cloud-config.conf
@@ -3,5 +3,6 @@ description "Handle applying cloud-config"
start on (filesystem and started rsyslog)
console output
+task
exec cloud-init-cfg all