summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceNoCloud.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/sources/DataSourceNoCloud.py')
-rw-r--r--cloudinit/sources/DataSourceNoCloud.py40
1 files changed, 24 insertions, 16 deletions
diff --git a/cloudinit/sources/DataSourceNoCloud.py b/cloudinit/sources/DataSourceNoCloud.py
index 6860f0cc..ee748b41 100644
--- a/cloudinit/sources/DataSourceNoCloud.py
+++ b/cloudinit/sources/DataSourceNoCloud.py
@@ -35,6 +35,26 @@ class DataSourceNoCloud(sources.DataSource):
root = sources.DataSource.__str__(self)
return "%s [seed=%s][dsmode=%s]" % (root, self.seed, self.dsmode)
+ def _get_devices(self, label):
+ if util.is_FreeBSD():
+ devlist = [
+ p for p in ['/dev/msdosfs/' + label, '/dev/iso9660/' + label]
+ if os.path.exists(p)]
+ else:
+ # Query optical drive to get it in blkid cache for 2.6 kernels
+ util.find_devs_with(path="/dev/sr0")
+ util.find_devs_with(path="/dev/sr1")
+
+ fslist = util.find_devs_with("TYPE=vfat")
+ fslist.extend(util.find_devs_with("TYPE=iso9660"))
+
+ label_list = util.find_devs_with("LABEL=%s" % label.upper())
+ label_list.extend(util.find_devs_with("LABEL=%s" % label.lower()))
+
+ devlist = list(set(fslist) & set(label_list))
+ devlist.sort(reverse=True)
+ return devlist
+
def _get_data(self):
defaults = {
"instance-id": "nocloud",
@@ -99,18 +119,7 @@ class DataSourceNoCloud(sources.DataSource):
label = self.ds_cfg.get('fs_label', "cidata")
if label is not None:
- # Query optical drive to get it in blkid cache for 2.6 kernels
- util.find_devs_with(path="/dev/sr0")
- util.find_devs_with(path="/dev/sr1")
-
- fslist = util.find_devs_with("TYPE=vfat")
- fslist.extend(util.find_devs_with("TYPE=iso9660"))
-
- label_list = util.find_devs_with("LABEL=%s" % label)
- devlist = list(set(fslist) & set(label_list))
- devlist.sort(reverse=True)
-
- for dev in devlist:
+ for dev in self._get_devices(label):
try:
LOG.debug("Attempting to use data from %s", dev)
@@ -118,9 +127,8 @@ class DataSourceNoCloud(sources.DataSource):
seeded = util.mount_cb(dev, _pp2d_callback,
pp2d_kwargs)
except ValueError:
- if dev in label_list:
- LOG.warning("device %s with label=%s not a"
- "valid seed.", dev, label)
+ LOG.warning("device %s with label=%s not a "
+ "valid seed.", dev, label)
continue
mydata = _merge_new_seed(mydata, seeded)
@@ -258,7 +266,7 @@ def load_cmdline_data(fill, cmdline=None):
("ds=nocloud-net", sources.DSMODE_NETWORK)]
for idstr, dsmode in pairs:
if parse_cmdline_data(idstr, fill, cmdline):
- # if dsmode was explicitly in the commanad line, then
+ # if dsmode was explicitly in the command line, then
# prefer it to the dsmode based on the command line id
if 'dsmode' not in fill:
fill['dsmode'] = dsmode