Esempio n. 1
0
 def test_synchronize_state_no_change(self, mock_ensure_cache):
     rtr = self._init_driver()
     fake_router_obj = fakes.fake_router()
     rtr._router = fake_router_obj
     rtr._last_synced_status = 'ACTIVE'
     rtr.synchronize_state(self.ctx, states.CONFIGURED)
     mock_ensure_cache.assert_called_with(self.ctx)
     self.assertFalse(self.ctx.neutron.update_router_status.called)
Esempio n. 2
0
 def test_get_resource_id_for_tenant(self):
     fake_router = fakes.fake_router()
     self.ctx.neutron.get_router_for_tenant.return_value = fake_router
     res = router.Router.get_resource_id_for_tenant(
         self.ctx, 'fake_tenant_id', 'fake_message')
     self.assertEqual(res, fake_router.id)
     self.ctx.neutron.get_router_for_tenant.assert_called_with(
         'fake_tenant_id')
Esempio n. 3
0
 def test_get_state(self, mock_ensure_cache):
     rtr = self._init_driver()
     fake_router = fakes.fake_router()
     rtr._router = fake_router
     self.assertEqual(
         rtr.get_state(self.ctx),
         fake_router.status,
     )
     mock_ensure_cache.assert_called_with(self.ctx)
Esempio n. 4
0
 def test_pre_plug_no_external_port(self):
     rtr = self._init_driver()
     fake_router_obj = fakes.fake_router()
     fake_router_obj.external_port = None
     rtr._router = fake_router_obj
     self.ctx.neutron.create_router_external_port.return_value = 'fake_port'
     rtr.pre_plug(self.ctx)
     self.ctx.neutron.create_router_external_port.assert_called_with(
         fake_router_obj,
     )
     self.assertEqual(rtr._router.external_port, 'fake_port')
Esempio n. 5
0
 def test_build_config(self, mock_ensure_cache, mock_build_config):
     rtr = self._init_driver()
     fake_router_obj = fakes.fake_router()
     fake_mgt_port = mock.Mock()
     fake_iface_map = mock.Mock()
     rtr._router = fake_router_obj
     mock_build_config.return_value = 'fake_config'
     res = rtr.build_config(self.ctx, fake_mgt_port, fake_iface_map)
     self.assertTrue(mock_ensure_cache.called)
     mock_build_config.return_value = 'fake_config'
     mock_build_config.assert_called_with(
         self.ctx.neutron, rtr._router, fake_mgt_port, fake_iface_map)
     self.assertEqual(res, 'fake_config')
Esempio n. 6
0
 def test_make_ports(self, mock_ensure_cache):
     rtr = self._init_driver()
     fake_router_obj = fakes.fake_router()
     rtr._router = fake_router_obj
     self.ctx.neutron.create_management_port.return_value = 'fake_mgt_port'
     self.ctx.neutron.create_vrrp_port.side_effect = [
         'fake_port_%s' % p.network_id for p in fake_router_obj.ports
     ]
     callback = rtr.make_ports(self.ctx)
     res = callback()
     expected_instance_ports = [
         'fake_port_%s' % p.network_id for p in fake_router_obj.ports
     ]
     self.assertEqual(res, ('fake_mgt_port', expected_instance_ports))
Esempio n. 7
0
 def test_ports_with_router(self):
     rtr = self._init_driver()
     fake_router_obj = fakes.fake_router()
     rtr._router = fake_router_obj
     self.assertEqual(set(rtr.ports), set(fake_router_obj.ports))
Esempio n. 8
0
 def test_pre_plug_with_external_port(self):
     rtr = self._init_driver()
     fake_router_obj = fakes.fake_router()
     fake_router_obj.external_port = 'fake_port'
     rtr.pre_plug(self.ctx)
     self.assertFalse(self.ctx.neutron.create_router_external_port.called)