diff options
author | Gonéri Le Bouder <goneri@lebouder.net> | 2020-04-24 15:42:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 13:42:36 -0600 |
commit | 72f6eb0339f7fcf7b8b02be2e86e5f7477cf731c (patch) | |
tree | 753d4a0791b0f044f789c57f025dc5d6e2558030 /cloudinit/sources/DataSourceNoCloud.py | |
parent | e4499963d663b52ca4b66423c0445909d710cfbd (diff) | |
download | vyos-cloud-init-72f6eb0339f7fcf7b8b02be2e86e5f7477cf731c.tar.gz vyos-cloud-init-72f6eb0339f7fcf7b8b02be2e86e5f7477cf731c.zip |
BSD: find_devs_with_ refactoring (#298)
Refactoring of the `find_devs_with_*bsd()` methods:
- centralize everything in `util.py`
- add test coverage
Diffstat (limited to 'cloudinit/sources/DataSourceNoCloud.py')
-rw-r--r-- | cloudinit/sources/DataSourceNoCloud.py | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/cloudinit/sources/DataSourceNoCloud.py b/cloudinit/sources/DataSourceNoCloud.py index 71d5fc2e..72d86c41 100644 --- a/cloudinit/sources/DataSourceNoCloud.py +++ b/cloudinit/sources/DataSourceNoCloud.py @@ -36,27 +36,14 @@ class DataSourceNoCloud(sources.DataSource): 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)] - elif util.is_NetBSD(): - out, _err = util.subp(['sysctl', '-n', 'hw.disknames'], rcs=[0]) - devlist = [] - for dev in out.split(): - mscdlabel_out, _ = util.subp(['mscdlabel', dev], rcs=[0, 1]) - if ('label "%s"' % label) in mscdlabel_out: - devlist.append('/dev/' + dev) - devlist.append('/dev/' + dev + 'a') # NetBSD 7 - else: - fslist = util.find_devs_with("TYPE=vfat") - fslist.extend(util.find_devs_with("TYPE=iso9660")) + 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())) + 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) + devlist = list(set(fslist) & set(label_list)) + devlist.sort(reverse=True) return devlist def _get_data(self): |