def test_static_routing_ipv6_without_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='nxos') static_routing = StaticRouting() static_routing.af = 'ipv6' static_routing.route = '2001:2:2:2::2/128' static_routing.device_attr[dev1].vrf_attr[ 'default'].address_family_attr[static_routing.af].route_attr[ static_routing. route].next_hop_attr['2001:10:2:3::2'].preference = 3 self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertEqual( str(cfgs[dev1.name]), '\n'.join([ 'ipv6 route 2001:2:2:2::2/128 2001:10:2:3::2 3', ]))
def test_static_routing_ipv6_with_interface_vrf_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='nxos') static_routing = StaticRouting() static_routing.interface = 'Null0' static_routing.vrf = 'VRF1' static_routing.af = 'ipv6' static_routing.route = '2001:1:1:1::1/128' static_routing.device_attr[dev1].vrf_attr[ static_routing. vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface] self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(cfgs[dev1.name]), '\n'.join([ 'vrf context VRF1', ' ipv6 route 2001:1:1:1::1/128 Null0', ' exit', ]))
def test_static_routing_without_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxr') static_routing = StaticRouting() static_routing.interface = 'GigabitEthernet0/1' static_routing.vrf = 'VRF1' static_routing.af = 'ipv4' static_routing.route = '{}'.format('10.2.1.0/24') static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing. route].next_hop_attr['192.168.1.2'].preference = 3 self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(cfgs[dev1.name]), '\n'.join([ 'router static', ' vrf VRF1', ' address-family ipv4 unicast', ' 10.2.1.0/24 192.168.1.2 3', ' exit', ' exit', ' exit', ]))
def test_static_routing_with_interface_next_vrf_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='nxos') static_routing = StaticRouting() static_routing.interface = 'Ethernet1/2' static_routing.vrf = 'default' static_routing.af = 'ipv4' static_routing.route = '1.1.1.1/32' static_routing.device_attr[dev1].vrf_attr[static_routing.vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_nexthop = '10.1.3.1' static_routing.device_attr[dev1].vrf_attr[static_routing.vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_preference = 4 static_routing.device_attr[dev1].vrf_attr[static_routing.vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_tag = 10 static_routing.device_attr[dev1].vrf_attr[static_routing.vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_track = 1 static_routing.device_attr[dev1].vrf_attr[static_routing.vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_nh_vrf = 'VRF1' self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.join( ['ip route 1.1.1.1/32 Ethernet1/2 10.1.3.1 vrf VRF1 track 1 tag 10 4', ]))
def test_static_routing_ipv6_with_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='nxos') static_routing = StaticRouting() static_routing.interface = 'Ethernet1/4' static_routing.vrf = 'default' static_routing.af = 'ipv6' static_routing.route = '2001:2:2:2::2/128' static_routing.device_attr[dev1].vrf_attr[static_routing.vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_nexthop = '2001:10:2:3::2' static_routing.device_attr[dev1].vrf_attr[static_routing.vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_tag = 10 static_routing.device_attr[dev1].vrf_attr[static_routing.vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_track = 1 static_routing.device_attr[dev1].vrf_attr[static_routing.vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_nh_vrf = 'VRF1' self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.join( ['ipv6 route 2001:2:2:2::2/128 Ethernet1/4 2001:10:2:3::2 vrf VRF1 track 1 tag 10', ]))
def test_static_routing_uncfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxe') static_routing_2 = StaticRouting() static_routing_2.device_attr[dev1].vrf_attr[ 'default'].address_family_attr['ipv4'].route_attr[ '10.2.1.0/24'].next_hop_attr['18.0.1.1'] dev1.add_feature(static_routing_2) un_cfgs = static_routing_2.build_unconfig(apply=False) self.assertCountEqual(un_cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertEqual( str(un_cfgs[dev1.name]), '\n'.join(['no ip route 10.2.1.0 255.255.255.0 18.0.1.1']))
def test_static_routing_without_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxe') static_routing = StaticRouting() static_routing.device_attr[dev1].vrf_attr['VRF1'].address_family_attr[ 'ipv4'].route_attr['10.2.1.0/24'].next_hop_attr[ '192.168.1.2'].preference = 3 self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertEqual( str(cfgs[dev1.name]), '\n'.join( ['ip route vrf VRF1 10.2.1.0 255.255.255.0 192.168.1.2 3']))
def test_static_routing_ipv6_without_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxe') static_routing_6 = StaticRouting() static_routing_6.device_attr[dev1].vrf_attr[ 'VRF1'].address_family_attr['ipv6'].route_attr[ '2001:3:3:3::3/128'].next_hop_attr[ '2001:10:1:2::2'].preference = 3 self.assertIs(static_routing_6.testbed, testbed) dev1.add_feature(static_routing_6) cfgs_6 = static_routing_6.build_config(apply=False) self.assertCountEqual(cfgs_6.keys(), [dev1.name]) self.maxDiff = None self.assertEqual( str(cfgs_6[dev1.name]), '\n'.join( ['ipv6 route vrf VRF1 2001:3:3:3::3/128 2001:10:1:2::2 3']))
def test_static_routing_ipv6_without_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxr') static_routing = StaticRouting() static_routing.vrf = 'default' static_routing.af = 'ipv6' static_routing.route = '{}'.format('2001:3:3:3::3/128') static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing. route].next_hop_attr['2001:20:2:3::3'].preference = 3 self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(cfgs[dev1.name]), '\n'.join([ 'router static', ' address-family ipv6 unicast', ' 2001:3:3:3::3/128 2001:20:2:3::3 3', ' exit', ' exit', ]))
def test_static_routing_uncfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxr') static_routing = StaticRouting() static_routing.vrf = 'VRF1' static_routing.af = 'ipv4' static_routing.route = '{}'.format('10.2.1.0/24') static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].next_hop_attr[None] dev1.add_feature(static_routing) un_cfgs = static_routing.build_unconfig(apply=False) self.assertCountEqual(un_cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(un_cfgs[dev1.name]), '\n'.join([ 'router static', ' vrf VRF1', ' address-family ipv4 unicast', ' no 10.2.1.0/24', ' exit', ' exit', ' exit', ]))
def test_static_routing_ipv6_with_interface_tag_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxe') static_routing = StaticRouting() static_routing.device_attr[dev1].vrf_attr[ 'default'].address_family_attr['ipv6'].route_attr[ '2001:2:2:2::2/128'].interface_attr[ 'GigabitEthernet0/0'].if_nexthop = '2001:10:1:2::2' static_routing.device_attr[dev1].vrf_attr[ 'default'].address_family_attr['ipv6'].route_attr[ '2001:2:2:2::2/128'].interface_attr[ 'GigabitEthernet0/0'].if_tag = 100 static_routing.device_attr[dev1].vrf_attr[ 'default'].address_family_attr['ipv6'].route_attr[ '2001:2:2:2::2/128'].interface_attr[ 'GigabitEthernet0/0'].if_track = 1 static_routing.device_attr[dev1].vrf_attr[ 'default'].address_family_attr['ipv6'].route_attr[ '2001:2:2:2::2/128'].interface_attr[ 'GigabitEthernet0/0'].if_preference = 11 self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertEqual( str(cfgs[dev1.name]), '\n'.join([ 'ipv6 route 2001:2:2:2::2/128 GigabitEthernet0/0 2001:10:1:2::2 11 tag 100 track 1' ]))
def test_static_routing_with_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxe') static_routing = StaticRouting() static_routing.device_attr[dev1].vrf_attr['VRF1'].address_family_attr[ 'ipv4'].route_attr['10.2.1.0/24'].interface_attr[ 'GigabitEthernet0/1'].if_nexthop = '192.168.1.2' static_routing.device_attr[dev1].vrf_attr['VRF1'].address_family_attr[ 'ipv4'].route_attr['10.2.1.0/24'].interface_attr[ 'GigabitEthernet0/1'].if_preference = 2 self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertEqual( str(cfgs[dev1.name]), '\n'.join([ 'ip route vrf VRF1 10.2.1.0 255.255.255.0 GigabitEthernet0/1 192.168.1.2 2' ])) static_routing_4 = StaticRouting() static_routing_4.device_attr[dev1].vrf_attr[ 'default'].address_family_attr['ipv4'].route_attr[ '3.3.3.3/32'].interface_attr['GigabitEthernet0/3'] self.assertIs(static_routing_4.testbed, testbed) dev1.add_feature(static_routing_4) cfgs = static_routing_4.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertEqual( str(cfgs[dev1.name]), '\n'.join(['ip route 3.3.3.3 255.255.255.255 GigabitEthernet0/3']))
def test_static_routing_ipv6_with_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxe') static_routing = StaticRouting() interface = 'GigabitEthernet0/1' vrf = 'VRF1' af = 'ipv6' route = '{}'.format('2001:2:2:2::2/128') static_routing.device_attr[dev1].vrf_attr[vrf].address_family_attr[ af].route_attr[route].interface_attr[ interface].if_nexthop = '2001:20:1:2::2' self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertEqual( str(cfgs[dev1.name]), '\n'.join([ 'ipv6 route vrf VRF1 2001:2:2:2::2/128 GigabitEthernet0/1 2001:20:1:2::2' ])) static_routing_2 = StaticRouting() static_routing_2.device_attr[dev1].vrf_attr[ 'default'].address_family_attr['ipv6'].route_attr[ '2001:2:2:2::2/128'].interface_attr['Null0'].if_preference = 5 self.assertIs(static_routing_2.testbed, testbed) dev1.add_feature(static_routing_2) cfgs = static_routing_2.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertEqual(str(cfgs[dev1.name]), '\n'.join(['ipv6 route 2001:2:2:2::2/128 Null0 5']))
def test_static_routing_default_uncfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='nxos') static_routing = StaticRouting() static_routing.af = 'ipv4' static_routing.interface = 'Ethernet0/1' static_routing.route = '10.2.1.0/24' static_routing.device_attr[dev1].vrf_attr['default'].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface].if_nexthop = '192.168.2.2' dev1.add_feature(static_routing) un_cfgs = static_routing.build_unconfig(apply=False) self.assertCountEqual(un_cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertEqual(str(un_cfgs[dev1.name]), '\n'.join( ['no ip route 10.2.1.0/24 Ethernet0/1 192.168.2.2', ]))
def test_static_routing_ipv4_ipv6_with_vrf_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxr') static_routing = StaticRouting() static_routing.interface = 'Null0' static_routing.vrf = 'VRF1' static_routing.af = 'ipv4' static_routing.route = '1.1.1.1/32' static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].interface_attr[ static_routing.interface].if_preference = 99 self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(cfgs[dev1.name]), '\n'.join([ 'router static', ' vrf VRF1', ' address-family ipv4 unicast', ' 1.1.1.1/32 Null0 99', ' exit', ' exit', ' exit', ])) static_routing_6 = StaticRouting() static_routing_6.interface = 'Null0' static_routing_6.vrf = 'VRF1' static_routing_6.af = 'ipv6' static_routing_6.route = '2001:1:1:1::1/128' static_routing_6.device_attr[dev1].vrf_attr[ static_routing_6.vrf].address_family_attr[ static_routing_6.af].route_attr[ static_routing_6.route].interface_attr[ static_routing_6.interface].if_preference = 99 self.assertIs(static_routing_6.testbed, testbed) dev1.add_feature(static_routing_6) cfgs = static_routing_6.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(cfgs[dev1.name]), '\n'.join([ 'router static', ' vrf VRF1', ' address-family ipv6 unicast', ' 2001:1:1:1::1/128 Null0 99', ' exit', ' exit', ' exit', ]))
def test_static_routing_with_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='nxos') static_routing = StaticRouting() static_routing.interface = 'Ethernet0/1' static_routing.vrf = 'VRF1' static_routing.af = 'ipv4' static_routing.route = '10.2.1.0/24' static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].interface_attr[ static_routing.interface].if_nexthop = '192.168.1.2' static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].interface_attr[ static_routing.interface].if_preference = 2 static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].interface_attr[ static_routing.interface].if_nh_vrf = 'VRF1' self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(cfgs[dev1.name]), '\n'.join([ 'vrf context VRF1', ' ip route 10.2.1.0/24 Ethernet0/1 192.168.1.2 vrf VRF1 2', ' exit', ])) static_routing = StaticRouting() static_routing.interface = 'Ethernet0/1' static_routing.vrf = 'default' static_routing.af = 'ipv4' static_routing.route = '10.2.1.0/24' static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].interface_attr[ static_routing.interface].if_nexthop = '192.168.1.2' static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].interface_attr[ static_routing.interface].if_preference = 2 static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].interface_attr[ static_routing.interface].if_nh_vrf = 'VRF1' self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(cfgs[dev1.name]), '\n'.join([ 'ip route 10.2.1.0/24 Ethernet0/1 192.168.1.2 vrf VRF1 2', ]))
def test_static_routing_vrf_default_with_interface_cfg(self): Genie.testbed = testbed = Testbed() dev1 = Device(testbed=testbed, name='PE1', os='iosxr') static_routing = StaticRouting() static_routing.interface = 'GigabitEthernet0/0/0/0' static_routing.vrf = 'default' static_routing.af = 'ipv4' static_routing.route = '1.1.1.1/32' static_routing.device_attr[dev1].vrf_attr[ static_routing. vrf].address_family_attr[static_routing.af].route_attr[ static_routing.route].interface_attr[static_routing.interface] self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(cfgs[dev1.name]), '\n'.join([ 'router static', ' address-family ipv4 unicast', ' 1.1.1.1/32 GigabitEthernet0/0/0/0', ' exit', ' exit', ])) static_routing = StaticRouting() static_routing.interface = 'GigabitEthernet0/0/0/0' static_routing.af = 'ipv4' static_routing.route = '10.2.1.0/24' static_routing.vrf = 'default' static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].interface_attr[ static_routing.interface].if_nexthop = '192.168.1.2' static_routing.device_attr[dev1].vrf_attr[ static_routing.vrf].address_family_attr[ static_routing.af].route_attr[ static_routing.route].interface_attr[ static_routing.interface].if_preference = 2 self.assertIs(static_routing.testbed, testbed) dev1.add_feature(static_routing) cfgs = static_routing.build_config(apply=False) self.assertCountEqual(cfgs.keys(), [dev1.name]) self.maxDiff = None self.assertMultiLineEqual( str(cfgs[dev1.name]), '\n'.join([ 'router static', ' address-family ipv4 unicast', ' 10.2.1.0/24 GigabitEthernet0/0/0/0 192.168.1.2 2', ' exit', ' exit', ]))