make config of nocloud datasource able to specify meta-data and user-data

This commit is contained in:
Scott Moser 2013-02-04 22:23:42 -05:00
parent a1efdc8a34
commit cceaa4db42
2 changed files with 47 additions and 26 deletions

View File

@ -77,10 +77,21 @@ class DataSourceNoCloud(sources.DataSource):
found.append("ds_config")
md["seedfrom"] = self.ds_cfg['seedfrom']
# if ds_cfg has 'user-data' and 'meta-data'
if 'user-data' in self.ds_cfg and 'meta-data' in self.ds_cfg:
if self.ds_cfg['user-data']:
ud = util.mergedict(md, self.ds_cfg['user-data'])
if self.ds_cfg['meta-data'] is not False:
md = util.mergedict(md, self.ds_cfg['meta-data'])
if 'ds_config' not in found:
found.append("ds_config")
if self.ds_cfg.get('fs_label', "cidata"):
fslist = util.find_devs_with("TYPE=vfat")
fslist.extend(util.find_devs_with("TYPE=iso9660"))
label_list = util.find_devs_with("LABEL=cidata")
label = self.ds_cfg.get('fs_label')
label_list = util.find_devs_with("LABEL=%s" % label)
devlist = list(set(fslist) & set(label_list))
devlist.sort(reverse=True)
@ -93,9 +104,8 @@ class DataSourceNoCloud(sources.DataSource):
ud = newud
# For seed from a device, the default mode is 'net'.
# that is more likely to be what is desired.
# If they want dsmode of local, then they must
# specify that.
# that is more likely to be what is desired. If they want
# dsmode of local, then they must specify that.
if 'dsmode' not in md:
md['dsmode'] = "net"

View File

@ -31,3 +31,14 @@ datasource:
# <url>/user-data and <url>/meta-data
# seedfrom: http://my.example.com/i-abcde
seedfrom: None
# fs_label: the label on filesystems to be searched for NoCloud source
fs_label: cidata
# these are optional, but allow you to basically provide a datasource
# right here
user-data: |
# This is the user-data verbatum
meta-data:
instance-id: i-87018aed
local-hostname: myhost.internal