]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Reject router-interface-add with a port which doesn't have any addresses
authorYAMAMOTO Takashi <yamamoto@midokura.com>
Fri, 19 Jun 2015 07:28:23 +0000 (16:28 +0900)
committerYAMAMOTO Takashi <yamamoto@midokura.com>
Sun, 12 Jul 2015 01:10:30 +0000 (10:10 +0900)
Fix a regression in commit I7d4e8194815e626f1cfa267f77a3f2475fdfa3d1 .

Closes-Bug: #1466750
Related-Bug: #1439824
Change-Id: Ic0c4c0adbffe14b1f08d4b2dee91e1dff41cc770

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

index 8f8f70b86e9d4c40695ca9b858e476973a3ffb38..295e63b89d511e97cf57c58b76149f3e8629cfca 100644 (file)
@@ -513,6 +513,10 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
                                       port_id=port['id'],
                                       device_id=port['device_id'])
 
+            if not port['fixed_ips']:
+                msg = _LE('Router port must have at least one fixed IP')
+                raise n_exc.BadRequest(resource='router', msg=msg)
+
             # Only allow one router port with IPv6 subnets per network id
             if self._port_has_ipv6_address(port):
                 for existing_port in (rp.port for rp in router.attached_ports):
index 52503d7d8de332b7c55f6275d65fc49eae28d48e..378a79a6d00510f9f607364f79fa4b16331adda2 100644 (file)
@@ -1292,6 +1292,18 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
                                                     expected_code=err_code,
                                                     tenant_id='bad_tenant')
 
+    def test_router_add_interface_port_without_ips(self):
+        with self.network() as network, self.router() as r:
+            # Create a router port without ips
+            p = self._make_port(self.fmt, network['network']['id'],
+                device_owner=l3_constants.DEVICE_OWNER_ROUTER_INTF)
+            err_code = exc.HTTPBadRequest.code
+            self._router_interface_action('add',
+                                          r['router']['id'],
+                                          None,
+                                          p['port']['id'],
+                                          expected_code=err_code)
+
     def test_router_add_interface_dup_subnet1_returns_400(self):
         with self.router() as r:
             with self.subnet() as s: