def test__flavor_plugin(self, get_service_plugins):
     _fake_flavor_plugin = mock.sentinel.fla_plugin
     get_service_plugins.return_value = {
         p_cons.FLAVORS: _fake_flavor_plugin
     }
     _dc = driver_controller.DriverController(self.fake_l3)
     self.assertEqual(_fake_flavor_plugin, _dc._flavor_plugin)
Exemplo n.º 2
0
 def setUp(self):
     super(TestDriverController, self).setUp()
     self.setup_coreplugin(DB_PLUGIN_KLASS)
     self.fake_l3 = mock.Mock()
     self.dc = driver_controller.DriverController(self.fake_l3)
     self.fake_l3.l3_driver_controller = self.dc
     self.ctx = context.get_admin_context()
Exemplo n.º 3
0
 def test__update_router_provider_with_flags(self):
     test_dc = driver_controller.DriverController(self.fake_l3)
     with mock.patch.object(registry, "publish"):
         with mock.patch.object(test_dc, "get_provider_for_router"):
             with mock.patch.object(
                 driver_controller,
                 "_ensure_driver_supports_request") as _ensure:
                 _ensure.side_effect = lib_exc.InvalidInput(
                     error_message='message')
                 with mock.patch(
                     "neutron.services.l3_router.service_providers."
                         "driver_controller.LOG.debug") as mock_log:
                     self.assertRaises(
                         lib_exc.InvalidInput,
                         test_dc._update_router_provider,
                         None, None, None,
                         payload=events.DBEventPayload(
                             None, request_body={'name': 'testname',
                                                 'distributed': False},
                             states=({'flavor_id': None,
                                      'distributed': True, 'ha': False},)))
                     # To validate that the 'ha' attribute of the router
                     # stays unchanged from the previous state while
                     # updating 'distributed' from True to False.
                     mock_log.assert_any_call(
                         "Get a provider driver handle based on the ha "
                         "flag: %(ha_flag)s and distributed flag: "
                         "%(distributed_flag)s",
                         {'ha_flag': False, 'distributed_flag': False})
 def test__update_router_provider_invalid(self):
     test_dc = driver_controller.DriverController(self.fake_l3)
     with mock.patch.object(test_dc, "_get_provider_for_router"):
         with mock.patch.object(
                 driver_controller,
                 "_ensure_driver_supports_request") as _ensure:
             _ensure.side_effect = lib_exc.Invalid(message='message')
             self.assertRaises(lib_exc.Invalid,
                               test_dc._update_router_provider, None, None,
                               None, None, None, {'name': 'testname'},
                               {'flavor_id': 'old_fid'}, None)
Exemplo n.º 5
0
    def test___attrs_to_driver(self):
        test_dc = driver_controller.DriverController(self.fake_l3)
        test_dc.default_provider = 'single_node'
        self.assertIsInstance(test_dc._attrs_to_driver({}),
                              single_node.SingleNodeDriver)

        test_dc.default_provider = 'ha'
        with mock.patch.object(driver_controller,
                               "_is_driver_compatible",
                               return_value=False):
            self.assertRaises(NotImplementedError, test_dc._attrs_to_driver,
                              {})
Exemplo n.º 6
0
    def __init__(self):
        self.router_scheduler = importutils.import_object(
            cfg.CONF.router_scheduler_driver)
        self.add_periodic_l3_agent_status_check()
        super(L3RouterPlugin, self).__init__()
        if 'dvr' in self.supported_extension_aliases:
            l3_dvrscheduler_db.subscribe()
        self.agent_notifiers.update(
            {n_const.AGENT_TYPE_L3: l3_rpc_agent_api.L3AgentNotifyAPI()})

        rpc_worker = service.RpcWorker([self], worker_process_count=0)

        self.add_worker(rpc_worker)
        self.l3_driver_controller = driver_controller.DriverController(self)
Exemplo n.º 7
0
 def test__update_router_provider_invalid(self):
     test_dc = driver_controller.DriverController(self.fake_l3)
     with mock.patch.object(registry, "publish") as mock_cb:
         with mock.patch.object(test_dc, "get_provider_for_router"):
             with mock.patch.object(
                 driver_controller,
                 "_ensure_driver_supports_request") as _ensure:
                 _ensure.side_effect = lib_exc.InvalidInput(
                     error_message='message')
                 self.assertRaises(
                     lib_exc.InvalidInput,
                     test_dc._update_router_provider,
                     None, None, None,
                     payload=events.DBEventPayload(
                         None, request_body={'name': 'testname'},
                         states=({'flavor_id': 'old_fid'},)))
                 mock_cb.assert_not_called()
Exemplo n.º 8
0
 def test__flavor_plugin(self):
     directory.add_plugin(p_cons.FLAVORS, mock.Mock())
     _dc = driver_controller.DriverController(self.fake_l3)
     self.assertEqual(directory.get_plugin(p_cons.FLAVORS),
                      _dc._flavor_plugin)
 def setUp(self):
     super(TestDriverController, self).setUp()
     self.fake_l3 = mock.Mock()
     self.dc = driver_controller.DriverController(self.fake_l3)
     self.ctx = context.get_admin_context()