summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-02-16 16:52:58 -0500
committerScott Moser <smoser@ubuntu.com>2012-02-16 16:52:58 -0500
commit9f171511042d29542d8578957c6692c2c9457583 (patch)
tree75ecc2df553f24cf0f91c1c019d06575731d0d81
parent3027a0d417723ce071ad048092607b3f7187ce08 (diff)
downloadvyos-cloud-init-9f171511042d29542d8578957c6692c2c9457583.tar.gz
vyos-cloud-init-9f171511042d29542d8578957c6692c2c9457583.zip
DataSourceNoCloud: allow reading user-data and meta-data from simple files
This allows you to attach a disk in ISO9660 or vfat filesystem format labeled 'cidata' with 'user-data' and 'meta-data' on it. It provides a much easier way to interact with cloud-init in nocloud than mounting the image or the OVF method.
-rw-r--r--cloudinit/DataSourceNoCloud.py21
-rw-r--r--cloudinit/util.py4
2 files changed, 23 insertions, 2 deletions
diff --git a/cloudinit/DataSourceNoCloud.py b/cloudinit/DataSourceNoCloud.py
index fa64f2e5..6c744b82 100644
--- a/cloudinit/DataSourceNoCloud.py
+++ b/cloudinit/DataSourceNoCloud.py
@@ -23,6 +23,7 @@ import cloudinit.DataSource as DataSource
from cloudinit import seeddir as base_seeddir
from cloudinit import log
import cloudinit.util as util
+import errno
class DataSourceNoCloud(DataSource.DataSource):
@@ -64,6 +65,26 @@ class DataSourceNoCloud(DataSource.DataSource):
found.append(self.seeddir)
log.debug("using seeded cache data in %s" % self.seeddir)
+ fslist = util.find_devs_with("TYPE=vfat")
+ fslist.extend(util.find_devs_with("TYPE=iso9660"))
+
+ label_list = util.find_devs_with("LABEL=cidata")
+ devlist = list(set(fslist) & set(label_list))
+ devlist.sort(reverse=True)
+
+ for dev in devlist:
+ try:
+ (newmd, newud) = util.mount_callback_umount(dev,
+ util.read_seeded)
+ md = util.mergedict(newmd, md)
+ ud = newud
+ log.debug("using data from %s" % dev)
+ found.append(dev)
+ break
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+
# there was no indication on kernel cmdline or data
# in the seeddir suggesting this handler should be used.
if len(found) == 0:
diff --git a/cloudinit/util.py b/cloudinit/util.py
index b53aa5fe..0a691dcf 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -681,7 +681,7 @@ def mount_callback_umount(device, callback, data=None):
umount = False
if device in mounted:
- mountpoint = mounted[device][2]
+ mountpoint = "%s/" % mounted[device][2]
else:
tmpd = tempfile.mkdtemp()
@@ -695,7 +695,7 @@ def mount_callback_umount(device, callback, data=None):
print exc.output[1]
raise mountFailedError(exc.output[1])
- mountpoint = tmpd
+ mountpoint = "%s/" % tmpd
try:
if data == None: