← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~redriver/cloud-init:fix-mount-issue-for-frbsd-on-Azure into cloud-init:master

 

Hongjiang Zhang has proposed merging ~redriver/cloud-init:fix-mount-issue-for-frbsd-on-Azure into cloud-init:master.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~redriver/cloud-init/+git/cloud-init/+merge/325207

Fix the bug of #1696295 (https://bugs.launchpad.net/cloud-init/+bug/1696295)
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~redriver/cloud-init:fix-mount-issue-for-frbsd-on-Azure into cloud-init:master.
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index a0b9eae..17737bb 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -800,17 +800,22 @@ def encrypt_pass(password, salt_id="$6$"):
 
 def list_possible_azure_ds_devs():
     # return a sorted list of devices that might have a azure datasource
+    def cd_avail_cb_on_freebsd(source_dir):
+        return True
     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:
-            util.subp(["mount", "-o", "ro", "-t", "udf", cdrom_dev,
-                       "/mnt/cdrom/secure"])
-        except util.ProcessExecutionError:
-            LOG.debug("Fail to mount cd")
+            ret = util.mount_cb(cdrom_dev, cd_avail_cb_on_freebsd,
+                                mtype="udf", sync=False)
+            if ret:
+                devlist.append(cdrom_dev)
+            else:
+                LOG.debug("cdrom (%s) is not configured", cdrom_dev)
+        except util.MountFailedError:
             return devlist
-        util.subp(["umount", "/mnt/cdrom/secure"])
-        devlist.append(cdrom_dev)
     else:
         for fstype in ("iso9660", "udf"):
             devlist.extend(util.find_devs_with("TYPE=%s" % fstype))

Follow ups