def test_multiple_pim_static_rp_config(self): # For failures self.maxDiff = None # shorten the line dev1 = self.dev1 # VRF configuration vrf = Vrf('default') # == bsr static rp === # -- bsr static rp intf -- # Pim object pim = Pim() dev1.add_feature(pim) rp1 = RPAddressGroup(device=self.dev1) rp1.static_rp_address = '2.2.2.2' rp2 = RPAddressGroup(device=self.dev1) rp2.static_rp_address = '3.3.3.3' rp2.static_rp_group_list = 'rp_group_list' rp3 = RPAddressGroup(device=self.dev1) rp3.static_rp_address = '4.4.4.4' rp3.static_rp_group_list = 'rp_group_list' rp3.static_rp_override = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr[ 'ipv4'].add_static_rp(rp1) pim.device_attr[dev1].vrf_attr[vrf].address_family_attr[ 'ipv4'].add_static_rp(rp2) pim.device_attr[dev1].vrf_attr[vrf].address_family_attr[ 'ipv4'].add_static_rp(rp3) # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim rp-address 2.2.2.2', 'ip pim rp-address 3.3.3.3 rp_group_list', 'ip pim rp-address 4.4.4.4 rp_group_list override', ]))
def test_pim_sg_expiry_timer_config(self): # For failures self.maxDiff = None # shorten the line dev1 = self.dev1 # VRF configuration vrf = Vrf('default') # == sg_expiry_timer === # Pim object pim = Pim() dev1.add_feature(pim) pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer = 181 # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim sg-expiry-timer 181', ])) # == sg_expiry_timer_infinity === # Pim object pim = Pim() dev1.add_feature(pim) # VRF configuration vrf = Vrf('blue') pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer_infinity = True # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'vrf context blue', ' ip pim sg-expiry-timer infinity', ' exit', ])) # == sg_expiry_timer sg_expiry_timer_sg_list === # Pim object pim = Pim() dev1.add_feature(pim) # VRF configuration vrf = Vrf('VRF1') pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer = 200 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer_sg_list = 'test' # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'vrf context VRF1', ' ip pim sg-expiry-timer 200 sg-list test', ' exit', ])) # == sg_expiry_timer_infinity sg_expiry_timer_prefix_list === # Pim object pim = Pim() dev1.add_feature(pim) # VRF configuration vrf = Vrf('default') pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer_infinity = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer_prefix_list = 'test' # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim sg-expiry-timer infinity prefix-list test', ]))
def test_pim_static_rp_config(self): # For failures self.maxDiff = None # shorten the line dev1 = self.dev1 # VRF configuration vrf = Vrf('default') # == bsr static rp === # -- bsr static rp intf -- # Pim object pim = Pim() dev1.add_feature(pim) rp1 = RPAddressGroup(device=self.dev1) rp1.static_rp_address = '2.2.2.2' rp1.static_rp_group_list = '224.0.0.0/4' rp2 = RPAddressGroup(device=self.dev1) rp2.static_rp_address = '3.3.3.3' rp2.static_rp_group_list = '224.0.0.0/4' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr[ 'ipv4'].add_static_rp(rp1) pim.device_attr[dev1].vrf_attr[vrf].address_family_attr[ 'ipv4'].add_static_rp(rp2) # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim rp-address 2.2.2.2 group-list 224.0.0.0/4', 'ip pim rp-address 3.3.3.3 group-list 224.0.0.0/4', ])) # == bsr static rp intf route-map === # Pim object pim = Pim() dev1.add_feature(pim) rp1 = RPAddressGroup(device=self.dev1) rp1.static_rp_address = '1.1.1.1' rp1.static_rp_route_map = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr[ 'ipv4'].add_static_rp(rp1) # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim rp-address 1.1.1.1 route-map test', ])) # == bsr static rp intf group-list ipv6 === # Pim object pim = Pim() dev1.add_feature(pim) rp1 = RPAddressGroup(device=self.dev1) rp1.static_rp_address = '1:1::1:1' rp1.static_rp_group_list = 'ff00::/8' rp1.static_rp_override = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr[ 'ipv6'].add_static_rp(rp1) # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ipv6 pim rp-address 1:1::1:1 group-list ff00::/8 override', ]))
def test_pim_bsr_config(self): # For failures self.maxDiff = None # shorten the line dev1 = self.dev1 # VRF configuration vrf = Vrf('default') # == bsr rp === # Pim object pim = Pim() dev1.add_feature(pim) pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_interface = 'Ethernet1/1' # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim bsr forward listen', 'ip pim bsr-candidate Ethernet1/1', ])) # Pim object pim = Pim() dev1.add_feature(pim) pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_interface = 'Ethernet1/1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_hash_mask_length = 30 # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim bsr forward listen', 'ip pim bsr-candidate Ethernet1/1 hash-len 30', ])) # Pim object pim = Pim() dev1.add_feature(pim) pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_candidate_interface = 'Ethernet1/1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_candidate_priority = 200 # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ipv6 pim bsr forward listen', 'ipv6 pim bsr-candidate Ethernet1/1 priority 200', ])) # == bsr rp intf route-map === # Pim object pim = Pim() dev1.add_feature(pim) # VRF configuration vrf = Vrf('red') pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_interface = 'Ethernet1/1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_route_map = 'test' # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'vrf context red', ' ipv6 pim bsr forward listen', ' ipv6 pim rp-candidate Ethernet1/1 route-map test', ' exit', ])) # == auto-rp intf prefix-list with interval bidir=== # Pim object pim = Pim() dev1.add_feature(pim) # VRF configuration vrf = Vrf('red') pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_interface = 'Ethernet1/1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_prefix_list = 'LALALLA' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_interval = 60 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_bidir = True # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'vrf context red', ' ip pim bsr forward listen', ' ip pim rp-candidate Ethernet1/1 prefix-list LALALLA interval 60 bidir', ' exit', ]))
def test_pim_auto_rp_config(self): # For failures self.maxDiff = None # shorten the line dev1 = self.dev1 # VRF configuration vrf = Vrf('default') # == auto-rp lack of information === # Pim object pim = Pim() dev1.add_feature(pim) pim.device_attr[dev1].enabled_pim = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_rp_group = '1.1.1.1' # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'feature pim', ])) # == auto-rp intf group-list === # Pim object pim = Pim() dev1.add_feature(pim) # Apply configuration pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_intf = 'Ethernet1/1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_group_list = '239.0.0.0/24' # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim send-rp-announce Ethernet1/1 group-list 239.0.0.0/24', ])) # == auto-rp group route-map with interval === # Pim object pim = Pim() dev1.add_feature(pim) # VRF configuration vrf = Vrf('red') # Apply configuration pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_rp_group = '1.1.1.1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_route_map = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_interval = 30 # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'vrf context red', ' ip pim send-rp-announce 1.1.1.1 route-map test interval 30', ' exit', ])) # == auto-rp intf prefix-list with interval bidir=== # Pim object pim = Pim() dev1.add_feature(pim) # VRF configuration vrf = Vrf('red') # Apply configuration pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ auto_rp = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_intf = 'Ethernet1/1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_prefix_list = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_scope = 10 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_bidir = True # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'vrf context red', ' ip pim auto-rp rp-candidate Ethernet1/1 prefix-list test scope 10 bidir', ' exit', ])) # == auto-rp discovery=== # Pim object pim = Pim() dev1.add_feature(pim) # VRF configuration vrf = Vrf('default') pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_discovery = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_discovery_intf = 'Ethernet1/1' # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim send-rp-discovery Ethernet1/1', ]))
def test_pim_full_config(self): # For failures self.maxDiff = None # shorten the line dev1 = self.dev1 # Pim object pim = Pim() dev1.add_feature(pim) # Apply configuration pim.device_attr[dev1].enabled = True # VRF configuration vrf1 = Vrf('default') pim.device_attr[self.dev1].vrf_attr[vrf1] vrf2 = Vrf('red') pim.device_attr[self.dev1].vrf_attr[vrf2] for vrf, intf in {vrf1: 'Ethernet1/1', vrf2: 'Ethernet2/1'}.items(): # == auto-rp === pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ auto_rp = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_rp_group = '1.1.1.1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_route_map = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_scope = 20 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_interval = 60 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_bidir = True # == auto-rp discovery=== pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ auto_rp_discovery = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_discovery_intf = intf pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_discovery_scope = 20 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ autorp_listener = True # == bsr candidate === pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_interface = intf pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_hash_mask_length = 20 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_priority = 20 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_candidate_interface = intf pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_candidate_hash_mask_length = 20 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_candidate_priority = 20 # == bsr rp-candidate === pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_interface = intf pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_group_list = '239.0.0.0/24' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_route_map = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_prefix_list = 'LLAL' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_priority = 10 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_interval = 60 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_bidir = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_priority = 10 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_interface = intf pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_group_list = 'ff1e:abcd:def1::0/64' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_route_map = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_prefix_list = 'LLAL' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_priority = 10 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_interval = 60 # == static RP === rp1 = RPAddressGroup(device=self.dev1) rp1.static_rp_address = '1.1.1.1' rp1.static_rp_group_list = '239.0.0.0/24' rp1.static_rp_route_map = 'test' rp1.static_rp_prefix_list = 'LLAL' rp1.static_rp_bidir = True rp1.static_rp_override = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr[ 'ipv4'].add_static_rp(rp1) rp2 = RPAddressGroup(device=self.dev1) rp2.static_rp_address = '2001:db8:1:1::1' rp2.static_rp_group_list = 'ff1e:abcd:def1::0/64' rp2.static_rp_route_map = 'test' rp2.static_rp_prefix_list = 'LLAL' rp2.static_rp_override = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr[ 'ipv6'].add_static_rp(rp2) # == static rp register === pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ accept_register = 'regist_name' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ accept_register_prefix_list = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ accept_register = 'regist_name' # not ipv6 supported pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ accept_register_prefix_list = 'test' # log-neighbor-changes pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ log_neighbor_changes = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ log_neighbor_changes = True # register_source pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ register_source = intf # not ipv6 supported pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ register_source = intf # == sg-expiry-timer == pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer = 182 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer_infinity = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer_sg_list = 'sg_name' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer_prefix_list = 'prefix_name' # == spt-threshold == pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ spt_switch_infinity = 'infinity' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ spt_switch_policy = 'abcde' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ spt_switch_infinity = 'infinity' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ spt_switch_policy = 'abcde' # == interface == # ---- mode ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].mode = 'sparse-mode' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].boundary = 'abc' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].boundary_in = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].mode = 'sparse-mode' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].boundary = 'abc' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].boundary_in = True # ---- jp-policy ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].boundary = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].boundary_in = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].boundary_out = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].boundary = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].boundary_in = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].boundary_out = True # ---- border ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].bsr_border = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].bsr_border = True # ---- hello-interval ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].hello_interval = 30000 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].hello_interval = 30000 # ---- dr-priority ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].dr_priority = 777 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].dr_priority = 777 # ---- neighbor-policy ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].neighbor_filter = 'pim_neighbor_policy' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].neighbor_filter_prefix_list = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].neighbor_filter = 'pim_neighbor_policy' # not supported pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].neighbor_filter_prefix_list = 'test' # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'feature pim', 'feature pim6', 'ip pim auto-rp rp-candidate 1.1.1.1 route-map test interval 60 scope 20 bidir', 'ip pim auto-rp mapping-agent Ethernet1/1 scope 20', 'ip pim auto-rp forward listen', 'ip pim bsr forward listen', 'ip pim bsr-candidate Ethernet1/1 hash-len 20 priority 20', 'ip pim bsr forward listen', 'ip pim rp-candidate Ethernet1/1 group-list 239.0.0.0/24 priority 10 interval 60 bidir', 'ip pim register-policy regist_name', 'ip pim register-policy prefix-list test', 'ip pim log-neighbor-changes', 'ip pim register-source Ethernet1/1', 'ip pim sg-expiry-timer 182 prefix-list prefix_name', 'ip pim sg-expiry-timer 182 sg-list sg_name', 'ip pim sg-expiry-timer infinity prefix-list prefix_name', 'ip pim sg-expiry-timer infinity sg-list sg_name', 'ip pim spt-threshold infinity group-list abcde', 'ip pim rp-address 1.1.1.1 group-list 239.0.0.0/24 bidir', 'interface Ethernet1/1', ' ip pim sparse-mode', ' ip pim jp-policy test in', ' ip pim jp-policy test out', ' ip pim border', ' ip pim hello-interval 30000', ' ip pim dr-priority 777', ' ip pim neighbor-policy pim_neighbor_policy', ' ip pim neighbor-policy prefix-list test', ' exit', 'ipv6 pim bsr forward listen', 'ipv6 pim bsr-candidate Ethernet1/1 hash-len 20 priority 20', 'ipv6 pim bsr forward listen', 'ipv6 pim rp-candidate Ethernet1/1 group-list ff1e:abcd:def1::0/64 priority 10 interval 60', 'ipv6 pim register-policy regist_name', 'ipv6 pim log-neighbor-changes', 'ipv6 pim spt-threshold infinity group-list abcde', 'ipv6 pim rp-address 2001:db8:1:1::1 group-list ff1e:abcd:def1::0/64 override', 'interface Ethernet1/1', ' ipv6 pim sparse-mode', ' ipv6 pim jp-policy test in', ' ipv6 pim jp-policy test out', ' ipv6 pim border', ' ipv6 pim hello-interval 30000', ' ipv6 pim dr-priority 777', ' ipv6 pim neighbor-policy pim_neighbor_policy', ' exit', 'vrf context red', ' ip pim auto-rp rp-candidate 1.1.1.1 route-map test interval 60 scope 20 bidir', ' ip pim auto-rp mapping-agent Ethernet2/1 scope 20', ' ip pim auto-rp forward listen', ' ip pim bsr forward listen', ' ip pim bsr-candidate Ethernet2/1 hash-len 20 priority 20', ' ip pim bsr forward listen', ' ip pim rp-candidate Ethernet2/1 group-list 239.0.0.0/24 priority 10 interval 60 bidir', ' ip pim register-policy regist_name', ' ip pim register-policy prefix-list test', ' ip pim log-neighbor-changes', ' ip pim register-source Ethernet2/1', ' ip pim sg-expiry-timer 182 prefix-list prefix_name', ' ip pim sg-expiry-timer 182 sg-list sg_name', ' ip pim sg-expiry-timer infinity prefix-list prefix_name', ' ip pim sg-expiry-timer infinity sg-list sg_name', ' ip pim spt-threshold infinity group-list abcde', ' ip pim rp-address 1.1.1.1 group-list 239.0.0.0/24 bidir', ' exit', 'interface Ethernet2/1', ' ip pim sparse-mode', ' ip pim jp-policy test in', ' ip pim jp-policy test out', ' ip pim border', ' ip pim hello-interval 30000', ' ip pim dr-priority 777', ' ip pim neighbor-policy pim_neighbor_policy', ' ip pim neighbor-policy prefix-list test', ' exit', 'vrf context red', ' ipv6 pim bsr forward listen', ' ipv6 pim bsr-candidate Ethernet2/1 hash-len 20 priority 20', ' ipv6 pim bsr forward listen', ' ipv6 pim rp-candidate Ethernet2/1 group-list ff1e:abcd:def1::0/64 priority 10 interval 60', ' ipv6 pim register-policy regist_name', ' ipv6 pim log-neighbor-changes', ' ipv6 pim spt-threshold infinity group-list abcde', ' ipv6 pim rp-address 2001:db8:1:1::1 group-list ff1e:abcd:def1::0/64 override', ' exit', 'interface Ethernet2/1', ' ipv6 pim sparse-mode', ' ipv6 pim jp-policy test in', ' ipv6 pim jp-policy test out', ' ipv6 pim border', ' ipv6 pim hello-interval 30000', ' ipv6 pim dr-priority 777', ' ipv6 pim neighbor-policy pim_neighbor_policy', ' exit', ])) cfgs = pim.build_unconfig(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'no feature pim', 'no feature pim6', ])) cfgs = pim.build_unconfig( apply=False, attributes={ 'device_attr': { self.dev1: { 'vrf_attr': { 'default': { 'address_family_attr': { 'ipv4': { 'register_source': None } } }, 'red': { 'address_family_attr': { 'ipv6': { 'interface_attr': { 'Ethernet2/1': { 'mode': None } } } } } } } } }) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'no ip pim register-source Ethernet1/1', 'interface Ethernet2/1', ' no ipv6 pim sparse-mode', ' exit', ]))
def test_pim_full_config(self): # For failures self.maxDiff = None # shorten the line dev1 = self.dev1 # Pim object pim = Pim() dev1.add_feature(pim) # VRF configuration vrf1 = Vrf('default') pim.device_attr[self.dev1].vrf_attr[vrf1] vrf2 = Vrf('red') pim.device_attr[self.dev1].vrf_attr[vrf2] for vrf in [vrf1, vrf2]: pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ rp_address = '2.2.2.2' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr['Loopback0'] pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr['HundredGigE0/0/0/1'] # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'router pim', ' address-family ipv4', ' interface HundredGigE0/0/0/1', ' exit', ' interface Loopback0', ' exit', ' rp-address 2.2.2.2', ' exit', ' vrf red', ' address-family ipv4', ' interface HundredGigE0/0/0/1', ' exit', ' interface Loopback0', ' exit', ' rp-address 2.2.2.2', ' exit', ' exit', ' exit', ])) cfgs = pim.build_unconfig(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'no router pim', ])) cfgs = pim.build_unconfig(apply=False, attributes={ 'device_attr': { self.dev1: { 'vrf_attr': { 'default': { 'address_family_attr': { 'ipv4': { 'rp_address': None } } }, 'red': { 'address_family_attr': { 'ipv4': { 'interface_attr': { 'Loopback0': None } } } } } } } }) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'router pim', ' address-family ipv4', ' no rp-address 2.2.2.2', ' exit', ' vrf red', ' address-family ipv4', ' no interface Loopback0', ' exit', ' exit', ' exit', ]))
def test_pim_full_config(self): # For failures self.maxDiff = None # shorten the line dev1 = self.dev1 # Pim object pim = Pim() dev1.add_feature(pim) # Apply configuration # VRF configuration vrf1 = Vrf('default') pim.device_attr[self.dev1].vrf_attr[vrf1] vrf2 = Vrf('red') pim.device_attr[self.dev1].vrf_attr[vrf2] pim.device_attr[dev1].enabled_bidir = True for vrf, intf in {vrf1: 'GigabitEthernet0/0/1', vrf2: 'GigabitEthernet0/0/2'}.items(): # == auto-rp === pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_rp_group = '1.1.1.1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_scope = 20 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_group_list = 'test_list' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_interval = 60 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_announce_bidir = True # == auto-rp discovery=== pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_discovery_intf = intf pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_discovery_scope = 20 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ send_rp_discovery_interval = 1000 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ autorp_listener = True # == bsr candidate === pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_interface = intf pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_hash_mask_length = 20 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_priority = 50 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_accept_rp_acl = 190 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_candidate_address = '2001:DB8:1:1::1' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_candidate_hash_mask_length = 126 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_candidate_priority = 20 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_candidate_accept_rp_acl = 190 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ scope = True # == bsr rp-candidate === pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_interface = 'Loopback0' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_group_list = '11' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_priority = 10 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_interval = 60 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ bsr_rp_candidate_bidir = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_address = '2001:DB8:2:2::2' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_group_list = 'ff1e:abcd:def1::0/64' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_priority = 10 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ bsr_rp_candidate_interval = 60 # == static RP === rp1 = RPAddressGroup(device=self.dev1) rp1.static_rp_address = '1.1.1.1' rp1.static_rp_group_list = '10' rp1.static_rp_override = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].add_static_rp(rp1) rp2 = RPAddressGroup(device=self.dev1) rp2.static_rp_address = '2001:db8:1:1::1' rp2.static_rp_group_list = 'ff1e:abcd:def1::0/64' rp2.static_rp_bidir = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].add_static_rp(rp2) # == static rp register === pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ accept_register = 'regist_name' # ipv6 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ accept_register = 'regist_map_v6' # log-neighbor-changes pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ log_neighbor_changes = True # ipv6 is not supported # register_source pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ register_source = intf # not ipv6 supported pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ register_source = 'Loopback0' # == sg-expiry-timer == pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer = 182 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ sg_expiry_timer_sg_list = 'sg_name' # == spt-threshold == pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ spt_switch_infinity = 0 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ spt_switch_policy = 'abcde' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ spt_switch_infinity = 'infinity' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ spt_switch_policy = 'abcdef' # == interface == intf = 'Loopback0' # ---- mode ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].mode = 'dense-mode' # ---- jp-policy ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].boundary = 'test' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].boundary_filter_autorp = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].boundary = 'test' # ---- border ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].bsr_border = True pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].bsr_border = True # ---- hello-interval ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].hello_interval_msec = 30000 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].hello_interval = 3000 # ---- dr-priority ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].dr_priority = 777 pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].dr_priority = 777 # ---- neighbor-policy ---------- pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ interface_attr[intf].neighbor_filter = 'pim_neighbor_policy' pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv6'].\ interface_attr[intf].neighbor_filter = 'pim_neighbor_policy' # Build config cfgs = pim.build_config(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'ip pim bidir-enable', 'ip pim send-rp-announce 1.1.1.1 scope 20 group-list test_list interval 60 bidir', 'ip pim send-rp-discovery GigabitEthernet0/0/1 scope 20 interval 1000', 'ip pim autorp listener', 'ip pim bsr-candidate GigabitEthernet0/0/1 20 50 accept-rp-candidate 190', 'ip pim rp-candidate Loopback0 group-list 11 interval 60 priority 10 bidir', 'ip pim accept-register list regist_name', 'ip pim log-neighbor-changes', 'ip pim register-source GigabitEthernet0/0/1', 'ip pim sparse sg-expiry-timer 182 sg-list sg_name', 'ip pim spt-threshold 0 group-list abcde', 'ip pim rp-address 1.1.1.1 10 override', 'interface Loopback0', ' ip pim dense-mode', ' ip multicast boundary test filter-autorp', ' ip pim bsr-border', ' ip pim dr-priority 777', ' ip pim query-interval 30000 msec', ' ip pim neighbor-filter pim_neighbor_policy', ' exit', 'ipv6 pim bsr candidate rp 2001:DB8:2:2::2 group-list ff1e:abcd:def1::0/64 interval 60 priority 10', 'ipv6 pim accept-register list regist_map_v6', 'ipv6 pim register-source Loopback0', 'ipv6 pim spt-threshold infinity group-list abcdef', 'ipv6 pim rp-address 2001:db8:1:1::1 ff1e:abcd:def1::0/64 bidir', 'interface Loopback0', ' ipv6 multicast boundary block source', ' ipv6 pim bsr border', ' ipv6 pim dr-priority 777', ' ipv6 pim hello-interval 3000', ' exit', 'ipv6 pim neighbor-filter list pim_neighbor_policy', 'ip pim vrf red send-rp-announce 1.1.1.1 scope 20 group-list test_list interval 60 bidir', 'ip pim vrf red send-rp-discovery GigabitEthernet0/0/2 scope 20 interval 1000', 'ip pim autorp listener', 'ip pim vrf red bsr-candidate GigabitEthernet0/0/2 20 50 accept-rp-candidate 190', 'ip pim vrf red rp-candidate Loopback0 group-list 11 interval 60 priority 10 bidir', 'ip pim accept-register list regist_name', 'ip pim log-neighbor-changes', 'ip pim vrf red register-source GigabitEthernet0/0/2', 'ip pim vrf red sparse sg-expiry-timer 182 sg-list sg_name', 'ip pim vrf red spt-threshold 0 group-list abcde', 'ip pim vrf red rp-address 1.1.1.1 10 override', 'interface Loopback0', ' ip pim dense-mode', ' ip multicast boundary test filter-autorp', ' ip pim bsr-border', ' ip pim dr-priority 777', ' ip pim query-interval 30000 msec', ' ip pim neighbor-filter pim_neighbor_policy', ' exit', 'ipv6 pim vrf red bsr candidate rp 2001:DB8:2:2::2 group-list ff1e:abcd:def1::0/64 interval 60 priority 10', 'ipv6 pim vrf red accept-register list regist_map_v6', 'ipv6 pim vrf red register-source Loopback0', 'ipv6 pim vrf red spt-threshold infinity group-list abcdef', 'ipv6 pim vrf red rp-address 2001:db8:1:1::1 ff1e:abcd:def1::0/64 bidir', 'interface Loopback0', ' ipv6 multicast boundary block source', ' ipv6 pim bsr border', ' ipv6 pim dr-priority 777', ' ipv6 pim hello-interval 3000', ' exit', 'ipv6 pim vrf red neighbor-filter list pim_neighbor_policy', ])) cfgs = pim.build_unconfig(apply=False) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'no ip pim bidir-enable', 'no ip pim send-rp-discovery GigabitEthernet0/0/1 scope 20 interval 1000', 'no ip pim autorp listener', 'no ip pim bsr-candidate GigabitEthernet0/0/1 20 50 accept-rp-candidate 190', 'no ip pim accept-register list regist_name', 'no ip pim log-neighbor-changes', 'no ip pim register-source GigabitEthernet0/0/1', 'no ip pim sparse sg-expiry-timer 182 sg-list sg_name', 'no ip pim spt-threshold 0 group-list abcde', 'no ip pim rp-address 1.1.1.1 10 override', 'interface Loopback0', ' no ip pim dense-mode', ' no ip multicast boundary test filter-autorp', ' no ip pim bsr-border', ' no ip pim dr-priority 777', ' no ip pim query-interval 30000 msec', ' no ip pim neighbor-filter pim_neighbor_policy', ' exit', 'no ipv6 pim bsr candidate rp 2001:DB8:2:2::2 group-list ff1e:abcd:def1::0/64 interval 60 priority 10', 'no ipv6 pim accept-register list regist_map_v6', 'no ipv6 pim register-source Loopback0', 'no ipv6 pim spt-threshold infinity group-list abcdef', 'no ipv6 pim rp-address 2001:db8:1:1::1 ff1e:abcd:def1::0/64 bidir', 'interface Loopback0', ' no ipv6 multicast boundary block source', ' no ipv6 pim bsr border', ' no ipv6 pim dr-priority 777', ' no ipv6 pim hello-interval 3000', ' exit', 'no ipv6 pim neighbor-filter list pim_neighbor_policy', 'no ip pim vrf red send-rp-discovery GigabitEthernet0/0/2 scope 20 interval 1000', 'no ip pim autorp listener', 'no ip pim vrf red bsr-candidate GigabitEthernet0/0/2 20 50 accept-rp-candidate 190', 'no ip pim accept-register list regist_name', 'no ip pim log-neighbor-changes', 'no ip pim vrf red register-source GigabitEthernet0/0/2', 'no ip pim vrf red sparse sg-expiry-timer 182 sg-list sg_name', 'no ip pim vrf red spt-threshold 0 group-list abcde', 'no ip pim vrf red rp-address 1.1.1.1 10 override', 'interface Loopback0', ' no ip pim dense-mode', ' no ip multicast boundary test filter-autorp', ' no ip pim bsr-border', ' no ip pim dr-priority 777', ' no ip pim query-interval 30000 msec', ' no ip pim neighbor-filter pim_neighbor_policy', ' exit', 'no ipv6 pim vrf red bsr candidate rp 2001:DB8:2:2::2 group-list ff1e:abcd:def1::0/64 interval 60 priority 10', 'no ipv6 pim vrf red accept-register list regist_map_v6', 'no ipv6 pim vrf red register-source Loopback0', 'no ipv6 pim vrf red spt-threshold infinity group-list abcdef', 'no ipv6 pim vrf red rp-address 2001:db8:1:1::1 ff1e:abcd:def1::0/64 bidir', 'interface Loopback0', ' no ipv6 multicast boundary block source', ' no ipv6 pim bsr border', ' no ipv6 pim dr-priority 777', ' no ipv6 pim hello-interval 3000', ' exit', 'no ipv6 pim vrf red neighbor-filter list pim_neighbor_policy', ])) # uncfg with attributes # pim.device_attr[dev1].vrf_attr[vrf].address_family_attr['ipv4'].\ # interface_attr[intf].mode = 'dense-mode' cfgs = pim.build_unconfig(apply=False, attributes={'device_attr': { self.dev1: { 'vrf_attr': { 'default': { 'address_family_attr': { 'ipv6': { 'register_source': None } } }, 'red': { 'address_family_attr': { 'ipv4': { 'interface_attr': { intf: { 'mode': None } } } } } } }}}) # Check config built correctly self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.\ join([ 'no ipv6 pim register-source Loopback0', 'interface Loopback0', ' no ip pim dense-mode', ' exit', ]))