Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ipv6 management in ost #1563

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,10 @@ def setIPsFromInstance(self, vm, node):
for net_name, ips in node.extra['addresses'].items():
for ipo in ips:
ip = ipo['addr']
is_private = any([IPAddress(ip) in IPNetwork(mask) for mask in Config.PRIVATE_NET_MASKS])
if IPAddress(ip).version == 4:
is_private = any([IPAddress(ip) in IPNetwork(mask) for mask in Config.PRIVATE_NET_MASKS])
else:
is_private = IPAddress(ip).is_ipv6_unique_local()

if 'OS-EXT-IPS:type' in ipo and ipo['OS-EXT-IPS:type'] == 'floating':
ip_net_map[ip] = (None, not is_private)
Expand Down
8 changes: 5 additions & 3 deletions test/unit/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,10 @@ def test_30_updateVMInfo(self, request, get_driver):
node.id = "1"
node.state = "running"
node.extra = {'flavorId': 'small', 'volumes_attached': [{'id': 'vol0'}, {'id': 'vol1'}],
'addresses': {'os-lan': [{'addr': '10.0.0.1', 'OS-EXT-IPS:type': 'fixed'}],
'addresses': {'os-lan': [{'addr': '10.0.0.1', 'OS-EXT-IPS:type': 'fixed'},
{'addr': 'fd8c:8d88:f133:71::24d', 'OS-EXT-IPS:type': 'fixed'}],
'public': [{'version': '4', 'addr': '8.8.8.8'},
{'version': '6', 'addr': 'fec0:4801:7808:52:16:3eff:fe6e:b7e2'}]}}
{'version': '6', 'addr': '::ffff:808:808'}]}}
node.public_ips = []
node.private_ips = ['10.0.0.1']
node.driver = driver
Expand Down Expand Up @@ -466,8 +467,9 @@ def test_30_updateVMInfo(self, request, get_driver):

self.assertTrue(success, msg="ERROR: updating VM info.")
self.assertEqual(vm.info.systems[0].getValue("net_interface.0.ip"), "8.8.8.8")
self.assertEqual(vm.info.systems[0].getValue("net_interface.0.ipv6"), "fec0:4801:7808:52:16:3eff:fe6e:b7e2")
self.assertEqual(vm.info.systems[0].getValue("net_interface.0.ipv6"), "::ffff:808:808")
self.assertEqual(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.1")
self.assertEqual(vm.info.systems[0].getValue("net_interface.1.ipv6"), "fd8c:8d88:f133:71::24d")
self.assertEqual(driver.ex_update_subnet.call_args_list[0][0][0].id, "subnet1")
self.assertEqual(driver.ex_update_subnet.call_args_list[0][1],
{'host_routes': [{'nexthop': '10.0.0.1', 'destination': '10.0.0.0/16'}]})
Expand Down