Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_devs_with_openbsd: ensure we return the last entry #1149

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions cloudinit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ def find_devs_with_openbsd(criteria=None, oformat='device',
tag=None, no_cache=False, path=None):
out, _err = subp.subp(['sysctl', '-n', 'hw.disknames'], rcs=[0])
devlist = []
for entry in out.split(','):
for entry in out.rstrip().split(','):
if not entry.endswith(':'):
# ffs partition with a serial, not a config-drive
continue
Expand All @@ -1220,12 +1220,6 @@ def find_devs_with_openbsd(criteria=None, oformat='device',
devlist.append(entry[:-1] + 'a')
if not entry.startswith('cd'):
devlist.append(entry[:-1] + 'i')
if criteria == "TYPE=iso9660":
devlist = [i for i in devlist if i.startswith('cd')]
elif criteria in ["LABEL=CONFIG-2", "TYPE=vfat"]:
devlist = [i for i in devlist if not i.startswith('cd')]
elif criteria:
LOG.debug("Unexpected criteria: %s", criteria)
return ['/dev/' + i for i in devlist]


Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,7 @@ def test_find_devs_with_openbsd(self, m_subp):
def test_find_devs_with_openbsd_with_criteria(self, m_subp):
m_subp.return_value = ('cd0:,sd0:630d98d32b5d3759,sd1:,fd0:', '')
devlist = util.find_devs_with_openbsd(criteria="TYPE=iso9660")
assert devlist == ['/dev/cd0a']
assert devlist == ['/dev/cd0a', '/dev/sd1a', '/dev/sd1i']

# lp: #1841466
devlist = util.find_devs_with_openbsd(criteria="LABEL_FATBOOT=A_LABEL")
Expand Down