Skip to content

Commit d2e31ea

Browse files
committed
net, localnet: Add runcmd to localnet_vm and constants
Add runcmd parameter to localnet_vm so first-boot commands can be injected via cloud-init, enabling ARP isolation settings without post-boot console calls. Add IFACE_A_NAME, IFACE_B_NAME, and CUDN_B_NAME constants for use in the NAD reference change test setup and fixtures. Signed-off-by: Asia Khromov <azhivovk@redhat.com> Assisted-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 0caa4e4 commit d2e31ea

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tests/network/localnet/liblocalnet.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
GUEST_2ND_IFACE_NAME: Final[str] = "eth1"
3535
GUEST_3RD_IFACE_NAME: Final[str] = "eth2"
3636

37+
IFACE_A_NAME: Final[str] = "localnet-vlan-a"
38+
IFACE_B_NAME: Final[str] = "localnet-vlan-b"
39+
CUDN_B_NAME: Final[str] = "cudn-localnet-vlan-b"
40+
3741
LOGGER = logging.getLogger(__name__)
3842

3943

@@ -65,6 +69,7 @@ def localnet_vm(
6569
networks: list[Network],
6670
interfaces: list[Interface],
6771
network_data: cloudinit.NetworkData | None = None,
72+
runcmd: list[str] | None = None,
6873
affinity: Affinity | None = None,
6974
vm_labels: dict[str, str] | None = None,
7075
) -> BaseVirtualMachine:
@@ -85,6 +90,8 @@ def localnet_vm(
8590
Each Interface should have a name matching a Network, and additional configuration and state.
8691
network_data (cloudinit.NetworkData | None): Cloud-init NetworkData object containing the network
8792
configuration for the VM interfaces. If None, no network configuration is applied via cloud-init.
93+
runcmd (list[str] | None): Commands to run on first boot via cloud-init runcmd. None means no
94+
extra commands are injected.
8895
affinity (Affinity | None): Optional Affinity object for VM scheduling. Controls the VM scheduling
8996
location. If None, no affinity constraints are applied.
9097
vm_labels (dict[str, str] | None): Optional labels to apply to the VM template metadata.
@@ -124,7 +131,7 @@ def localnet_vm(
124131

125132
if network_data is not None:
126133
# Prevents cloud-init from overriding the default OS user credentials
127-
userdata = cloudinit.UserData(users=[])
134+
userdata = cloudinit.UserData(users=[], runcmd=runcmd)
128135
disk, volume = cloudinitdisk_storage(
129136
data=CloudInitNoCloud(
130137
networkData=cloudinit.asyaml(no_cloud=network_data),

0 commit comments

Comments
 (0)