summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Dobrawy <ad-m@users.noreply.github.com>2020-06-29 19:52:13 +0200
committerGitHub <noreply@github.com>2020-06-29 13:52:13 -0400
commitbaf11418c196ca72e6d570b64051d8ed35065abb (patch)
tree6712b7ed758620dbfe8d9cb2e567f4cbe0ec92f2
parentb0eba6a4c3a25a13259c01ac4c9a35720fecfdd2 (diff)
downloadvyos-cloud-init-baf11418c196ca72e6d570b64051d8ed35065abb.tar.gz
vyos-cloud-init-baf11418c196ca72e6d570b64051d8ed35065abb.zip
RbxCloud: Add support for FreeBSD (#464)
Changes are made that simplify code and aim to properly support FreeBSD: - use `util.find_devs_with` instead call directly `blkid`, because on FreeBSD is not supported well and `util.find_devs_with` have solution for FreeBSD for that - introduction of an additional name on FAT file system, which is used in FreeBSD - drop shell to use default value, because FreeBSD – by default – does not have `/bin/bash`
-rw-r--r--cloudinit/sources/DataSourceRbxCloud.py14
-rw-r--r--tests/unittests/test_ds_identify.py16
2 files changed, 22 insertions, 8 deletions
diff --git a/cloudinit/sources/DataSourceRbxCloud.py b/cloudinit/sources/DataSourceRbxCloud.py
index 38fb5421..e064c8d6 100644
--- a/cloudinit/sources/DataSourceRbxCloud.py
+++ b/cloudinit/sources/DataSourceRbxCloud.py
@@ -44,7 +44,7 @@ def int2ip(addr):
def _sub_arp(cmd):
"""
- Uses the prefered cloud-init subprocess def of subp.subp
+ Uses the preferred cloud-init subprocess def of subp.subp
and runs arping. Breaking this to a separate function
for later use in mocking and unittests
"""
@@ -72,17 +72,16 @@ def gratuitous_arp(items, distro):
def get_md():
rbx_data = None
- devices = [
- dev
- for dev, bdata in util.blkid().items()
- if bdata.get('LABEL', '').upper() == 'CLOUDMD'
- ]
+ devices = set(
+ util.find_devs_with('LABEL=CLOUDMD') +
+ util.find_devs_with('LABEL=cloudmd')
+ )
for device in devices:
try:
rbx_data = util.mount_cb(
device=device,
callback=read_user_data_callback,
- mtype=['vfat', 'fat']
+ mtype=['vfat', 'fat', 'msdosfs']
)
if rbx_data:
break
@@ -190,7 +189,6 @@ def read_user_data_callback(mount_dir):
'passwd': hash,
'lock_passwd': False,
'ssh_authorized_keys': ssh_keys,
- 'shell': '/bin/bash'
}
},
'network_config': network,
diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
index fbb88e8a..cb57f2d0 100644
--- a/tests/unittests/test_ds_identify.py
+++ b/tests/unittests/test_ds_identify.py
@@ -273,6 +273,10 @@ class TestDsIdentify(DsIdentifyBase):
"""Rbx datasource has a disk with LABEL=CLOUDMD."""
self._test_ds_found('RbxCloud')
+ def test_rbx_cloud_lower(self):
+ """Rbx datasource has a disk with LABEL=cloudmd."""
+ self._test_ds_found('RbxCloudLower')
+
def test_config_drive_upper(self):
"""ConfigDrive datasource has a disk with LABEL=CONFIG-2."""
self._test_ds_found('ConfigDriveUpper')
@@ -948,6 +952,18 @@ VALID_CFG = {
)},
],
},
+ 'RbxCloudLower': {
+ 'ds': 'RbxCloud',
+ 'mocks': [
+ {'name': 'blkid', 'ret': 0,
+ 'out': blkid_out(
+ [{'DEVNAME': 'vda1', 'TYPE': 'vfat', 'PARTUUID': uuid4()},
+ {'DEVNAME': 'vda2', 'TYPE': 'ext4',
+ 'LABEL': 'cloudimg-rootfs', 'PARTUUID': uuid4()},
+ {'DEVNAME': 'vdb', 'TYPE': 'vfat', 'LABEL': 'cloudmd'}]
+ )},
+ ],
+ },
'Hetzner': {
'ds': 'Hetzner',
'files': {P_SYS_VENDOR: 'Hetzner\n'},