Skip to content

Commit

Permalink
Merge "[DM]: DM Support for IPv6 based VN Subnets"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed May 21, 2016
2 parents 9c25a90 + 6010d3b commit e6c7128
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/config/api-server/vnc_addr_mgmt.py
Expand Up @@ -878,7 +878,7 @@ def ip_alloc_req(self, vn_fq_name, vn_dict=None, sub=None, asked_ip_addr=None,
should_persist=False)
self._subnet_objs[vn_fq_name_str][subnet_name] = subnet_obj

if asked_ip_version != subnet_obj.get_version():
if asked_ip_version and asked_ip_version != subnet_obj.get_version():
continue
if asked_ip_addr == str(subnet_obj.gw_ip):
return asked_ip_addr
Expand Down
5 changes: 4 additions & 1 deletion src/config/api-server/vnc_cfg_types.py
Expand Up @@ -1070,7 +1070,10 @@ def drop_ref(obj_uuid):

@classmethod
def ip_alloc(cls, vn_fq_name, subnet_name, count, family=None):
ip_version = 6 if family == 'v6' else 4
if family:
ip_version = 6 if family == 'v6' else 4
else:
ip_version = None
ip_list = [cls.addr_mgmt.ip_alloc_req(vn_fq_name, sub=subnet_name,
asked_ip_version=ip_version,
alloc_id=str(uuid.uuid4()))
Expand Down
6 changes: 3 additions & 3 deletions src/config/device-manager/device_manager/db.py
Expand Up @@ -238,7 +238,7 @@ def free_ip(self, vn_uuid, subnet_prefix, ip_addr):
def get_vn_irb_ip_map(self):
irb_ips = {}
for vn_subnet, ip_addr in self.vn_ip_map.items():
(vn_uuid, subnet_prefix) = vn_subnet.split(':')
(vn_uuid, subnet_prefix) = vn_subnet.split(':', 1)
vn = VirtualNetworkDM.get(vn_uuid)
if vn_uuid not in irb_ips:
irb_ips[vn_uuid] = set()
Expand All @@ -260,7 +260,7 @@ def evaluate_vn_irb_ip_map(self, vn_set):
delete_set = old_set.difference(new_vn_ip_set)
create_set = new_vn_ip_set.difference(old_set)
for vn_subnet in delete_set:
(vn_uuid, subnet_prefix) = vn_subnet.split(':')
(vn_uuid, subnet_prefix) = vn_subnet.split(':', 1)
ret = self.free_ip(
vn_uuid, subnet_prefix, self.vn_ip_map[vn_subnet])
if ret == False:
Expand All @@ -283,7 +283,7 @@ def evaluate_vn_irb_ip_map(self, vn_set):
del self.vn_ip_map[vn_subnet]

for vn_subnet in create_set:
(vn_uuid, subnet_prefix) = vn_subnet.split(':')
(vn_uuid, subnet_prefix) = vn_subnet.split(':', 1)
(sub, length) = subnet_prefix.split('/')
ip_addr = self.reserve_ip(vn_uuid, subnet_prefix)
if ip_addr is None:
Expand Down
41 changes: 34 additions & 7 deletions src/config/device-manager/device_manager/physical_router_config.py
Expand Up @@ -304,10 +304,23 @@ def add_routing_instance(self, ri_name, is_l2, is_l2_l3,
if not is_l2:
if ri_opt is None:
ri_opt = etree.SubElement(ri, "routing-options")
has_ipv6_prefixes = False
has_ipv4_prefixes = False
if prefixes and fip_map is None:
static_config = etree.SubElement(ri_opt, "static")
rib_config_v6 = None
static_config_v6 = None
for prefix in prefixes:
route_config = etree.SubElement(static_config, "route")
if ':' in prefix and not rib_config_v6:
rib_config_v6 = etree.SubElement(ri_opt, "rib")
etree.SubElement(rib_config_v6, "name").text = ri_name + ".inet6.0"
static_config_v6 = etree.SubElement(rib_config_v6, "static")
has_ipv6_prefixes = True
if ':' in prefix:
route_config = etree.SubElement(static_config_v6, "route")
else:
route_config = etree.SubElement(static_config, "route")
has_ipv4_prefixes = True
etree.SubElement(route_config, "name").text = prefix
etree.SubElement(route_config, "discard")
if router_external:
Expand All @@ -324,10 +337,16 @@ def add_routing_instance(self, ri_name, is_l2, is_l2_l3,
ri_opt = etree.SubElement(ri, "routing-options")
if static_routes:
self.add_static_routes(ri_opt, static_routes)
auto_export = """<auto-export>
if has_ipv4_prefixes:
auto_export = """<auto-export>
<family><inet><unicast/></inet></family>
</auto-export>"""
ri_opt.append(etree.fromstring(auto_export))
ri_opt.append(etree.fromstring(auto_export))
if has_ipv6_prefixes:
auto_export = """<auto-export>
<family><inet6><unicast/></inet6></family>
</auto-export>"""
ri_opt.append(etree.fromstring(auto_export))
else:
etree.SubElement(ri, "instance-type").text = "virtual-switch"

Expand Down Expand Up @@ -496,9 +515,17 @@ def add_routing_instance(self, ri_name, is_l2, is_l2_l3,
intf_unit = etree.SubElement(irb_intf, "unit")
etree.SubElement(intf_unit, "name").text = str(network_id)
family = etree.SubElement(intf_unit, "family")
inet = etree.SubElement(family, "inet")
inet = None
inet6 = None
for (irb_ip, gateway) in gateways:
addr = etree.SubElement(inet, "address")
if ':' in irb_ip:
if not inet6:
inet6 = etree.SubElement(family, "inet6")
addr = etree.SubElement(inet6, "address")
else:
if not inet:
inet = etree.SubElement(family, "inet")
addr = etree.SubElement(inet, "address")
etree.SubElement(addr, "name").text = irb_ip
if len(gateway) and gateway != '0.0.0.0':
etree.SubElement(
Expand Down Expand Up @@ -791,7 +818,7 @@ def _get_neighbor_config_xml(self, bgp_config, peers):
def send_bgp_config(self):
bgp_config = self._get_bgp_config_xml()
if bgp_config is None:
return
return 0
proto_config = etree.Element("protocols")
bgp = etree.SubElement(proto_config, "bgp")
bgp.append(bgp_config)
Expand Down Expand Up @@ -857,4 +884,4 @@ def is_untagged(self):
return False
# end is_untagged

# end JunosInterface
# end JunosInterface

0 comments on commit e6c7128

Please sign in to comment.