Skip to content

Commit

Permalink
Merge pull request #1563 from grycap/devel
Browse files Browse the repository at this point in the history
Fix ipv6 management in ost
  • Loading branch information
micafer authored May 28, 2024
2 parents dbe796b + 1505e60 commit f362429
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit f362429

Please sign in to comment.