def test_generate_template_dict_for_ipv4_neighbor(self):

        plugin = Generic(equipment=self._mock_equipment(),
                         virtual_interface=self.virtual_interface,
                         neighbor=self.ipv4_neighbor,
                         asn=self.asn,
                         vrf=self.vrf)

        returned_dict = plugin._generate_template_dict()

        expected_dict = {
            'AS_NUMBER': '25114',
            'VRF_NAME': 'Vrf-Test',
            'REMOTE_IP': '11.1.1.155',
            'REMOTE_AS': '200',
            'PASSWORD': '******',
            'TIMER_KEEPALIVE': '3',
            'TIMER_TIMEOUT': '60',
            'DESCRIPTION': 'desc',
            'SOFT_RECONFIGURATION': True,
            'COMMUNITY': True,
            'REMOVE_PRIVATE_AS': False,
            'NEXT_HOP_SELF': False
        }

        self.assertDictEqual(expected_dict, returned_dict)
예제 #2
0
    def _generate_config_helper(self, type_operation, neighbor,
                                virtual_interface, asn, vrf, roteiro):

        plugin = Generic(equipment=self._mock_equipment(),
                         virtual_interface=virtual_interface,
                         neighbor=neighbor,
                         asn=asn,
                         vrf=vrf)
        plugin = self._mock_plugin(plugin, roteiro)

        if type_operation == 'deploy':
            template_name = plugin._get_template_deploy_name()
        elif type_operation == 'undeploy':
            template_name = plugin._get_template_undeploy_name()

        path_file_to_deploy = plugin._generate_config_file(template_name)

        if 'v4' in roteiro:
            fake_dell = self._get_file_content(self.fake_template_v4_path,
                                               False)
        elif 'v6' in roteiro:
            fake_dell = self._get_file_content(self.fake_template_v6_path,
                                               False)

        file_to_deploy = self._get_file_content(path_file_to_deploy, True)

        self.assertEquals(fake_dell, file_to_deploy)
    def test_undeploy_neighbor_v4(self):
        undeploy_neighbor_mock = patch(
            'networkapi.plugins.Dell.FTOS.BGP.Cli.Generic._operate_equipment'
        ).start()

        Generic(neighbor={'remote_ip': '1.1.1.1'}).undeploy_neighbor()

        undeploy_neighbor_mock.assert_called_once_with('neighbor_v4_remove')
    def test_deploy_route_map(self):
        undeploy_route_map_mock = patch(
            'networkapi.plugins.Dell.FTOS.BGP.Cli.Generic._operate_equipment'
        ).start()

        Generic().deploy_route_map()

        undeploy_route_map_mock.assert_called_once_with('route_map_add')
    def test_undeploy_prefix_list(self):
        undeploy_prefix_mock = patch(
            'networkapi.plugins.Dell.FTOS.BGP.Cli.Generic._operate_equipment'
        ).start()

        Generic().undeploy_prefix_list()

        undeploy_prefix_mock.assert_called_once_with('prefix_list_remove')
    def test_deploy_neighbor_v6(self):
        deploy_neighbor_mock = patch(
            'networkapi.plugins.Dell.FTOS.BGP.Cli.Generic._operate_equipment'
        ).start()

        Generic(neighbor={'remote_ip': '1:1:1:1:1:1:1:1'}).deploy_neighbor()

        deploy_neighbor_mock.assert_called_once_with('neighbor_v6_add')
    def test_wait_string(self):

        plugin = Generic()

        plugin.channel = Mock()
        plugin.channel.recv.side_effect = ['test', 'ok']

        string = plugin._wait_string('ok')

        self.assertEqual(plugin.channel.recv.call_count, 2)
        self.assertEqual(string, 'ok')
    def test_wait_string_sleep(self):
        sleep_mock = patch(
            'networkapi.plugins.Dell.FTOS.BGP.Cli.sleep').start()

        plugin = Generic()

        plugin.channel = Mock()
        plugin.channel.recv.side_effect = ['ok']
        plugin.channel.recv_ready.side_effect = [False, True]

        plugin._wait_string('ok')

        sleep_mock.assert_called_once_with(1)
        self.assertEqual(sleep_mock.call_count, 1)
    def test_copy_script_file_to_config(self):

        plugin = Generic()
        plugin.tftpserver = '1.1.1.1'

        plugin.channel = Mock()
        plugin.channel.recv.side_effect = ['bytes successfully copied']

        plugin._copy_script_file_to_config(filename='filename',
                                           use_vrf='VRFBE',
                                           destination='running-config')

        # sleep
        plugin.channel.send.assert_called_once_with(
            'copy tftp://1.1.1.1/filename running-config VRFBE\n\n\n')
예제 #10
0
    def _helper_to_check_templates_name(self, type_operation, neighbor,
                                        expected_template_name):

        plugin = Generic(equipment=self._mock_equipment(),
                         virtual_interface=self.virtual_interface,
                         neighbor=neighbor,
                         asn=self.asn,
                         vrf=self.vrf)

        if type_operation == 'deploy':
            returned_template_name = plugin._get_template_deploy_name()
        elif type_operation == 'undeploy':
            returned_template_name = plugin._get_template_undeploy_name()

        self.assertEquals(expected_template_name, returned_template_name)