Merge "Fix L3 HA network creation to allow user to create router"

This commit is contained in:
Jenkins 2014-11-11 00:25:45 +00:00 committed by Gerrit Code Review
commit 29bfb285ec
2 changed files with 30 additions and 6 deletions

View File

@ -224,7 +224,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin):
'shared': False, 'shared': False,
'admin_state_up': True, 'admin_state_up': True,
'status': constants.NET_STATUS_ACTIVE}} 'status': constants.NET_STATUS_ACTIVE}}
network = self._core_plugin.create_network(context, args) network = self._core_plugin.create_network(admin_ctx, args)
try: try:
ha_network = self._create_ha_network_tenant_binding(admin_ctx, ha_network = self._create_ha_network_tenant_binding(admin_ctx,
tenant_id, tenant_id,

View File

@ -54,20 +54,25 @@ class L3HATestFramework(testlib_api.SqlTestCase,
self.notif_m = notif_p.start() self.notif_m = notif_p.start()
cfg.CONF.set_override('allow_overlapping_ips', True) cfg.CONF.set_override('allow_overlapping_ips', True)
def _create_router(self, ha=True, tenant_id='tenant1', distributed=None): def _create_router(self, ha=True, tenant_id='tenant1', distributed=None,
self.admin_ctx.tenant_id = tenant_id ctx=None):
if ctx is None:
ctx = self.admin_ctx
ctx.tenant_id = tenant_id
router = {'name': 'router1', 'admin_state_up': True} router = {'name': 'router1', 'admin_state_up': True}
if ha is not None: if ha is not None:
router['ha'] = ha router['ha'] = ha
if distributed is not None: if distributed is not None:
router['distributed'] = distributed router['distributed'] = distributed
return self.plugin.create_router(self.admin_ctx, {'router': router}) return self.plugin.create_router(ctx, {'router': router})
def _update_router(self, router_id, ha=True, distributed=None): def _update_router(self, router_id, ha=True, distributed=None, ctx=None):
if ctx is None:
ctx = self.admin_ctx
data = {'ha': ha} if ha is not None else {} data = {'ha': ha} if ha is not None else {}
if distributed is not None: if distributed is not None:
data['distributed'] = distributed data['distributed'] = distributed
return self.plugin._update_router_db(self.admin_ctx, router_id, return self.plugin._update_router_db(ctx, router_id,
data, None) data, None)
@ -395,3 +400,22 @@ class L3HATestCase(L3HATestFramework):
routers_after = self.plugin.get_routers(self.admin_ctx) routers_after = self.plugin.get_routers(self.admin_ctx)
self.assertEqual(routers_before, routers_after) self.assertEqual(routers_before, routers_after)
class L3HAUserTestCase(L3HATestFramework):
def setUp(self):
super(L3HAUserTestCase, self).setUp()
self.user_ctx = context.Context('', _uuid())
self.plugin = FakeL3Plugin()
def test_create_ha_router(self):
self._create_router(ctx=self.user_ctx)
def test_update_router(self):
router = self._create_router(ctx=self.user_ctx)
self._update_router(router['id'], ha=False, ctx=self.user_ctx)
def test_delete_router(self):
router = self._create_router(ctx=self.user_ctx)
self.plugin.delete_router(self.user_ctx, router['id'])