Skip to content

Commit

Permalink
Revert "fix(vmware): Set IPv6 to dhcp when there is no IPv6 addr (#5471
Browse files Browse the repository at this point in the history
…)" (#5596)

This reverts commit 2b6fe64.

When there is no IPv6 set to dhcp explicitly, NetworkManager keyfile
defaults to method=auto, may-fail=true. When there is Ipv6 set to dhcp
explictily, NetworkManager keyfile will be set to
method=auto, may-fail=false. The default settings are what we want, so
revert the previous change to keep IPv6 not set explicitly.
  • Loading branch information
PengpengSun authored Aug 9, 2024
1 parent edd92b7 commit 65014b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 52 deletions.
2 changes: 1 addition & 1 deletion cloudinit/sources/helpers/vmware/imc/config_nic.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def gen_ipv6(self, name, nic):
"""

if not nic.staticIpv6:
return ([{"type": "dhcp6"}], [])
return ([], [])

subnet_list = []
# Static Ipv6
Expand Down
68 changes: 17 additions & 51 deletions tests/unittests/sources/vmware/test_vmware_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,45 +241,27 @@ def test_get_nics_list_dhcp(self):
elif cfg.get("name") == nic2.get("name"):
nic2.update(cfg)

# Test NIC1
self.assertEqual("physical", nic1.get("type"), "type of NIC1")
self.assertEqual("NIC1", nic1.get("name"), "name of NIC1")
self.assertEqual(
"00:50:56:a6:8c:08", nic1.get("mac_address"), "mac address of NIC1"
)
subnets = nic1.get("subnets")
self.assertEqual(2, len(subnets), "number of subnets for NIC1")
subnet_ipv4 = subnets[0]
self.assertEqual(
"dhcp", subnet_ipv4.get("type"), "Ipv4 DHCP type for NIC1"
)
self.assertEqual(
"auto", subnet_ipv4.get("control"), "NIC1 Control type"
)
subnet_ipv6 = subnets[1]
self.assertEqual(
"dhcp6", subnet_ipv6.get("type"), "Ipv6 DHCP type for NIC1"
)
self.assertEqual(1, len(subnets), "number of subnets for NIC1")
subnet = subnets[0]
self.assertEqual("dhcp", subnet.get("type"), "DHCP type for NIC1")
self.assertEqual("auto", subnet.get("control"), "NIC1 Control type")

# Test NIC2
self.assertEqual("physical", nic2.get("type"), "type of NIC2")
self.assertEqual("NIC2", nic2.get("name"), "name of NIC2")
self.assertEqual(
"00:50:56:a6:5a:de", nic2.get("mac_address"), "mac address of NIC2"
)
subnets = nic2.get("subnets")
self.assertEqual(2, len(subnets), "number of subnets for NIC2")
subnet_ipv4 = subnets[0]
self.assertEqual(
"dhcp", subnet_ipv4.get("type"), "Ipv4 DHCP type for NIC2"
)
self.assertEqual(
"auto", subnet_ipv4.get("control"), "NIC2 Control type"
)
subnet_ipv6 = subnets[1]
self.assertEqual(
"dhcp6", subnet_ipv6.get("type"), "Ipv6 DHCP type for NIC2"
)
self.assertEqual(1, len(subnets), "number of subnets for NIC2")
subnet = subnets[0]
self.assertEqual("dhcp", subnet.get("type"), "DHCP type for NIC2")
self.assertEqual("auto", subnet.get("control"), "NIC2 Control type")

def test_get_nics_list_static(self):
"""Tests if NicConfigurator properly calculates network subnets
Expand All @@ -304,7 +286,6 @@ def test_get_nics_list_static(self):
elif cfg.get("name") == nic2.get("name"):
nic2.update(cfg)

# Test NIC1
self.assertEqual("physical", nic1.get("type"), "type of NIC1")
self.assertEqual("NIC1", nic1.get("name"), "name of NIC1")
self.assertEqual(
Expand Down Expand Up @@ -364,26 +345,23 @@ def test_get_nics_list_static(self):
else:
self.assertEqual(True, False, "invalid gateway %s" % (gateway))

# Test NIC2
self.assertEqual("physical", nic2.get("type"), "type of NIC2")
self.assertEqual("NIC2", nic2.get("name"), "name of NIC2")
self.assertEqual(
"00:50:56:a6:ef:7d", nic2.get("mac_address"), "mac address of NIC2"
)

subnets = nic2.get("subnets")
self.assertEqual(2, len(subnets), "Number of subnets for NIC2")
self.assertEqual(1, len(subnets), "Number of subnets for NIC2")

subnet_ipv4 = subnets[0]
self.assertEqual("static", subnet_ipv4.get("type"), "Subnet type")
subnet = subnets[0]
self.assertEqual("static", subnet.get("type"), "Subnet type")
self.assertEqual(
"192.168.6.102", subnet_ipv4.get("address"), "Subnet address"
"192.168.6.102", subnet.get("address"), "Subnet address"
)
self.assertEqual(
"255.255.0.0", subnet_ipv4.get("netmask"), "Subnet netmask"
"255.255.0.0", subnet.get("netmask"), "Subnet netmask"
)
subnet_ipv6 = subnets[1]
self.assertEqual("dhcp6", subnet_ipv6.get("type"), "Subnet type")

def test_custom_script(self):
cf = ConfigFile("tests/data/vmware/cust-dhcp-2nic.cfg")
Expand Down Expand Up @@ -470,10 +448,7 @@ def test_non_primary_nic_without_gateway(self):
"type": "static",
"address": "10.20.87.154",
"netmask": "255.255.252.0",
},
{
"type": "dhcp6",
},
}
],
}
],
Expand Down Expand Up @@ -524,10 +499,7 @@ def test_non_primary_nic_with_gateway(self):
"metric": 10000,
}
],
},
{
"type": "dhcp6",
},
}
],
}
],
Expand Down Expand Up @@ -587,10 +559,7 @@ def test_cust_non_primary_nic_with_gateway_(self):
"metric": 10000,
}
],
},
{
"type": "dhcp6",
},
}
],
}
],
Expand Down Expand Up @@ -635,10 +604,7 @@ def test_a_primary_nic_with_gateway(self):
"address": "10.20.87.154",
"netmask": "255.255.252.0",
"gateway": "10.20.87.253",
},
{
"type": "dhcp6",
},
}
],
}
],
Expand Down

0 comments on commit 65014b9

Please sign in to comment.