diff options
author | Scott Moser <smoser@brickies.net> | 2017-06-15 16:39:50 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-06-15 17:02:01 -0400 |
commit | 9ccb8f5e2ab262ee04bb9c103c1302479f7c81d3 (patch) | |
tree | 9f3f74137c89ed4a652322bdaf1b71192b57632a /cloudinit/sources | |
parent | ea0a534d93544837e44d03e3394233d28c247f7d (diff) | |
download | vyos-cloud-init-9ccb8f5e2ab262ee04bb9c103c1302479f7c81d3.tar.gz vyos-cloud-init-9ccb8f5e2ab262ee04bb9c103c1302479f7c81d3.zip |
FreeBSD: fix test failure
The previous commit caused test failure.
This separates out _check_freebsd_cdrom and mocks it in a test
rather than patching open.
Diffstat (limited to 'cloudinit/sources')
-rw-r--r-- | cloudinit/sources/DataSourceAzure.py | 21 |
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)) |