initial changes towards removing ipaddress and using netaddr

This commit is contained in:
Blake Harnden 2020-01-07 14:08:29 -08:00
parent 93ce2a3755
commit f431254e15
10 changed files with 47 additions and 67 deletions

View file

@ -4,7 +4,8 @@ sdn.py defines services to start Open vSwitch and the Ryu SDN Controller.
import re
from core.nodes import ipaddress
import netaddr
from core.services.coreservices import CoreService
@ -58,11 +59,11 @@ class OvsService(SdnService):
# or assign them manually to rtr interfaces if zebra is not running
for ifcaddr in ifc.addrlist:
addr = ifcaddr.split("/")[0]
if ipaddress.is_ipv4_address(addr):
if netaddr.valid_ipv4(addr):
cfg += "ip addr del %s dev %s\n" % (ifcaddr, ifc.name)
if has_zebra == 0:
cfg += "ip addr add %s dev rtr%s\n" % (ifcaddr, ifnum)
elif ipaddress.is_ipv6_address(addr):
elif netaddr.valid_ipv6(addr):
cfg += "ip -6 addr del %s dev %s\n" % (ifcaddr, ifc.name)
if has_zebra == 0:
cfg += "ip -6 addr add %s dev rtr%s\n" % (ifcaddr, ifnum)