Exemplo n.º 1
0
    def setUp(self):
        super(TestBasicRoutingOperations, self).setUp()
        self.conf = cfg.ConfigOpts()
        self.conf.register_opts(base_config.core_opts)
        self.conf.register_opts(cfg_agent.CiscoCfgAgent.OPTS)
        self.ex_gw_port = {
            'id': _uuid(),
            'network_id': _uuid(),
            'fixed_ips': [{
                'ip_address': '19.4.4.4',
                'subnet_id': _uuid()
            }],
            'subnets': [{
                'cidr': '19.4.4.0/24',
                'gateway_ip': '19.4.4.1'
            }]
        }
        self.hosting_device = {
            'id': "100",
            'name': "CSR1kv_template",
            'booting_time': 300,
            'host_category': "VM",
            'management_ip_address': '20.0.0.5',
            'protocol_port': 22,
            'credentials': {
                'username': '******',
                "password": '******'
            },
        }
        self.router = {
            'id': _uuid(),
            'enable_snat': True,
            'routes': [],
            'gw_port': self.ex_gw_port,
            'hosting_device': self.hosting_device
        }

        self.agent = mock.Mock()

        #Patches & Mocks

        self.l3pluginApi_cls_p = mock.patch(
            'networking_cisco.plugins.cisco.cfg_agent.service_helpers.'
            'routing_svc_helper.CiscoRoutingPluginApi')
        l3plugin_api_cls = self.l3pluginApi_cls_p.start()
        self.plugin_api = mock.Mock()
        l3plugin_api_cls.return_value = self.plugin_api
        self.plugin_api.get_routers = mock.MagicMock()
        self.looping_call_p = mock.patch(
            'oslo_service.loopingcall.FixedIntervalLoopingCall')
        self.looping_call_p.start()
        mock.patch('neutron.common.rpc.create_connection').start()

        self.routing_helper = routing_svc_helper.RoutingServiceHelper(
            HOST, self.conf, self.agent)
        self.routing_helper._internal_network_added = mock.Mock()
        self.routing_helper._external_gateway_added = mock.Mock()
        self.routing_helper._internal_network_removed = mock.Mock()
        self.routing_helper._external_gateway_removed = mock.Mock()
        self.driver = self._mock_driver_and_hosting_device(self.routing_helper)
    def setUp(self):
        super(TestDeviceSyncOperations, self).setUp()
        self.conf = cfg.ConfigOpts()
        self.conf.register_opts(bc.core_opts)
        self.conf.register_opts(cfg_agent.OPTS, "cfg_agent")
        self.ex_gw_port = {
            'id': _uuid(),
            'network_id': _uuid(),
            'admin_state_up': True,
            'fixed_ips': [{
                'ip_address': '19.4.4.4',
                'subnet_id': _uuid()
            }],
            'subnets': [{
                'cidr': '19.4.4.0/24',
                'gateway_ip': '19.4.4.1'
            }]
        }
        self.hosting_device = {
            'id': "100",
            'name': "CSR1kv_template",
            'booting_time': 300,
            'host_category': "VM",
            'management_ip_address': '20.0.0.5',
            'protocol_port': 22,
            'credentials': {
                'username': '******',
                'password': '******'
            },
        }

        self.fetched_routers = [{
            'id': _uuid(),
            'enable_snat': True,
            'admin_state_up': True,
            'routes': [],
            'gw_port': self.ex_gw_port,
            routerrole.ROUTER_ROLE_ATTR: None,
            'hosting_device': self.hosting_device
        }, {
            'id': _uuid(),
            'enable_snat': True,
            'admin_state_up': True,
            'routes': [],
            'gw_port': self.ex_gw_port,
            routerrole.ROUTER_ROLE_ATTR: None,
            'hosting_device': self.hosting_device
        }]

        #Patches & Mocks
        self.agent = mock.Mock()

        self.routing_helper = routing_svc_helper.RoutingServiceHelper(
            HOST, self.conf, self.agent)
        self.routing_helper._cleanup_invalid_cfg = mock.Mock()
        self.routing_helper._router_removed = mock.Mock()
        self.driver = self._mock_driver_and_hosting_device(self.routing_helper)