summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceAzure.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index ebb53d0a..71e7c55c 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -803,18 +803,23 @@ def encrypt_pass(password, salt_id="$6$"):
return crypt.crypt(password, salt_id + util.rand_str(strlen=16))
+def _check_freebsd_cdrom(cdrom_dev):
+ """Return boolean indicating path to cdrom device has content."""
+ try:
+ with open(cdrom_dev) as fp:
+ fp.read(1024)
+ return True
+ except IOError:
+ LOG.debug("cdrom (%s) is not configured", cdrom_dev)
+ return False
+
+
def list_possible_azure_ds_devs():
devlist = []
if util.is_FreeBSD():
- # add '/dev/cd0' to devlist if it is configured
- # here wants to test whether '/dev/cd0' is available
cdrom_dev = "/dev/cd0"
- try:
- with open(cdrom_dev) as fp:
- fp.read(1024)
- devlist.append(cdrom_dev)
- except IOError:
- LOG.debug("cdrom (%s) is not configured", cdrom_dev)
+ if _check_freebsd_cdrom(cdrom_dev):
+ return [cdrom_dev]
else:
for fstype in ("iso9660", "udf"):
devlist.extend(util.find_devs_with("TYPE=%s" % fstype))