コード例 #1
0
    def test_cli_config_vni(self):
        vrf_conf = Vrf('VRF1')
        self.dev1.add_feature(vrf_conf)
        vrf_conf.device_attr[self.dev1].vni = 4092
        cfgs = vrf_conf.build_config(apply=False)

        # Check config built correctly
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]), '\n'.join([
                'vrf context VRF1',
                ' vni 4092',
                ' exit',
            ]))

        # Build unconfig for vni attribute
        cfgs = vrf_conf.build_unconfig(
            apply=False,
            attributes={'device_attr': {
                self.dev1: {
                    'vni': None,
                }
            }})
        # Check config correctly unconfigured
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]), '\n'.join([
                'vrf context VRF1',
                ' no vni 4092',
                ' exit',
            ]))
コード例 #2
0
    def test_cli_vxlan_evpn_config(self):
        vrf_conf = Vrf('VRF1')
        self.dev1.add_feature(vrf_conf)

        # Apply configuration
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast']. \
            route_target_attr['200:1'].rt_type = 'both'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast']. \
            route_target_attr['200:1'].protocol_attr['evpn'].rt_evpn = True

        # Build config
        cfgs = vrf_conf.build_config(apply=False)

        # Check config built correctly
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]), '\n'.join([
                'vrf context VRF1',
                ' address-family ipv4 unicast',
                '  route-target import 200:1',
                '  route-target export 200:1',
                '  route-target both 200:1 evpn',
                '  exit',
                ' exit',
            ]))

        # Build unconfig for selected attributes
        uncfgs = vrf_conf.build_unconfig(
            apply=False,
            attributes={
                'device_attr': {
                    self.dev1: {
                        'address_family_attr': {
                            'ipv4 unicast': {
                                'route_target_attr': {
                                    '200:1': {
                                        'rt_type': 'both',
                                        'protocol_attr': {
                                            'evpn': {
                                                'rt_evpn': None,
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            })

        # Check config correctly unconfigured
        self.assertMultiLineEqual(
            str(uncfgs[self.dev1.name]), '\n'.join([
                'vrf context VRF1',
                ' address-family ipv4 unicast',
                '  route-target import 200:1',
                '  route-target export 200:1',
                '  no route-target both 200:1 evpn',
                '  exit',
                ' exit',
            ]))
コード例 #3
0
    def test_cli_config(self):        
        # prefix-list conf
        vrf_conf = Vrf('VRF1')
        self.dev1.add_feature(vrf_conf)

        # Apply configuration
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast'].\
            route_target_attr['200:1'].rt_type  = 'both'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast'].\
            route_target_attr['100:1'].rt_type  = 'import'

        # Build config
        cfgs = vrf_conf.build_config(apply=False)

        # Check config built correctly
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]),
            '\n'.join([
                'vrf VRF1',
                ' address-family ipv4 unicast',
                '  import route-target 100:1',
                '  import route-target 200:1',
                '  export route-target 200:1',
                '  exit',
                ' exit',
            ]))

        # Build unconfig
        cfgs = vrf_conf.build_unconfig(apply=False)

        # Check config correctly unconfigured
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]),
            '\n'.join([
                'no vrf VRF1',
            ]))

        # Build unconfig for selected attributes
        cfgs = vrf_conf.build_unconfig(apply=False,
                                       attributes={'device_attr': {
                                                        self.dev1: {
                                                            'address_family_attr': {
                                                                'ipv4 unicast': {
                                                                    'route_target_attr': None
                                                                }
                                                             }}}})

        # Check config correctly unconfigured
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]),
            '\n'.join([
                'vrf VRF1',
                ' address-family ipv4 unicast',
                '  no import route-target 100:1',
                '  no import route-target 200:1',
                '  no export route-target 200:1',
                '  exit',
                ' exit',
            ]))

        # Build unconfig for selected attributes
        cfgs = vrf_conf.build_unconfig(apply=False,
                                       attributes={'device_attr': {
                                                    self.dev1: {
                                                        'address_family_attr': {
                                                            'ipv4 unicast': {
                                                                'route_target_attr': {
                                                                    '200:1': {
                                                                        'rt_type': None}
                                                    }}}}}})

        # Check config correctly unconfigured
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]),
            '\n'.join([
                'vrf VRF1',
                ' address-family ipv4 unicast',
                '  no import route-target 200:1',
                '  no export route-target 200:1',
                '  exit',
                ' exit',
            ]))
コード例 #4
0
    def test_cli_config_v4(self):
        # prefix-list conf
        vrf_conf = Vrf('VRF1')
        self.dev1.add_feature(vrf_conf)

        # Apply configuration
        vrf_conf.device_attr[self.dev1].rd = '100:1'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast'].\
            import_from_global_map = 'import_from_global_map'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast'].\
            export_to_global_map = 'export_to_global_map'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast'].\
            routing_table_limit_number = 10000
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast'].\
            simple_alert  = True

        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast'].\
            route_target_attr['200:1'].rt_type  = 'both'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv4 unicast'].\
            route_target_attr['100:1'].rt_type  = 'import'

        # Build config
        cfgs = vrf_conf.build_config(apply=False)

        # Check config built correctly
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]), '\n'.join([
                'vrf definition VRF1',
                ' rd 100:1',
                ' address-family ipv4 unicast',
                '  import ipv4 unicast map import_from_global_map',
                '  export ipv4 unicast map export_to_global_map',
                '  maximum routes 10000 warning-only',
                '  route-target import 100:1',
                '  route-target import 200:1',
                '  route-target export 200:1',
                '  exit',
                ' exit',
            ]))

        # Build unconfig
        cfgs = vrf_conf.build_unconfig(apply=False)

        # Check config correctly unconfigured
        self.assertMultiLineEqual(str(cfgs[self.dev1.name]), '\n'.join([
            'no vrf definition VRF1',
        ]))

        # Build unconfig for selected attributes
        cfgs = vrf_conf.build_unconfig(
            apply=False,
            attributes={
                'device_attr': {
                    self.dev1: {
                        'rd': None,
                        'address_family_attr': {
                            'ipv4 unicast': {
                                'export_to_global_map': None
                            }
                        }
                    }
                }
            })

        # Check config correctly unconfigured
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]), '\n'.join([
                'vrf definition VRF1',
                ' no rd 100:1',
                ' address-family ipv4 unicast',
                '  no export ipv4 unicast map export_to_global_map',
                '  exit',
                ' exit',
            ]))

        # Build unconfig for selected attributes
        cfgs = vrf_conf.build_unconfig(apply=False,
                                       attributes={
                                           'device_attr': {
                                               self.dev1: {
                                                   'address_family_attr': {
                                                       'ipv4 unicast': {
                                                           'route_target_attr':
                                                           {
                                                               '200:1': {
                                                                   'rt_type':
                                                                   None
                                                               }
                                                           }
                                                       }
                                                   }
                                               }
                                           }
                                       })

        # Check config correctly unconfigured
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]), '\n'.join([
                'vrf definition VRF1',
                ' address-family ipv4 unicast',
                '  no route-target import 200:1',
                '  no route-target export 200:1',
                '  exit',
                ' exit',
            ]))
コード例 #5
0
    def test_cli_config_v6(self):
        # prefix-list conf
        vrf_conf = Vrf('VRF2')
        self.dev1.add_feature(vrf_conf)

        # Apply configuration
        vrf_conf.device_attr[self.dev1].rd = '100:1'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv6 unicast'].\
            import_from_global_map = 'test_import'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv6 unicast'].\
            export_to_global_map = 'test_export'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv6 unicast'].\
            routing_table_limit_number = 10000
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv6 unicast'].\
            alert_percent_value  = 50

        vrf_conf.device_attr[self.dev1].address_family_attr['ipv6 unicast'].\
            route_target_attr['100:1'].rt_type  = 'export'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv6 unicast'].\
            route_target_attr['200:1'].rt_type  = 'export'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv6 unicast'].\
            route_target_attr['300:1'].rt_type  = 'import'
        vrf_conf.device_attr[self.dev1].address_family_attr['ipv6 unicast'].\
            route_target_attr['400:1'].rt_type  = 'import'

        # Build config
        cfgs = vrf_conf.build_config(apply=False)

        # Check config built correctly
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]), '\n'.join([
                'vrf context VRF2',
                ' rd 100:1',
                ' address-family ipv6 unicast',
                '  import vrf default map test_import',
                '  maximum routes 10000 50',
                '  route-target export 100:1',
                '  route-target export 200:1',
                '  route-target import 300:1',
                '  route-target import 400:1',
                '  exit',
                ' exit',
            ]))

        # Build unconfig
        cfgs = vrf_conf.build_unconfig(apply=False)

        # Check config correctly unconfigured
        self.assertMultiLineEqual(str(cfgs[self.dev1.name]), '\n'.join([
            'no vrf context VRF2',
        ]))

        # Build unconfig for selected attributes
        cfgs = vrf_conf.build_unconfig(
            apply=False,
            attributes={
                'device_attr': {
                    self.dev1: {
                        'rd': None,
                        'address_family_attr': {
                            'ipv6 unicast': {
                                'routing_table_limit_number': None,
                                'alert_percent_value': None,
                            }
                        }
                    }
                }
            })

        # Check config correctly unconfigured
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]), '\n'.join([
                'vrf context VRF2',
                ' no rd 100:1',
                ' address-family ipv6 unicast',
                '  no maximum routes 10000 50',
                '  exit',
                ' exit',
            ]))

        # Build unconfig for selected attributes
        cfgs = vrf_conf.build_unconfig(apply=False,
                                       attributes={
                                           'device_attr': {
                                               self.dev1: {
                                                   'address_family_attr': {
                                                       'ipv6 unicast': {
                                                           'route_target_attr':
                                                           {
                                                               '200:1': {
                                                                   'rt_type':
                                                                   None
                                                               }
                                                           }
                                                       }
                                                   }
                                               }
                                           }
                                       })

        # Check config correctly unconfigured
        self.assertMultiLineEqual(
            str(cfgs[self.dev1.name]), '\n'.join([
                'vrf context VRF2',
                ' address-family ipv6 unicast',
                '  no route-target import 200:1',
                '  no route-target export 200:1',
                '  exit',
                ' exit',
            ]))