def test_IsisPerInterface(self): isis = Isis("core") self.link.add_feature(isis) for intf_iter in self.link.interfaces: intf_iter.add_feature(isis) val = 1 isis.device_attr['PE1'].net_id = "00.0000.0000.000{}.00".format(val) val += 1 isis.device_attr['PE2'].net_id = "00.0000.0000.000{}.00".format(val) # per interface ISIS isis.device_attr['PE1'].interface_attr[self.intf1].passive = True isis.device_attr['PE1'].interface_attr[self.intf1].metric = 20 isis.device_attr['PE2'].interface_attr[ self.intf2].point_to_point = True cfg1 = isis.build_config(apply=False) self.assertMultiLineEqual( str(cfg1['PE1']), '\n'.join([ 'router isis core', ' net 00.0000.0000.0001.00', ' passive-interface GigabitEthernet0/0/1', ' exit', 'interface GigabitEthernet0/0/1', ' ip router isis core', ' isis metric 20', ' exit', ])) self.assertMultiLineEqual( str(cfg1['PE2']), '\n'.join([ 'router isis core', ' net 00.0000.0000.0002.00', ' exit', 'interface GigabitEthernet0/0/2', ' ip router isis core', ' isis network point-to-point', ' exit', ])) isis.address_families = set( [AddressFamily.ipv4_unicast, AddressFamily.ipv6_unicast]) cfg2 = isis.build_config(apply=False) self.assertMultiLineEqual( str(cfg2['PE1']), '\n'.join([ 'router isis core', ' net 00.0000.0000.0001.00', ' passive-interface GigabitEthernet0/0/1', ' exit', 'interface GigabitEthernet0/0/1', ' ip router isis core', ' ipv6 router isis core', ' isis metric 20', ' exit', ])) self.assertMultiLineEqual( str(cfg2['PE2']), '\n'.join([ 'router isis core', ' net 00.0000.0000.0002.00', ' exit', 'interface GigabitEthernet0/0/2', ' ip router isis core', ' ipv6 router isis core', ' isis network point-to-point', ' exit', ])) partial_cfg21 = isis.build_config( apply=False, attributes='device_attr__*__interface_attr__*__metric') self.assertMultiLineEqual( str(partial_cfg21['PE1']), '\n'.join([ 'interface GigabitEthernet0/0/1', ' isis metric 20', ' exit', ])) partial_cfg22 = isis.build_config( apply=False, attributes= 'device_attr__*__interface_attr__*__address_family_attr__ipv6 unicast' ) self.assertMultiLineEqual( str(partial_cfg22['PE1']), '\n'.join([ 'interface GigabitEthernet0/0/1', ' ipv6 router isis core', ' exit', ]))
def test_IsisPerAddrFamily(self): isis = Isis("core") self.link.add_feature(isis) val = 1 isis.device_attr['PE1'].net_id = "00.0000.0000.000{}.00".format(val) val += 1 isis.device_attr['PE2'].net_id = "00.0000.0000.000{}.00".format(val) # per address family ISIS isis.device_attr['PE1'].address_family_attr[ 'ipv4 unicast'].metric_style = "wide" isis.device_attr['PE1'].address_family_attr[ 'ipv4 unicast'].mpls_te_level = Isis.IsType.level_1 isis.device_attr['PE1'].address_family_attr[ 'ipv4 unicast'].mpls_te_rtrid = self.intf1 isis.device_attr['PE2'].address_family_attr[ 'ipv4 unicast'].metric_style = "narrow" isis.device_attr['PE2'].address_family_attr[ 'ipv4 unicast'].mpls_te_level = Isis.IsType.level_2 isis.device_attr['PE2'].address_family_attr[ 'ipv4 unicast'].mpls_te_rtrid = self.intf2 cfg1 = isis.build_config(apply=False) self.assertMultiLineEqual( str(cfg1['PE1']), '\n'.join([ 'router isis core', ' net 00.0000.0000.0001.00', ' metric-style wide', ' mpls traffic-eng level-1', ' mpls traffic-eng router-id GigabitEthernet0/0/1', ' exit', 'interface GigabitEthernet0/0/1', ' ip router isis core', ' exit', ])) self.assertMultiLineEqual( str(cfg1['PE2']), '\n'.join([ 'router isis core', ' net 00.0000.0000.0002.00', ' metric-style narrow', ' mpls traffic-eng level-2', ' mpls traffic-eng router-id GigabitEthernet0/0/2', ' exit', 'interface GigabitEthernet0/0/2', ' ip router isis core', ' exit', ])) isis.address_families = set( [AddressFamily.ipv4_unicast, AddressFamily.ipv6_unicast]) isis.device_attr['PE1'].address_family_attr[ 'ipv6 unicast'].metric_style = "wide" isis.device_attr['PE2'].address_family_attr[ 'ipv6 unicast'].metric_style = "narrow" cfg2 = isis.build_config(apply=False) self.assertMultiLineEqual( str(cfg2['PE1']), '\n'.join([ 'router isis core', ' net 00.0000.0000.0001.00', ' metric-style wide', ' mpls traffic-eng level-1', ' mpls traffic-eng router-id GigabitEthernet0/0/1', ' address-family ipv6 unicast', ' metric-style wide', ' exit', ' exit', 'interface GigabitEthernet0/0/1', ' ip router isis core', ' ipv6 router isis core', ' exit', ])) self.assertMultiLineEqual( str(cfg2['PE2']), '\n'.join([ 'router isis core', ' net 00.0000.0000.0002.00', ' metric-style narrow', ' mpls traffic-eng level-2', ' mpls traffic-eng router-id GigabitEthernet0/0/2', ' address-family ipv6 unicast', ' metric-style narrow', ' exit', ' exit', 'interface GigabitEthernet0/0/2', ' ip router isis core', ' ipv6 router isis core', ' exit', ])) uncfg2 = isis.build_unconfig(apply=False) self.assertMultiLineEqual( str(uncfg2['PE1']), '\n'.join([ 'no router isis core', 'interface GigabitEthernet0/0/1', ' no ip router isis core', ' no ipv6 router isis core', ' exit', ])) self.assertMultiLineEqual( str(uncfg2['PE2']), '\n'.join([ 'no router isis core', 'interface GigabitEthernet0/0/2', ' no ip router isis core', ' no ipv6 router isis core', ' exit', ])) partial_uncfg2 = isis.build_unconfig( apply=False, attributes='device_attr__*__address_family_attr__*') self.assertMultiLineEqual( str(partial_uncfg2['PE1']), '\n'.join([ 'router isis core', ' no metric-style wide', ' no mpls traffic-eng level-1', ' no mpls traffic-eng router-id GigabitEthernet0/0/1', ' no address-family ipv4 unicast', ' no address-family ipv6 unicast', ' exit', ])) self.assertMultiLineEqual( str(partial_uncfg2['PE2']), '\n'.join([ 'router isis core', ' no metric-style narrow', ' no mpls traffic-eng level-2', ' no mpls traffic-eng router-id GigabitEthernet0/0/2', ' no address-family ipv4 unicast', ' no address-family ipv6 unicast', ' exit', ])) partial_cfg21 = isis.build_config( apply=False, attributes= 'device_attr__PE1__address_family_attr__ipv4 unicast__metric_style' ) self.assertMultiLineEqual( str(partial_cfg21['PE1']), '\n'.join([ 'router isis core', ' metric-style wide', ' exit', ])) partial_uncfg21 = isis.build_unconfig( apply=False, attributes= 'device_attr__PE1__address_family_attr__ipv4 unicast__metric_style' ) self.assertMultiLineEqual( str(partial_uncfg21['PE1']), '\n'.join([ 'router isis core', ' no metric-style wide', ' exit', ])) partial_cfg22 = isis.build_config( apply=False, attributes= 'device_attr__PE1__address_family_attr__ipv6 unicast__metric_style' ) self.assertMultiLineEqual( str(partial_cfg22['PE1']), '\n'.join([ 'router isis core', ' address-family ipv6 unicast', ' metric-style wide', ' exit', ' exit', ])) partial_uncfg22 = isis.build_unconfig( apply=False, attributes= 'device_attr__PE1__address_family_attr__ipv6 unicast__metric_style' ) self.assertMultiLineEqual( str(partial_uncfg22['PE1']), '\n'.join([ 'router isis core', ' address-family ipv6 unicast', ' no metric-style wide', ' exit', ' exit', ]))