Commit bd802054 authored by Sigmund Augdal's avatar Sigmund Augdal

Canonicalize cidrs before adding to ipsets. This fixes duplication detection

parent 476c4657
......@@ -2,6 +2,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
from collections import OrderedDict
import subprocess
import ipaddress
import logging
from nova_router import security_groups, setupLogfile, send_stat, etcd_connect
import time
......@@ -105,8 +106,10 @@ class Generator(object):
def add_ipset_net(self, name, net):
if "." in net:
family = "inet"
net = ipaddress.IPv4Network(net).with_prefixlen
else:
family = "inet6"
net = ipaddress.IPv6Network(net).with_prefixlen
setname = self.set_name(name, family)
self.group_members[setname] += 1
self.output("add {} {}".format(setname, net))
......
......@@ -16,6 +16,7 @@ requires = [
]
if sys.version_info[0] == 2:
requires.append('scapy')
requires.append('ipaddress')
setup(name='router-services',
version='0.30',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment