Skip to content

Commit

Permalink
integration test and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Feb 26, 2024
1 parent 09c775c commit 3d07322
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cloudinit/sources/DataSourceNoCloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def _merge_new_seed(cur, seeded):


def _parse_dmi() -> str:
serial = dmi.read_dmi_data("system-serial-number")
serial = dmi.read_dmi_data("product_serial")
if serial:
return sources.parse_cmdline_or_dmi(serial)
return ""
Expand Down
35 changes: 35 additions & 0 deletions tests/integration_tests/datasources/test_nocloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,38 @@ def test_nocloud_seedfrom_vendordata(client: IntegrationInstance):
client.restart()
assert client.execute("cloud-init status").ok
assert "seeded_vendordata_test_file" in client.execute("ls /var/tmp")

SMBIOS_USERDATA = """\
#cloud-config
runcmd:
- touch /var/tmp/smbios_test_file
"""
SMBIOS_SEED_DIR = "/smbios_seed"


def setup_nocloud_serial(instance: LXDInstance):
subp(
[
"lxc",
"config",
"set",
instance.name,
"raw.qemu=-smbios "
f"type=1,serial=ds=nocloud;s=file://{SMBIOS_SEED_DIR};h=myhost",
]
)


@pytest.mark.lxd_setup.with_args(setup_nocloud_serial)
@pytest.mark.lxd_use_exec
@pytest.mark.skipif(
PLATFORM != "lxd_vm",
reason="Requires NoCloud with raw QEMU serial setup",
)
def test_smbios_seed(client: IntegrationInstance):
client.execute(f"mkdir {SMBIOS_SEED_DIR}")
client.write_to_file(f"{SMBIOS_SEED_DIR}/user-data", SMBIOS_USERDATA)
client.write_to_file(f"{SMBIOS_SEED_DIR }/smbios_seed/meta-data", "")
client.execute("cloud-init clean --logs")
client.restart()
assert client.execute("test -f /var/tmp/smbios_test_file").ok

0 comments on commit 3d07322

Please sign in to comment.