Skip to content

Commit dfb6206

Browse files
authored
[6.19.z] Fix IPv6 subnet creation in tests and fixtures (#20959)
1 parent 966b75d commit dfb6206

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
# Subnet Fixtures
2+
from fauxfactory import gen_ipaddr
23
import pytest
34

45

56
@pytest.fixture(scope='module')
67
def module_default_subnet(module_target_sat, module_org, module_location):
7-
return module_target_sat.api.Subnet(
8-
location=[module_location], organization=[module_org]
9-
).create()
8+
subnet_kwargs = {
9+
'location': [module_location],
10+
'organization': [module_org],
11+
}
12+
# Create subnet with appropriate network type based on satellite configuration
13+
if module_target_sat.network_type.has_ipv6:
14+
subnet_kwargs['network_type'] = 'IPv6'
15+
subnet_kwargs['network'] = gen_ipaddr(ip3=True, ipv6=True)
16+
subnet_kwargs['mask'] = 'ffff:ffff:ffff:ffff::'
17+
subnet_kwargs['ipam'] = 'EUI-64'
18+
else:
19+
subnet_kwargs['network_type'] = 'IPv4'
20+
return module_target_sat.api.Subnet(**subnet_kwargs).create()

tests/foreman/api/test_host.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,19 @@ def test_positive_create_and_update_with_subnet(
396396
location=module_location, organization=module_org, subnet=module_default_subnet
397397
).create()
398398
assert host.subnet.read().name == module_default_subnet.name
399-
new_subnet = module_target_sat.api.Subnet(
400-
location=[module_location], organization=[module_org]
401-
).create()
399+
# Create subnet with appropriate network type based on satellite configuration
400+
subnet_kwargs = {
401+
'location': [module_location],
402+
'organization': [module_org],
403+
}
404+
if module_target_sat.network_type.has_ipv6:
405+
subnet_kwargs['network_type'] = 'IPv6'
406+
subnet_kwargs['network'] = gen_ipaddr(ip3=True, ipv6=True)
407+
subnet_kwargs['mask'] = 'ffff:ffff:ffff:ffff::'
408+
subnet_kwargs['ipam'] = 'EUI-64'
409+
else:
410+
subnet_kwargs['network_type'] = 'IPv4'
411+
new_subnet = module_target_sat.api.Subnet(**subnet_kwargs).create()
402412
host.subnet = new_subnet
403413
host = host.update(['subnet'])
404414
assert host.subnet.read().name == new_subnet.name

0 commit comments

Comments
 (0)