]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Allow plugin to specify router_id
authorAaron Rosen <aaronorosen@gmail.com>
Wed, 4 Mar 2015 21:34:26 +0000 (13:34 -0800)
committerAaron Rosen <aaronorosen@gmail.com>
Fri, 24 Apr 2015 04:56:21 +0000 (21:56 -0700)
It is useful to allow the backend to specify the uuid that we want neutron to
use. We currently do this same thing for networks. This patch enables the same
behavior for routers as well.

Change-Id: If675dfd2997217886976301270ef5f773ffa7a13

neutron/db/l3_db.py
neutron/tests/unit/extensions/test_l3.py

index fbad07a13bdc649eb00086e506a72770d6946da9..fd69bf29b78092a61daf564c7b03b33f2e0b4ac8 100644 (file)
@@ -158,7 +158,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
         with context.session.begin(subtransactions=True):
             # pre-generate id so it will be available when
             # configuring external gw port
-            router_db = Router(id=uuidutils.generate_uuid(),
+            router_db = Router(id=(router.get('id') or
+                                   uuidutils.generate_uuid()),
                                tenant_id=tenant_id,
                                name=router['name'],
                                admin_state_up=router['admin_state_up'],
index 8c824d6c07831049220a95ee7c9569ada500c07d..6919220ef1a312093164deefad34b9ba29e03c1d 100644 (file)
@@ -2299,6 +2299,14 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
                                   floating_ip='10.0.0.10',
                                   http_status=exc.HTTPConflict.code)
 
+    def test_router_specify_id_backend(self):
+        plugin = manager.NeutronManager.get_service_plugins()[
+                    service_constants.L3_ROUTER_NAT]
+        router_req = {'router': {'id': _uuid(), 'name': 'router',
+                                 'admin_state_up': True}}
+        result = plugin.create_router(context.Context('', 'foo'), router_req)
+        self.assertEqual(result['id'], router_req['router']['id'])
+
 
 class L3AgentDbTestCaseBase(L3NatTestCaseMixin):