Beispiel #1
0
    def test_set_timers_advertise(self):
        # vrrp 10 timers advertise 3

        # Test set_timers_advertise gives properly formatted commands
        cases = [
            (50, None, None, 'vrrp %d timers advertise 50' % upd_vrid),
            (None, None, True, 'default vrrp %d timers advertise' % upd_vrid),
            (None, True, True, 'default vrrp %d timers advertise' % upd_vrid),
            (None, True, None, 'no vrrp %d timers advertise' % upd_vrid),
        ]

        for (timers_advertise, disable, default, cmd) in cases:
            func = function('set_timers_advertise', upd_intf, upd_vrid,
                            value=timers_advertise, disable=disable,
                            default=default)
            exp_cmds = [upd_cmd] + [cmd]
            self.eapi_positive_config_test(func, exp_cmds)

        # Test raising ValueError by entering invalid parameters
        cases = [256, 0, 'a']

        for timers_advertise in cases:
            func = function('set_timers_advertise', upd_intf, upd_vrid,
                            value=timers_advertise)
            self.eapi_exception_config_test(func, ValueError)
Beispiel #2
0
    def test_set_bfd_ip(self):
        # no vrrp 10 bfd ip

        bfd_addr = '10.10.4.101'

        # Test bfd_ip gives properly formatted commands
        cases = [
            (bfd_addr, None, None, 'vrrp %d bfd ip %s' % (upd_vrid, bfd_addr)),
            (None, True, None, 'no vrrp %d bfd ip' % upd_vrid),
            (None, None, True, 'default vrrp %d bfd ip' % upd_vrid),
            (None, True, True, 'default vrrp %d bfd ip' % upd_vrid),
        ]

        for (bfd_ip, disable, default, cmd) in cases:
            func = function('set_bfd_ip', upd_intf, upd_vrid,
                            value=bfd_ip, disable=disable, default=default)
            exp_cmds = [upd_cmd] + [cmd]
            self.eapi_positive_config_test(func, exp_cmds)

        # Test raising ValueError from invalid parameters
        cases = ['abc', 500, '101.101']

        for bfd_ip in cases:
            func = function('set_bfd_ip', upd_intf, upd_vrid,
                            value=bfd_ip)
            self.eapi_exception_config_test(func, ValueError)
Beispiel #3
0
    def test_set_mac_addr_adv_interval(self):
        # vrrp 10 mac-address advertisement-interval 30

        # Test set_timers_advertise gives properly formatted commands
        maadvint = 'mac-address advertisement-interval'
        cases = [
            (50, None, None, 'vrrp %d %s 50' % (upd_vrid, maadvint)),
            (None, None, True, 'default vrrp %d %s' % (upd_vrid, maadvint)),
            (None, True, True, 'default vrrp %d %s' % (upd_vrid, maadvint)),
            (None, True, None, 'no vrrp %d %s' % (upd_vrid, maadvint)),
        ]

        for (mac_addr_adv_interval, disable, default, cmd) in cases:
            func = function('set_mac_addr_adv_interval', upd_intf, upd_vrid,
                            value=mac_addr_adv_interval, disable=disable,
                            default=default)
            exp_cmds = [upd_cmd] + [cmd]
            self.eapi_positive_config_test(func, exp_cmds)

        # Test raising ValueError by entering invalid parameters
        cases = ['a', 10000]

        for mac_addr_adv_interval in cases:
            func = function('set_mac_addr_adv_interval', upd_intf, upd_vrid,
                            value=mac_addr_adv_interval)
            self.eapi_exception_config_test(func, ValueError)
Beispiel #4
0
 def test_set_interface(self):
     for state in ['config', 'negate', 'default']:
         vrf_name = 'testintvrf'
         interface = 'Ethernet1'
         if state == 'config':
             cmds = [
                 'interface %s' % interface,
                 'vrf forwarding %s' % vrf_name
             ]
             func = function('set_interface', vrf_name, interface)
             self.eapi_positive_config_test(func, cmds)
         elif state == 'negate':
             cmds = ['interface %s' % interface, 'no vrf forwarding']
             func = function('set_interface',
                             vrf_name,
                             interface,
                             disable=True)
             self.eapi_positive_config_test(func, cmds)
         elif state == 'default':
             cmds = ['interface %s' % interface, 'default vrf forwarding']
             func = function('set_interface',
                             vrf_name,
                             interface,
                             default=True)
             self.eapi_positive_config_test(func, cmds)
Beispiel #5
0
    def test_set_peer_group(self):
        for state in ['config', 'negate', 'default']:
            peer_group = 'test'
            name = '172.16.10.1'
            cmd = 'neighbor {} peer-group'.format(name)
            if state == 'config':
                cmds = ['router bgp 65000', '{} {}'.format(cmd, peer_group)]
                func = function('set_peer_group', name, peer_group)
            elif state == 'negate':
                cmds = ['router bgp 65000', 'no {}'.format(cmd)]
                func = function('set_peer_group', name, disable=True)
            elif state == 'default':
                cmds = ['router bgp 65000', 'default {}'.format(cmd)]
                func = function('set_peer_group',
                                name,
                                peer_group,
                                default=True)
            self.eapi_positive_config_test(func, cmds)

        # func = function('set_peer_group', name, value=None, default=False,
        #                 disable=False)
        # self.eapi_exception_config_test(func, ValueError)
        # If command_builder fails because value is None, uncomment
        # above lines and remove below lines.
        cmds = ['router bgp 65000', 'no neighbor 172.16.10.1 peer-group']
        func = function('set_peer_group', '172.16.10.1', None)
        self.eapi_positive_config_test(func, cmds)
Beispiel #6
0
    def test_set_preempt(self):
        # vrrp 10 preempt

        # Test set_description gives properly formatted commands
        cases = [
            (False, None, None, 'no vrrp %d preempt' % upd_vrid),
            (True, None, None, 'vrrp %d preempt' % upd_vrid),
            (None, None, True, 'default vrrp %d preempt' % upd_vrid),
            (None, True, True, 'default vrrp %d preempt' % upd_vrid),
            (None, True, None, 'no vrrp %d preempt' % upd_vrid),
        ]

        for (preempt, disable, default, cmd) in cases:
            func = function('set_preempt', upd_intf, upd_vrid,
                            value=preempt, disable=disable, default=default)
            exp_cmds = [upd_cmd] + [cmd]
            self.eapi_positive_config_test(func, exp_cmds)

        # Test raising ValueError by entering invalid parameters
        cases = ['a', 5]

        for preempt in cases:
            func = function('set_preempt', upd_intf, upd_vrid,
                            value=preempt)
            self.eapi_exception_config_test(func, ValueError)
Beispiel #7
0
    def test_set_peer_group(self):
        for state in ['config', 'negate', 'default']:
            peer_group = 'test'
            name = '172.16.10.1'
            cmd = 'neighbor {} peer-group'.format(name)
            if state == 'config':
                cmds = ['router bgp 65000', '{} {}'.format(cmd, peer_group)]
                func = function('set_peer_group', name, peer_group)
            elif state == 'negate':
                cmds = ['router bgp 65000', 'no {}'.format(cmd)]
                func = function('set_peer_group', name, disable=True)
            elif state == 'default':
                cmds = ['router bgp 65000', 'default {}'.format(cmd)]
                func = function('set_peer_group', name, peer_group,
                                default=True)
            self.eapi_positive_config_test(func, cmds)

        # func = function('set_peer_group', name, value=None, default=False,
        #                 disable=False)
        # self.eapi_exception_config_test(func, ValueError)
        # If command_builder fails because value is None, uncomment
        # above lines and remove below lines.
        cmds = ['router bgp 65000', 'no neighbor 172.16.10.1 peer-group']
        func = function('set_peer_group', '172.16.10.1', None)
        self.eapi_positive_config_test(func, cmds)
Beispiel #8
0
    def test_set_route_map_out(self):
        for state in ['config', 'negate', 'default']:
            route_map = 'TEST_RM'
            name = 'test'
            cmd = 'neighbor {} route-map'.format(name)
            if state == 'config':
                cmds = ['router bgp 65000', '{} {} out'.format(cmd, route_map)]
                func = function('set_route_map_out', name, value=route_map)
            elif state == 'negate':
                cmds = ['router bgp 65000', 'no {} out'.format(cmd)]
                func = function('set_route_map_out', name, disable=True)
            elif state == 'default':
                cmds = ['router bgp 65000', 'default {} out'.format(cmd)]
                func = function('set_route_map_out', name, value=route_map,
                                default=True)
            self.eapi_positive_config_test(func, cmds)

        # func = function('set_route_map_out', name, value=None, default=False,
        #                 disable=False)
        # self.eapi_exception_config_test(func, ValueError)
        # If command_builder fails because value is None, uncomment
        # above lines and remove below lines.
        cmds = ['router bgp 65000', 'no neighbor test route-map out']
        func = function('set_route_map_out', 'test', None)
        self.eapi_positive_config_test(func, cmds)
Beispiel #9
0
    def test_set_primary_ip(self):
        # vrrp 10 ip 10.10.4.10

        # Test set_primary_ip gives properly formatted commands
        ip1 = '10.10.4.110'
        ipcurr = '10.10.4.10'
        cases = [
            (ip1, None, None, 'vrrp %d ip %s' % (upd_vrid, ip1)),
            (ip1, True, None, 'no vrrp %d ip %s' % (upd_vrid, ipcurr)),
            (ip1, None, True, 'default vrrp %d ip %s' % (upd_vrid, ipcurr)),
            (ip1, True, True, 'default vrrp %d ip %s' % (upd_vrid, ipcurr)),
        ]

        for (primary_ip, disable, default, cmd) in cases:
            func = function('set_primary_ip', upd_intf, upd_vrid,
                            value=primary_ip, disable=disable, default=default)
            exp_cmds = [upd_cmd] + [cmd]
            self.eapi_positive_config_test(func, exp_cmds)

        # Test raising ValueError from invalid parameters
        cases = ['abc', 500, '101.101']

        for primary_ip in cases:
            func = function('set_primary_ip', upd_intf, upd_vrid,
                            value=primary_ip)
            self.eapi_exception_config_test(func, ValueError)
Beispiel #10
0
    def test_set_preempt_delay_min(self):
        # vrrp 10 preempt delay minimum 0

        # Test set_preempt_delay_min gives properly formatted commands
        cases = [
            (2500, None, None,
             'vrrp %d preempt delay minimum 2500' % upd_vrid),
            (None, None, True,
             'default vrrp %d preempt delay minimum' % upd_vrid),
            (None, True, True,
             'default vrrp %d preempt delay minimum' % upd_vrid),
            (None, True, None, 'no vrrp %d preempt delay minimum' % upd_vrid),
        ]

        for (preempt_delay_min, disable, default, cmd) in cases:
            func = function('set_preempt_delay_min', upd_intf, upd_vrid,
                            value=preempt_delay_min, disable=disable,
                            default=default)
            exp_cmds = [upd_cmd] + [cmd]
            self.eapi_positive_config_test(func, exp_cmds)

        # Test raising ValueError by entering invalid parameters
        cases = ['a', 3601]

        for preempt_delay_min in cases:
            func = function('set_preempt_delay_min', upd_intf, upd_vrid,
                            value=preempt_delay_min)
            self.eapi_exception_config_test(func, ValueError)
Beispiel #11
0
    def test_set_description(self):
        for state in ['config', 'negate', 'default']:
            value = 'this is a test'
            name = 'test'
            cmd = 'neighbor {} description'.format(name)
            if state == 'config':
                cmds = ['router bgp 65000', '{} {}'.format(cmd, value)]
                func = function('set_description', name, value=value)
            elif state == 'negate':
                cmds = ['router bgp 65000', 'no {}'.format(cmd)]
                func = function('set_description', name, disable=True)
            elif state == 'default':
                cmds = ['router bgp 65000', 'default {}'.format(cmd)]
                func = function('set_description', name, value=value,
                                default=True)
            self.eapi_positive_config_test(func, cmds)

        # func = function('set_description', name, value=None, default=False,
        #                 disable=False)
        # self.eapi_exception_config_test(func, ValueError)
        # If command_builder fails because value is None, uncomment
        # above lines and remove below lines.
        cmds = ['router bgp 65000', 'no neighbor test description']
        func = function('set_description', 'test', None)
        self.eapi_positive_config_test(func, cmds)
Beispiel #12
0
    def test_set_description(self):
        for state in ['config', 'negate', 'default']:
            value = 'this is a test'
            name = 'test'
            cmd = 'neighbor {} description'.format(name)
            if state == 'config':
                cmds = ['router bgp 65000', '{} {}'.format(cmd, value)]
                func = function('set_description', name, value=value)
            elif state == 'negate':
                cmds = ['router bgp 65000', 'no {}'.format(cmd)]
                func = function('set_description', name, disable=True)
            elif state == 'default':
                cmds = ['router bgp 65000', 'default {}'.format(cmd)]
                func = function('set_description',
                                name,
                                value=value,
                                default=True)
            self.eapi_positive_config_test(func, cmds)

        # func = function('set_description', name, value=None, default=False,
        #                 disable=False)
        # self.eapi_exception_config_test(func, ValueError)
        # If command_builder fails because value is None, uncomment
        # above lines and remove below lines.
        cmds = ['router bgp 65000', 'no neighbor test description']
        func = function('set_description', 'test', None)
        self.eapi_positive_config_test(func, cmds)
Beispiel #13
0
    def test_set_route_map_out(self):
        for state in ['config', 'negate', 'default']:
            route_map = 'TEST_RM'
            name = 'test'
            cmd = 'neighbor {} route-map'.format(name)
            if state == 'config':
                cmds = ['router bgp 65000', '{} {} out'.format(cmd, route_map)]
                func = function('set_route_map_out', name, value=route_map)
            elif state == 'negate':
                cmds = ['router bgp 65000', 'no {} out'.format(cmd)]
                func = function('set_route_map_out', name, disable=True)
            elif state == 'default':
                cmds = ['router bgp 65000', 'default {} out'.format(cmd)]
                func = function('set_route_map_out',
                                name,
                                value=route_map,
                                default=True)
            self.eapi_positive_config_test(func, cmds)

        # func = function('set_route_map_out', name, value=None, default=False,
        #                 disable=False)
        # self.eapi_exception_config_test(func, ValueError)
        # If command_builder fails because value is None, uncomment
        # above lines and remove below lines.
        cmds = ['router bgp 65000', 'no neighbor test route-map out']
        func = function('set_route_map_out', 'test', None)
        self.eapi_positive_config_test(func, cmds)
Beispiel #14
0
    def test_set_delay_reload(self):
        # vrrp 10 delay reload 0

        # Test set_delay_min gives properly formatted commands
        cases = [
            (1750, None, None, 'vrrp %d delay reload 1750' % upd_vrid),
            (None, None, True, 'default vrrp %d delay reload' % upd_vrid),
            (None, True, True, 'default vrrp %d delay reload' % upd_vrid),
            (None, True, None, 'no vrrp %d delay reload' % upd_vrid),
        ]

        for (delay_reload, disable, default, cmd) in cases:
            func = function('set_delay_reload', upd_intf, upd_vrid,
                            value=delay_reload, disable=disable,
                            default=default)
            exp_cmds = [upd_cmd] + [cmd]
            self.eapi_positive_config_test(func, exp_cmds)

        # Test raising ValueError by entering invalid parameters
        cases = ['a', 3601]

        for delay_reload in cases:
            func = function('set_delay_reload', upd_intf, upd_vrid,
                            value=delay_reload)
            self.eapi_exception_config_test(func, ValueError)
Beispiel #15
0
 def test_set_shutdown(self):
     for state in ['config', 'negate', 'default']:
         if state == 'config':
             cmds = ['router ospf 65000', 'shutdown']
             func = function('set_shutdown')
         elif state == 'negate':
             cmds = ['router ospf 65000', 'no shutdown']
             func = function('set_no_shutdown')
         self.eapi_positive_config_test(func, cmds)
 def test_set_banner_default_disable(self):
     func = function('set_banner', banner_type='motd',
                     value=None, default=True)
     cmds = 'default banner motd'
     self.eapi_positive_config_test(func, cmds)
     func = function('set_banner', banner_type='motd',
                     value=None, disable=True)
     cmds = 'no banner motd'
     self.eapi_positive_config_test(func, cmds)
Beispiel #17
0
    def test_remove_network(self):
        func = function('remove_network', '172.16.10.1', '24', 'test')
        cmds = ['router bgp 65000', 'no network 172.16.10.1/24 route-map test']
        self.eapi_positive_config_test(func, cmds)

        func = function('remove_network', '', '24', 'test')
        self.eapi_exception_config_test(func, ValueError)

        func = function('remove_network', '172.16.10.1', '', 'test')
        self.eapi_exception_config_test(func, ValueError)
Beispiel #18
0
    def test_remove_network(self):
        func = function('remove_network', '172.16.10.1', '24', 'test')
        cmds = ['router bgp 65000', 'no network 172.16.10.1/24 route-map test']
        self.eapi_positive_config_test(func, cmds)

        func = function('remove_network', '', '24', 'test')
        self.eapi_exception_config_test(func, ValueError)

        func = function('remove_network', '172.16.10.1', '', 'test')
        self.eapi_exception_config_test(func, ValueError)
Beispiel #19
0
    def test_remove_network(self):
        func = function('remove_network', '172.16.10.0', '24', '0')
        cmds = ['router ospf 65000', 'no network 172.16.10.0/24 area 0']
        self.eapi_positive_config_test(func, cmds)

        func = function('remove_network', '', '24', '0')
        self.eapi_exception_config_test(func, ValueError)

        func = function('remove_network', '172.16.10.0', '', '0')
        self.eapi_exception_config_test(func, ValueError)
Beispiel #20
0
 def test_set_iprouting(self):
     for state in ['config', 'negate', 'default']:
         if state == 'config':
             cmds = 'ip routing'
             func = function('set_iprouting', True)
         elif state == 'negate':
             cmds = 'no ip routing'
             func = function('set_iprouting', disable=True)
         elif state == 'default':
             cmds = 'default ip routing'
             func = function('set_iprouting', default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #21
0
 def test_set_shutdown(self):
     for state in ['config', 'negate', 'default']:
         if state == 'config':
             cmds = ['router bgp 65000', 'shutdown']
             func = function('set_shutdown', default=False, disable=False)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no shutdown']
             func = function('set_shutdown', disable=True)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default shutdown']
             func = function('set_shutdown', default=True)
         self.eapi_positive_config_test(func, cmds)
 def test_set_mtu_invalid_value_raises_value_error(self):
     for intf in self.INTERFACES:
         for value in [67, 65536, random_string()]:
             func = function('set_mtu', intf, value)
             self.eapi_exception_config_test(func, ValueError)
         for value in [None]:
             # If command_builder fails because value is None, put None
             # in the first loop to check for value error, and remove
             # this second loop
             cmds = ['interface %s' % intf, 'no mtu']
             func = function('set_mtu', intf, value)
             self.eapi_positive_config_test(func, cmds)
 def test_set_mtu_invalid_value_raises_value_error(self):
     for intf in self.INTERFACES:
         for value in [67, 65536, random_string()]:
             func = function('set_mtu', intf, value)
             self.eapi_exception_config_test(func, ValueError)
         for value in [None]:
             # If command_builder fails because value is None, put None
             # in the first loop to check for value error, and remove
             # this second loop
             cmds = ['interface %s' % intf, 'no mtu']
             func = function('set_mtu', intf, value)
             self.eapi_positive_config_test(func, cmds)
Beispiel #24
0
 def test_set_shutdown(self):
     for state in ['config', 'negate', 'default']:
         if state == 'config':
             cmds = ['router bgp 65000', 'shutdown']
             func = function('set_shutdown', default=False, disable=False)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no shutdown']
             func = function('set_shutdown', disable=True)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default shutdown']
             func = function('set_shutdown', default=True)
         self.eapi_positive_config_test(func, cmds)
 def test_set_iprouting(self):
     for state in ['config', 'negate', 'default']:
         if state == 'config':
             cmds = 'ip routing'
             func = function('set_iprouting', True)
         elif state == 'negate':
             cmds = 'no ip routing'
             func = function('set_iprouting', disable=True)
         elif state == 'default':
             cmds = 'default ip routing'
             func = function('set_iprouting', default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #26
0
    def test_set_secondary_ips(self):
        # vrrp 10 ip 10.10.4.21 secondary
        # vrrp 10 ip 10.10.4.22 secondary
        # vrrp 10 ip 10.10.4.23 secondary

        curr1 = '10.10.4.21'
        curr2 = '10.10.4.22'
        curr3 = '10.10.4.23'
        curr4 = '10.10.4.24'

        new1 = '10.10.4.31'
        new2 = '10.10.4.32'
        new3 = '10.10.4.33'
        new4 = curr4

        # Test set_secondary_ips gives properly formatted commands
        cases = [
            ([new1, new2, new3],
             {'add': [new1, new2, new3],
              'remove': [curr1, curr2, curr3, curr4]}),
            ([new1, new2, new4],
             {'add': [new1, new2],
              'remove': [curr1, curr2, curr3]}),
            ([],
             {'add': [],
              'remove': [curr1, curr2, curr3, curr4]}),
        ]

        for (secondary_ips, cmd_dict) in cases:
            cmds = []
            for sec_ip in cmd_dict['add']:
                cmds.append("vrrp %d ip %s secondary" % (upd_vrid, sec_ip))

            for sec_ip in cmd_dict['remove']:
                cmds.append("no vrrp %d ip %s secondary" % (upd_vrid, sec_ip))

            func = function('set_secondary_ips', upd_intf, upd_vrid,
                            secondary_ips)
            exp_cmds = [upd_cmd] + sorted(cmds)
            self.eapi_positive_config_test(func, exp_cmds)

        # Test raising ValueError by entering invalid parameters
        cases = [
            [new1, new2, 'abc'],
            [new1, new2, '10.10.10'],
            [new1, new2, True],
        ]

        for secondary_ips in cases:
            func = function('set_secondary_ips', upd_intf, upd_vrid,
                            secondary_ips)
            self.eapi_exception_config_test(func, ValueError)
Beispiel #27
0
 def test_set_domain_id(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('domain-id test.dom-id string')
             func = function('set_domain_id', 'test.dom-id string')
         elif state == 'negate':
             cmds.append('no domain-id')
             func = function('set_domain_id', value='test', disable=True)
         elif state == 'default':
             cmds.append('default domain-id')
             func = function('set_domain_id', value='test', default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #28
0
 def test_set_domain_id(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('domain-id test')
             func = function('set_domain_id', 'test')
         elif state == 'negate':
             cmds.append('no domain-id')
             func = function('set_domain_id')
         elif state == 'default':
             cmds.append('default domain-id')
             func = function('set_domain_id', value='test', default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #29
0
 def test_maximum_paths_just_max_path(self):
     for state in ['config', 'negate', 'default']:
         max_paths = 20
         if state == 'config':
             cmds = ['router bgp 65000', 'maximum-paths 20']
             func = function('set_maximum_paths', max_paths)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no maximum-paths']
             func = function('set_maximum_paths')
         elif state == 'default':
             cmds = ['router bgp 65000', 'default maximum-paths']
             func = function('set_maximum_paths', default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #30
0
 def test_set_router_id(self):
     for state in ['config', 'negate', 'default']:
         rid = '1.1.1.1'
         if state == 'config':
             cmds = ['router bgp 65000', 'router-id 1.1.1.1']
             func = function('set_router_id', rid)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no router-id']
             func = function('set_router_id')
         elif state == 'default':
             cmds = ['router bgp 65000', 'default router-id']
             func = function('set_router_id', rid, True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #31
0
 def test_set_hostname(self):
     for state in ['config', 'negate', 'default']:
         value = random_string()
         if state == 'config':
             cmds = 'hostname %s' % value
             func = function('set_hostname', value)
         elif state == 'negate':
             cmds = 'no hostname'
             func = function('set_hostname', disable=True)
         elif state == 'default':
             cmds = 'default hostname'
             func = function('set_hostname', value=value, default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #32
0
 def test_set_shutdown(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('shutdown')
             func = function('set_shutdown', default=False, disable=False)
         elif state == 'negate':
             cmds.append('no shutdown')
             func = function('set_shutdown', disable=True)
         elif state == 'default':
             cmds.append('default shutdown')
             func = function('set_shutdown', default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #33
0
 def test_set_mlag_id(self):
     for state in ['config', 'negate', 'default']:
         if state == 'config':
             cmds = ['interface Ethernet1', 'mlag 1']
             func = function('set_mlag_id', 'Ethernet1', '1')
         elif state == 'negate':
             cmds = ['interface Ethernet1', 'no mlag']
             func = function('set_mlag_id', 'Ethernet1', disable=True)
         elif state == 'default':
             cmds = ['interface Ethernet1', 'default mlag']
             func = function('set_mlag_id', 'Ethernet1', value='1',
                             default=True)
         self.eapi_positive_config_test(func, cmds)
 def test_set_hostname(self):
     for state in ['config', 'negate', 'default']:
         value = random_string()
         if state == 'config':
             cmds = 'hostname %s' % value
             func = function('set_hostname', value)
         elif state == 'negate':
             cmds = 'no hostname'
             func = function('set_hostname', disable=True)
         elif state == 'default':
             cmds = 'default hostname'
             func = function('set_hostname', value=value, default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #35
0
 def test_set_banner_default_disable(self):
     func = function('set_banner',
                     banner_type='motd',
                     value=None,
                     default=True)
     cmds = 'default banner motd'
     self.eapi_positive_config_test(func, cmds)
     func = function('set_banner',
                     banner_type='motd',
                     value=None,
                     disable=True)
     cmds = 'no banner motd'
     self.eapi_positive_config_test(func, cmds)
Beispiel #36
0
 def test_instance_functions_exceptions(self):
     intf = 'Ethernet1'
     for name in ['create', 'delete']:
         if name == 'create':
             cmds = 'interface %s' % intf
             func = function(name, intf)
             self.eapi_exception_config_test(func, NotImplementedError,
                                             cmds)
         elif name == 'delete':
             cmds = 'no interface %s' % intf
             func = function(name, intf)
             self.eapi_exception_config_test(func, NotImplementedError,
                                             cmds)
Beispiel #37
0
 def test_set_router_id(self):
     for state in ['config', 'negate', 'default']:
         rid = '1.1.1.1'
         if state == 'config':
             cmds = ['router bgp 65000', 'router-id 1.1.1.1']
             func = function('set_router_id', rid)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no router-id']
             func = function('set_router_id')
         elif state == 'default':
             cmds = ['router bgp 65000', 'default router-id']
             func = function('set_router_id', rid, True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #38
0
 def test_set_shutdown(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('shutdown')
             func = function('set_shutdown', default=False, disable=False)
         elif state == 'negate':
             cmds.append('no shutdown')
             func = function('set_shutdown', disable=True)
         elif state == 'default':
             cmds.append('default shutdown')
             func = function('set_shutdown', default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #39
0
 def test_set_next_hop_self(self):
     for state in ['config', 'negate', 'default']:
         name = 'test'
         cmd = 'neighbor {}'.format(name)
         if state == 'config':
             cmds = ['router bgp 65000', '{} next-hop-self'.format(cmd)]
             func = function('set_next_hop_self', name, True)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no {} next-hop-self'.format(cmd)]
             func = function('set_next_hop_self', name)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default {} next-hop-self'.format(cmd)]
             func = function('set_next_hop_self', name, False, True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #40
0
 def test_set_peer_address(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('peer-address 1.2.3.4')
             func = function('set_peer_address', '1.2.3.4')
         elif state == 'negate':
             cmds.append('no peer-address')
             func = function('set_peer_address', disable=True)
         elif state == 'default':
             cmds.append('default peer-address')
             func = function('set_peer_address', value='1.2.3.4',
                             default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #41
0
 def test_set_local_interface(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('local-interface Vlan1234')
             func = function('set_local_interface', 'Vlan1234')
         elif state == 'negate':
             cmds.append('no local-interface')
             func = function('set_local_interface', disable=True)
         elif state == 'default':
             cmds.append('default local-interface')
             func = function('set_local_interface', value='Vlan1234',
                             default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #42
0
 def test_set_peer_link(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('peer-link Ethernet1')
             func = function('set_peer_link', 'Ethernet1')
         elif state == 'negate':
             cmds.append('no peer-link')
             func = function('set_peer_link', disable=True)
         elif state == 'default':
             cmds.append('default peer-link')
             func = function('set_peer_link', value='Ethernet1',
                             default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #43
0
 def test_set_name(self):
     for state in ['config', 'negate', 'default']:
         vid = random_vlan()
         name = random_string()
         if state == 'config':
             cmds = ['vlan %s' % vid, 'name %s' % name]
             func = function('set_name', vid, name)
         elif state == 'negate':
             cmds = ['vlan %s' % vid, 'no name']
             func = function('set_name', vid, disable=True)
         elif state == 'default':
             cmds = ['vlan %s' % vid, 'default name']
             func = function('set_name', vid, default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #44
0
 def test_set_name(self):
     for state in ['config', 'negate', 'default']:
         vid = random_vlan()
         name = random_string()
         if state == 'config':
             cmds = ['vlan %s' % vid, 'name %s' % name]
             func = function('set_name', vid, name)
         elif state == 'negate':
             cmds = ['vlan %s' % vid, 'no name']
             func = function('set_name', vid)
         elif state == 'default':
             cmds = ['vlan %s' % vid, 'default name']
             func = function('set_name', vid, default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #45
0
 def test_set_shutdown(self):
     for state in ['config', 'negate', 'default']:
         name = 'test'
         cmd = 'neighbor {}'.format(name)
         if state == 'config':
             cmds = ['router bgp 65000', '{} shutdown'.format(cmd)]
             func = function('set_shutdown', name, True)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no {} shutdown'.format(cmd)]
             func = function('set_shutdown', name)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default {} shutdown'.format(cmd)]
             func = function('set_shutdown', name, False, True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #46
0
 def test_set_description(self):
     for state in ['config', 'negate', 'default']:
         value = 'this is a test'
         name = 'test'
         cmd = 'neighbor {} description'.format(name)
         if state == 'config':
             cmds = ['router bgp 65000', '{} {}'.format(cmd, value)]
             func = function('set_description', name, value)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no {}'.format(cmd)]
             func = function('set_description', name)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default {}'.format(cmd)]
             func = function('set_description', name, value, True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #47
0
 def test_set_peer_link(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('peer-link Ethernet1')
             func = function('set_peer_link', 'Ethernet1')
         elif state == 'negate':
             cmds.append('no peer-link')
             func = function('set_peer_link')
         elif state == 'default':
             cmds.append('default peer-link')
             func = function('set_peer_link',
                             value='Ethernet1',
                             default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #48
0
 def test_set_description(self):
     for state in ['config', 'negate', 'default']:
         value = 'this is a test'
         name = 'test'
         cmd = 'neighbor {} description'.format(name)
         if state == 'config':
             cmds = ['router bgp 65000', '{} {}'.format(cmd, value)]
             func = function('set_description', name, value)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no {}'.format(cmd)]
             func = function('set_description', name)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default {}'.format(cmd)]
             func = function('set_description', name, value, True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #49
0
 def test_set_route_map_out(self):
     for state in ['config', 'negate', 'default']:
         route_map = 'TEST_RM'
         name = 'test'
         cmd = 'neighbor {} route-map'.format(name)
         if state == 'config':
             cmds = ['router bgp 65000', '{} {} out'.format(cmd, route_map)]
             func = function('set_route_map_out', name, route_map)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no {} out'.format(cmd)]
             func = function('set_route_map_out', name)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default {} out'.format(cmd)]
             func = function('set_route_map_out', name, route_map, True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #50
0
 def test_set_ipv6_routing(self):
     for state in ['config', 'negate', 'default']:
         vrf_name = 'testipv6vrf'
         if state == 'config':
             cmds = ['ipv6 unicast-routing vrf %s' % vrf_name]
             func = function('set_ipv6_routing', vrf_name)
             self.eapi_positive_config_test(func, cmds)
         elif state == 'negate':
             cmds = ['no ipv6 unicast-routing vrf %s' % vrf_name]
             func = function('set_ipv6_routing', vrf_name, disable=True)
             self.eapi_positive_config_test(func, cmds)
         elif state == 'default':
             cmds = ['default ipv6 unicast-routing vrf %s' % vrf_name]
             func = function('set_ipv6_routing', vrf_name, default=True)
             self.eapi_positive_config_test(func, cmds)
Beispiel #51
0
 def test_set_route_map_out(self):
     for state in ['config', 'negate', 'default']:
         route_map = 'TEST_RM'
         name = 'test'
         cmd = 'neighbor {} route-map'.format(name)
         if state == 'config':
             cmds = ['router bgp 65000', '{} {} out'.format(cmd, route_map)]
             func = function('set_route_map_out', name, route_map)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no {} out'.format(cmd)]
             func = function('set_route_map_out', name)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default {} out'.format(cmd)]
             func = function('set_route_map_out', name, route_map, True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #52
0
 def test_set_remote_as(self):
     for state in ['config', 'negate', 'default']:
         remote_as = '65000'
         name = 'test'
         cmd = 'neighbor {} remote-as'.format(name)
         if state == 'config':
             cmds = ['router bgp 65000', '{} {}'.format(cmd, remote_as)]
             func = function('set_remote_as', name, remote_as)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no {}'.format(cmd)]
             func = function('set_remote_as', name)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default {}'.format(cmd)]
             func = function('set_remote_as', name, remote_as, True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #53
0
 def test_set_local_interface(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('local-interface Vlan1234')
             func = function('set_local_interface', 'Vlan1234')
         elif state == 'negate':
             cmds.append('no local-interface')
             func = function('set_local_interface')
         elif state == 'default':
             cmds.append('default local-interface')
             func = function('set_local_interface',
                             value='Vlan1234',
                             default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #54
0
 def test_set_peer_address(self):
     for state in ['config', 'negate', 'default']:
         cmds = ['mlag configuration']
         if state == 'config':
             cmds.append('peer-address 1.2.3.4')
             func = function('set_peer_address', '1.2.3.4')
         elif state == 'negate':
             cmds.append('no peer-address')
             func = function('set_peer_address')
         elif state == 'default':
             cmds.append('default peer-address')
             func = function('set_peer_address',
                             value='1.2.3.4',
                             default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #55
0
 def test_set_mlag_id(self):
     for state in ['config', 'negate', 'default']:
         if state == 'config':
             cmds = ['interface Ethernet1', 'mlag 1']
             func = function('set_mlag_id', 'Ethernet1', '1')
         elif state == 'negate':
             cmds = ['interface Ethernet1', 'no mlag']
             func = function('set_mlag_id', 'Ethernet1')
         elif state == 'default':
             cmds = ['interface Ethernet1', 'default mlag']
             func = function('set_mlag_id',
                             'Ethernet1',
                             value='1',
                             default=True)
         self.eapi_positive_config_test(func, cmds)
Beispiel #56
0
 def test_set_peer_group(self):
     for state in ['config', 'negate', 'default']:
         peer_group = 'test'
         name = '172.16.10.1'
         cmd = 'neighbor {} peer-group'.format(name)
         if state == 'config':
             cmds = ['router bgp 65000', '{} {}'.format(cmd, peer_group)]
             func = function('set_peer_group', name, peer_group)
         elif state == 'negate':
             cmds = ['router bgp 65000', 'no {}'.format(cmd)]
             func = function('set_peer_group', name)
         elif state == 'default':
             cmds = ['router bgp 65000', 'default {}'.format(cmd)]
             func = function('set_peer_group', name, peer_group, True)
         self.eapi_positive_config_test(func, cmds)
 def test_set_trunk_native_vlan(self):
     for intf in self.INTERFACES:
         vid = random_vlan()
         cmds = ['interface %s' % intf,
                 'switchport trunk native vlan %s' % vid]
         func = function('set_trunk_native_vlan', intf, vid)
         self.eapi_positive_config_test(func, cmds)
Beispiel #58
0
 def test_set_allowed_vlans_with_default(self):
     for intf in self.INTERFACES:
         cmds = [
             'interface %s' % intf, 'default switchport trunk allowed vlan'
         ]
         func = function('set_trunk_allowed_vlans', intf, default=True)
         self.eapi_positive_config_test(func, cmds)
 def test_set_trunk_allowed_vlans(self):
     for intf in self.INTERFACES:
         vid = '1,2,3-5,6,7'
         cmds = ['interface %s' % intf,
                 'switchport trunk allowed vlan %s' % vid]
         func = function('set_trunk_allowed_vlans', intf, vid)
         self.eapi_positive_config_test(func, cmds)