Esempio n. 1
0
    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',
            ]))
Esempio n. 2
0
    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',
            ]))