diff --git a/neutron/common/constants.py b/neutron/common/constants.py index e424450d25a..bc37a87cb16 100644 --- a/neutron/common/constants.py +++ b/neutron/common/constants.py @@ -28,6 +28,7 @@ FLOATINGIP_STATUS_ACTIVE = 'ACTIVE' FLOATINGIP_STATUS_DOWN = 'DOWN' FLOATINGIP_STATUS_ERROR = 'ERROR' +PORT_STATUS_NOTAPPLICABLE = 'N/A' DEVICE_OWNER_ROUTER_HA_INTF = "network:router_ha_interface" DEVICE_OWNER_ROUTER_INTF = "network:router_interface" diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index 65898cca46a..3fa7c18bd07 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -777,16 +777,32 @@ def create_floatingip(self, context, floatingip, # This external port is never exposed to the tenant. # it is used purely for internal system and admin use when # managing floating IPs. - external_port = self._core_plugin.create_port(context.elevated(), { - 'port': - {'tenant_id': '', # tenant intentionally not set - 'network_id': f_net_id, - 'mac_address': attributes.ATTR_NOT_SPECIFIED, - 'fixed_ips': attributes.ATTR_NOT_SPECIFIED, - 'admin_state_up': True, - 'device_id': fip_id, - 'device_owner': DEVICE_OWNER_FLOATINGIP, - 'name': ''}}) + #external_port = self._core_plugin.create_port(context.elevated(), { + # 'port': + #{'tenant_id': '', # tenant intentionally not set + #'network_id': f_net_id, + #'mac_address': attributes.ATTR_NOT_SPECIFIED, + #'fixed_ips': attributes.ATTR_NOT_SPECIFIED, + #'admin_state_up': True, + #'device_id': fip_id, + #'device_owner': DEVICE_OWNER_FLOATINGIP, + #'name': ''}}) + port = {'tenant_id': '', # tenant intentionally not set + 'network_id': f_net_id, + 'mac_address': attributes.ATTR_NOT_SPECIFIED, + 'fixed_ips': attributes.ATTR_NOT_SPECIFIED, + 'admin_state_up': True, + 'device_id': fip_id, + 'device_owner': DEVICE_OWNER_FLOATINGIP, + 'status': l3_constants.PORT_STATUS_NOTAPPLICABLE, + 'name': ''} + + if fip.get('floating_ip_address'): + port['fixed_ips'] = [ + {'ip_address': fip['floating_ip_address']}] + + external_port = self._core_plugin.create_port(context.elevated(), + {'port': port}) # Ensure IP addresses are allocated on external port if not external_port['fixed_ips']: raise n_exc.ExternalIpAddressExhausted(net_id=f_net_id) diff --git a/neutron/extensions/l3.py b/neutron/extensions/l3.py index 1497d9fb45c..9088368e234 100644 --- a/neutron/extensions/l3.py +++ b/neutron/extensions/l3.py @@ -120,7 +120,7 @@ class RouterExternalGatewayInUseByFloatingIp(qexception.InUse): 'validate': {'type:uuid': None}, 'is_visible': True, 'primary_key': True}, - 'floating_ip_address': {'allow_post': False, 'allow_put': False, + 'floating_ip_address': {'allow_post': True, 'allow_put': False, 'validate': {'type:ip_address_or_none': None}, 'is_visible': True}, 'floating_network_id': {'allow_post': True, 'allow_put': False,