def test_IsisGlobal(self): isis = Isis("core") self.link.add_feature(isis) # Global ISIS config isis.nsr = True # override default for both devices isis.is_type = Isis.IsType.level_1 isis.device_attr['PE1'].is_type = Isis.IsType.level_1_2 isis.device_attr['PE2'].is_type = Isis.IsType.level_2 # use no default isis.device_attr['PE1'].nsf = Isis.Nsf.ietf isis.device_attr['PE2'].nsf = Isis.Nsf.cisco # override default for one device 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) cfg1 = isis.build_config(apply=False) self.assertCountEqual(cfg1.keys(), ['PE1', 'PE2']) self.assertMultiLineEqual( str(cfg1['PE1']), '\n'.join([ 'router isis core', ' is-type level-1-2', ' nsf ietf', ' nsr', ' net 00.0000.0000.0001.00', ' exit', 'interface GigabitEthernet0/0/1', ' ip router isis core', ' exit', ])) self.assertMultiLineEqual( str(cfg1['PE2']), '\n'.join([ 'router isis core', ' is-type level-2-only', ' nsf cisco', ' nsr', ' net 00.0000.0000.0002.00', ' exit', 'interface GigabitEthernet0/0/2', ' ip router isis core', ' exit', ])) uncfg1 = isis.build_unconfig(apply=False) self.assertCountEqual(uncfg1.keys(), ['PE1', 'PE2']) self.assertMultiLineEqual( str(uncfg1['PE1']), '\n'.join([ 'no router isis core', 'interface GigabitEthernet0/0/1', ' no ip router isis core', ' exit', ])) self.assertMultiLineEqual( str(uncfg1['PE2']), '\n'.join([ 'no router isis core', 'interface GigabitEthernet0/0/2', ' no ip router isis core', ' exit', ])) partial_cfg1 = isis.build_config(apply=False, attributes='device_attr__PE1__nsf') self.assertCountEqual(partial_cfg1.keys(), ['PE1']) self.assertMultiLineEqual( str(partial_cfg1['PE1']), '\n'.join([ 'router isis core', ' nsf ietf', ' exit', ]))
def test_IsisGlobal(self): isis = Isis("core") self.link.add_feature(isis) self.assertCountEqual(isis.devices, [self.dev1, self.dev2]) self.assertCountEqual(isis.interfaces, [self.intf1, self.intf2]) self.assertCountEqual(isis.links, [self.link]) # Global ISIS config isis.nsr = True isis.nsf_lifetime = 5 # override default for both devices isis.is_type = Isis.IsType.level_1 isis.device_attr['PE1'].is_type = Isis.IsType.level_1_2 isis.device_attr['PE2'].is_type = Isis.IsType.level_2 # use no default isis.device_attr['PE1'].nsf = Isis.Nsf.ietf isis.device_attr['PE2'].nsf = Isis.Nsf.cisco # override default for one device isis.lsp_mtu = 1400 isis.device_attr['PE1'].lsp_mtu = 1500 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) cfg1 = isis.build_config(apply=False) #print("\nPE1 config\n" + str(cfg1['PE1'])) #print("\nPE2 config\n" + str(cfg1['PE2'])) self.assertCountEqual(cfg1.keys(), ['PE1', 'PE2']) self.assertMultiLineEqual( str(cfg1['PE1']), '\n'.join([ 'router isis core', ' is-type level-1-2', ' lsp-mtu 1500', ' net 00.0000.0000.0001.00', ' nsf ietf', ' nsf lifetime 5', ' nsr', ' address-family ipv4 unicast', ' exit', ' interface GigabitEthernet0/0/0/1', ' address-family ipv4 unicast', ' exit', ' exit', ' exit', ])) self.assertMultiLineEqual( str(cfg1['PE2']), '\n'.join([ 'router isis core', ' is-type level-2-only', ' lsp-mtu 1400', ' net 00.0000.0000.0002.00', ' nsf cisco', ' nsf lifetime 5', ' nsr', ' address-family ipv4 unicast', ' exit', ' interface GigabitEthernet0/0/0/2', ' address-family ipv4 unicast', ' exit', ' exit', ' exit', ]))