diff --git a/api-ref/source/v2/floatingips.inc b/api-ref/source/v2/floatingips.inc index 3facdb7cd..3add14a93 100644 --- a/api-ref/source/v2/floatingips.inc +++ b/api-ref/source/v2/floatingips.inc @@ -10,6 +10,13 @@ attributes to floating IPs allowing them to be specified at creation time. The data in these attributes will be published in an external DNS service when Neutron is configured to integrate with such a service. +Floating IP port details +======================== + +The ``fip-port-details`` extension adds the ``port_details`` attribute to +floating IPs. The value of this attribute contains information of the +associated port. + List floating IPs ================= @@ -76,6 +83,7 @@ Response Parameters - description: description - dns_domain: dns_domain - dns_name: dns_name + - port_details: floating_port_details - floating_network_id: floating_network_id - fixed_ip_address: floatingip-fixed_ip_address - floating_ip_address: floating_ip_address @@ -180,6 +188,7 @@ Response Parameters - description: description - dns_domain: dns_domain - dns_name: dns_name + - port_details: floating_port_details - tenant_id: project_id - created_at: created_at_resource - updated_at: updated_at_resource @@ -243,6 +252,7 @@ Response Parameters - description: description - dns_domain: dns_domain - dns_name: dns_name + - port_details: floating_port_details - tenant_id: project_id - created_at: created_at_resource - updated_at: updated_at_resource @@ -330,6 +340,7 @@ Response Parameters - description: description - dns_domain: dns_domain - dns_name: dns_name + - port_details: floating_port_details Response Example ---------------- diff --git a/api-ref/source/v2/parameters.yaml b/api-ref/source/v2/parameters.yaml index d1af853f0..b2a751c05 100644 --- a/api-ref/source/v2/parameters.yaml +++ b/api-ref/source/v2/parameters.yaml @@ -2494,6 +2494,17 @@ floating_network_id: in: body required: true type: string +floating_port_details: + description: | + The information of the port that this floating IP associates with. + In particular, if the floating IP is associated with a port, this field + contains some attributes of the associated port, including ``name``, + ``network_id``, ``mac_address``, ``admin_state_up``, ``status``, + ``device_id`` and ``device_owner``. If the floating IP is not associated + with a port, this field is ``null``. + in: body + required: true + type: string floatingip: description: | A ``floatingip`` object. When you associate a diff --git a/api-ref/source/v2/samples/floatingips/floating-ips-list-response.json b/api-ref/source/v2/samples/floatingips/floating-ips-list-response.json index dae2fb857..34b6254c7 100644 --- a/api-ref/source/v2/samples/floatingips/floating-ips-list-response.json +++ b/api-ref/source/v2/samples/floatingips/floating-ips-list-response.json @@ -15,7 +15,16 @@ "floating_ip_address": "172.24.4.228", "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab", "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda7", - "status": "ACTIVE" + "status": "ACTIVE", + "port_details": { + "status": "ACTIVE", + "name": "", + "admin_state_up": true, + "network_id": "02dd8479-ef26-4398-a102-d19d0a7b3a1f", + "device_owner": "compute:nova", + "mac_address": "fa:16:3e:b1:3b:30", + "device_id": "8e3941b4-a6e9-499f-a1ac-2a4662025cba" + } }, { "router_id": null, @@ -32,7 +41,8 @@ "floating_ip_address": "172.24.4.227", "port_id": null, "id": "61cea855-49cb-4846-997d-801b70c71bdd", - "status": "DOWN" + "status": "DOWN", + "port_details": null } ] } diff --git a/api-ref/source/v2/samples/floatingips/floatingip-create-response.json b/api-ref/source/v2/samples/floatingips/floatingip-create-response.json index a4c187105..f84f2300a 100644 --- a/api-ref/source/v2/samples/floatingips/floatingip-create-response.json +++ b/api-ref/source/v2/samples/floatingips/floatingip-create-response.json @@ -14,6 +14,15 @@ "dns_name": "myfip", "created_at": "2016-12-21T01:36:04Z", "updated_at": "2016-12-21T01:36:04Z", - "revision_number": 1 + "revision_number": 1, + "port_details": { + "status": "ACTIVE", + "name": "", + "admin_state_up": true, + "network_id": "02dd8479-ef26-4398-a102-d19d0a7b3a1f", + "device_owner": "compute:nova", + "mac_address": "fa:16:3e:b1:3b:30", + "device_id": "8e3941b4-a6e9-499f-a1ac-2a4662025cba" + } } } diff --git a/api-ref/source/v2/samples/floatingips/floatingip-disassociate-response.json b/api-ref/source/v2/samples/floatingips/floatingip-disassociate-response.json index 06e09b12c..eef2b72c1 100644 --- a/api-ref/source/v2/samples/floatingips/floatingip-disassociate-response.json +++ b/api-ref/source/v2/samples/floatingips/floatingip-disassociate-response.json @@ -12,6 +12,7 @@ "description": "for test", "created_at": "2016-12-21T10:55:50Z", "updated_at": "2016-12-22T03:13:49Z", - "revision_number": 3 + "revision_number": 3, + "port_details": null } } diff --git a/api-ref/source/v2/samples/floatingips/floatingip-show-response.json b/api-ref/source/v2/samples/floatingips/floatingip-show-response.json index 6c3b7b880..aafb4cb7d 100644 --- a/api-ref/source/v2/samples/floatingips/floatingip-show-response.json +++ b/api-ref/source/v2/samples/floatingips/floatingip-show-response.json @@ -14,6 +14,15 @@ "dns_name": "myfip", "created_at": "2016-12-21T01:36:04Z", "updated_at": "2016-12-21T01:36:04Z", - "revision_number": 1 + "revision_number": 1, + "port_details": { + "status": "ACTIVE", + "name": "", + "admin_state_up": true, + "network_id": "02dd8479-ef26-4398-a102-d19d0a7b3a1f", + "device_owner": "compute:nova", + "mac_address": "fa:16:3e:b1:3b:30", + "device_id": "8e3941b4-a6e9-499f-a1ac-2a4662025cba" + } } } diff --git a/api-ref/source/v2/samples/floatingips/floatingip-update-response.json b/api-ref/source/v2/samples/floatingips/floatingip-update-response.json index 60cf206d2..6432d2b2a 100644 --- a/api-ref/source/v2/samples/floatingips/floatingip-update-response.json +++ b/api-ref/source/v2/samples/floatingips/floatingip-update-response.json @@ -14,6 +14,15 @@ "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f", "status": "ACTIVE", "tenant_id": "4969c491a3c74ee4af974e6d800c62de", - "updated_at": "2016-12-22T03:13:49Z" + "updated_at": "2016-12-22T03:13:49Z", + "port_details": { + "status": "ACTIVE", + "name": "", + "admin_state_up": true, + "network_id": "02dd8479-ef26-4398-a102-d19d0a7b3a1f", + "device_owner": "compute:nova", + "mac_address": "fa:16:3e:b1:3b:30", + "device_id": "8e3941b4-a6e9-499f-a1ac-2a4662025cba" + } } -} \ No newline at end of file +} diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index f7b99ee0a..c8fce30d7 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -28,6 +28,7 @@ from neutron_lib.api.definitions import external_net from neutron_lib.api.definitions import extra_dhcp_opt from neutron_lib.api.definitions import extraroute from neutron_lib.api.definitions import fip64 +from neutron_lib.api.definitions import fip_port_details from neutron_lib.api.definitions import firewall from neutron_lib.api.definitions import firewall_v2 from neutron_lib.api.definitions import firewallrouterinsertion @@ -100,6 +101,7 @@ _ALL_API_DEFINITIONS = { firewall, firewall_v2, firewallrouterinsertion, + fip_port_details, flavors, ip_allocation, ip_substring_port_filtering, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index 68d4c1d1f..d5f8c9a41 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -90,6 +90,7 @@ KNOWN_EXTENSIONS = ( 'external-net', 'extra_dhcp_opt', 'extraroute', + 'fip-port-details', 'flavors', 'ip-substring-filtering', 'l3-ha', diff --git a/neutron_lib/api/definitions/fip_port_details.py b/neutron_lib/api/definitions/fip_port_details.py new file mode 100644 index 000000000..a13c9c2c0 --- /dev/null +++ b/neutron_lib/api/definitions/fip_port_details.py @@ -0,0 +1,38 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron_lib.api.definitions import l3 +from neutron_lib import constants + + +PORT_DETAILS = 'port_details' + +ALIAS = 'fip-port-details' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Floating IP Port Details Extension' +DESCRIPTION = 'Add port_details attribute to Floating IP resource' +UPDATED_TIMESTAMP = '2018-04-09T10:00:00-00:00' +RESOURCE_ATTRIBUTE_MAP = { + l3.FLOATINGIPS: { + PORT_DETAILS: { + 'allow_post': False, 'allow_put': False, + 'default': constants.ATTR_NOT_SPECIFIED, + 'is_visible': True + } + } +} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [l3.ALIAS] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_fip_port_details.py b/neutron_lib/tests/unit/api/definitions/test_fip_port_details.py new file mode 100644 index 000000000..981df2144 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_fip_port_details.py @@ -0,0 +1,21 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron_lib.api.definitions import fip_port_details +from neutron_lib.api.definitions import l3 +from neutron_lib.tests.unit.api.definitions import base + + +class FipPortDetailsDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = fip_port_details + extension_resources = (l3.FLOATINGIPS,) + extension_attributes = (fip_port_details.PORT_DETAILS,) diff --git a/releasenotes/notes/add-port_details-to-floatingip-a2a3c95cc54737ac.yaml b/releasenotes/notes/add-port_details-to-floatingip-a2a3c95cc54737ac.yaml new file mode 100644 index 000000000..536ab988f --- /dev/null +++ b/releasenotes/notes/add-port_details-to-floatingip-a2a3c95cc54737ac.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add ``fip-port-details`` API extension. This extension add ``port_details`` + attribute to the Floating IP resource.