From 495ef272ff6fdfa2a3d94168130a73b64cdf5b51 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Thu, 25 Jun 2020 13:32:30 +0200 Subject: [PATCH 1/2] RbxCloud: Add support for FreeBSD --- cloudinit/sources/DataSourceRbxCloud.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cloudinit/sources/DataSourceRbxCloud.py b/cloudinit/sources/DataSourceRbxCloud.py index 38fb5421af3..c248e7f40b2 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,13 @@ 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 = 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 +186,6 @@ def read_user_data_callback(mount_dir): 'passwd': hash, 'lock_passwd': False, 'ssh_authorized_keys': ssh_keys, - 'shell': '/bin/bash' } }, 'network_config': network, From 4db5060cb40e05b48545b1defb054461be05d186 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Mon, 29 Jun 2020 16:40:49 +0200 Subject: [PATCH 2/2] sources/RbxCloud: Add support for lower case CLOUDMD --- cloudinit/sources/DataSourceRbxCloud.py | 5 ++++- tests/unittests/test_ds_identify.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cloudinit/sources/DataSourceRbxCloud.py b/cloudinit/sources/DataSourceRbxCloud.py index c248e7f40b2..e064c8d6385 100644 --- a/cloudinit/sources/DataSourceRbxCloud.py +++ b/cloudinit/sources/DataSourceRbxCloud.py @@ -72,7 +72,10 @@ def gratuitous_arp(items, distro): def get_md(): rbx_data = None - devices = util.find_devs_with('LABEL=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( diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py index fbb88e8a2d4..cb57f2d04be 100644 --- a/tests/unittests/test_ds_identify.py +++ b/tests/unittests/test_ds_identify.py @@ -273,6 +273,10 @@ def test_rbx_cloud(self): """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 @@ def _print_run_output(rc, out, err, cfg, files): )}, ], }, + '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'},