Skip to content

Commit

Permalink
[DM]: Router Loopback interface should be conifgured all the time
Browse files Browse the repository at this point in the history
- Fix for confguration router loopback interface if bgp is configured
- Fixes spell errors in comments

Partial-Bug: #1468954

Change-Id: I4a1adb27390b810911739b82931eab58678d782a
  • Loading branch information
sbalineni committed Feb 22, 2017
1 parent 381a21e commit b0210bc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/config/device-manager/device_manager/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ def push_config(self):
GlobalSystemConfigDM.ip_fabric_subnets,
bgp_router_ips)

self.config_manager.add_lo0_unit_0_interface()

vn_dict = self.get_vn_li_map()
self.evaluate_vn_irb_ip_map(set(vn_dict.keys()), 'l2_l3', 'irb', False)
self.evaluate_vn_irb_ip_map(set(vn_dict.keys()), 'l3', 'lo0', True)
Expand Down
33 changes: 19 additions & 14 deletions src/config/device-manager/device_manager/dm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,10 @@ def vn_ri_comment(vn, is_l2, is_l2_l3, is_nat):
if is_l2_l3:
fwd_mode = "L2-L3"
if not is_nat:
return "/* Virtual Network: %s, UUID: %s, VRF Type: %s, Forwarding Mode: %s */"%(
vn.fq_name[-1], vn.uuid, vrf_type, fwd_mode)
else:
return "/* Virtual Network: %s, UUID: %s, VRF Type: %s (NAT), Forwarding Mode: %s*/"%(
vn.fq_name[-1], vn.uuid, vrf_type, fwd_mode)
return "/* Virtual Network: %s, UUID: %s, VRF Type: %s," \
" Forwarding Mode: %s */"%(vn.fq_name[-1], vn.uuid, vrf_type, fwd_mode)
return "/* Virtual Network: %s, UUID: %s, VRF Type: %s (NAT)," \
" Forwarding Mode: %s */"%(vn.fq_name[-1], vn.uuid, vrf_type, fwd_mode)

@staticmethod
def bgp_group_comment(bgp_obj):
Expand All @@ -205,19 +204,23 @@ def public_vrf_filter_comment():

@staticmethod
def vn_ps_comment(vn, target_type):
return "/* Virtual Network: %s, UUID: %s, Route Targets Type: %s */"%(vn.fq_name[-1], vn.uuid, target_type)
return "/* Virtual Network: %s, UUID: %s, Route Targets Type: %s */"%(
vn.fq_name[-1], vn.uuid, target_type)

@staticmethod
def vn_firewall_comment(vn, mode):
return "/* Virtual Network: %s, UUID: %s, Filter Type: %s */"%(vn.fq_name[-1], vn.uuid, mode)
return "/* Virtual Network: %s, UUID: %s, Filter Type: %s */"%(vn.fq_name[-1],
vn.uuid, mode)

@staticmethod
def vn_bd_comment(vn, encap):
return "/* Virtual Network: %s, UUID: %s, Encapsulation: %s */"%(vn.fq_name[-1], vn.uuid, encap)
return "/* Virtual Network: %s, UUID: %s, Encapsulation: %s */"%(
vn.fq_name[-1], vn.uuid, encap)

@staticmethod
def vn_evpn_comment(vn, encap):
return "/* Virtual Network: %s, UUID: %s, Encapsulation: %s */"%(vn.fq_name[-1], vn.uuid, encap)
return "/* Virtual Network: %s, UUID: %s, Encapsulation: %s */"%(
vn.fq_name[-1], vn.uuid, encap)

@staticmethod
def vn_irb_comment(vn, is_l2, is_l2_l3):
Expand All @@ -226,19 +229,21 @@ def vn_irb_comment(vn, is_l2, is_l2_l3):
vrf_type = "L2"
if is_l2_l3:
vrf_type = "L2-L3"
return "/* Virtual Network: %s, UUID: %s, VRF Type: %s */"%(vn.fq_name[-1], vn.uuid, vrf_type)
return "/* Virtual Network: %s, UUID: %s, VRF Type: %s */"%(vn.fq_name[-1],
vn.uuid, vrf_type)

@staticmethod
def service_set_comment(vn):
return "/* Virtual Network: %s, UUID: %s */"%(vn.fq_name[-1], vn.uuid)

@staticmethod
def service_set_nat_rule_comment(vn, nat_type):
return "/* %s Rules for Virtual Network: %s, UUID: %s*/"%(nat_type, vn.fq_name[-1], vn.uuid)
return "/* %s Rules for Virtual Network: %s, UUID: %s */"%(nat_type,
vn.fq_name[-1], vn.uuid)

@staticmethod
def nat_comment():
return "/* Network Address Transalation Rules for SNAT/Floating IPs */"
return "/* Network Address Translation Rules for SNAT/Floating IPs */"

@staticmethod
def snat_rule_comment():
Expand Down Expand Up @@ -274,7 +279,7 @@ def protocols_comment():

@staticmethod
def routing_instances_comment():
return "/* Routing Instances Confguration */"
return "/* Routing Instances Configuration */"

@staticmethod
def services_comment():
Expand Down Expand Up @@ -325,7 +330,7 @@ def lo0_ri_intf_comment(vn):

@staticmethod
def lo0_unit_0_comment():
return "/* Routing Interface For L2 EVPNs */"
return "/* Router Loopback Interface */"

@staticmethod
def ip_fabric_subnet_comment():
Expand Down
22 changes: 14 additions & 8 deletions src/config/device-manager/device_manager/physical_router_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ def add_pnf_logical_interface(self, junos_interface):
self.interfaces_config.add_interface(interface)
# end add_pnf_logical_interface

def add_lo0_unit_0_interface(self):
if not self.bgp_params or not self.bgp_params.get('address'):
return
if not self.interfaces_config:
self.interfaces_config = Interfaces(comment=DMUtils.interfaces_comment())
lo_intf = Interface(name="lo0")
self.interfaces_config.add_interface(lo_intf)
fam_inet = FamilyInet(address=[Address(name=self.bgp_params['address'] + "/32",
primary='', preferred='')])
intf_unit = Unit(name="0", family=Family(inet=fam_inet),
comment=DMUtils.lo0_unit_0_comment())
lo_intf.add_unit(intf_unit)
# end add_lo0_unit_0_interface

def add_static_routes(self, parent, static_routes):
static_config = parent.get_static()
if not static_config:
Expand Down Expand Up @@ -585,14 +599,6 @@ def add_routing_instance(self, ri_conf):
if len(gateway) and gateway != '0.0.0.0':
addr.set_virtual_gateway_address(gateway)

lo_intf = Interface(name="lo0")
interfaces_config.add_interface(lo_intf)
fam_inet = FamilyInet(address=[Address(name=self.bgp_params['address'] + "/32",
primary='', preferred='')])
intf_unit = Unit(name="0", family=Family(inet=fam_inet),
comment=DMUtils.lo0_unit_0_comment())
lo_intf.add_unit(intf_unit)

self.build_l2_evpn_interface_config(interfaces_config, interfaces, vn)

if (not is_l2 and not is_l2_l3 and gateways):
Expand Down

0 comments on commit b0210bc

Please sign in to comment.