Skip to content

Commit

Permalink
Fixed setipalias with IPv6 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
gthiemonge committed Jun 13, 2024
1 parent ac0c17f commit 0b4ddd3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions templates/octaviaamphoracontroller/bin/setipalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
if ipaddr:
# Get our current addresses so we can avoid trying to set the
# same address again.
ifaceinfo = netifaces.ifaddresses(interface_name)[netifaces.AF_INET]
version = ipaddress.ip_address(ipaddr).version
ifaceinfo = netifaces.ifaddresses(interface_name)[
netifaces.AF_INET if version == 4 else netifaces.AF_INET6]
current_addresses = [x['addr'] for x in ifaceinfo]
if ipaddr not in current_addresses:
mask_value = 32
if ipaddress.ip_address(ipaddr).version == 6:
if version == 6:
mask_value = 128
ip.addr('add', index = octavia_interface[0], address=ipaddr, mask=mask_value)
ip.close()

0 comments on commit 0b4ddd3

Please sign in to comment.