Add API extension fip-port-details

This extension adds 'port_details' attribute to the floating IP resource.
Neutron patch: https://review.openstack.org/#/c/533327/

Change-Id: I568d07a778609cfd2a0ff72057be3f47a9aa8a0a
Partial-Bug: #1723026
This commit is contained in:
Hongbin Lu 2018-01-17 18:55:00 +00:00
parent 88c92b8468
commit 24a0877d1d
12 changed files with 134 additions and 7 deletions

View File

@ -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
----------------

View File

@ -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

View File

@ -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
}
]
}

View File

@ -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"
}
}
}

View File

@ -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
}
}

View File

@ -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"
}
}
}

View File

@ -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"
}
}
}
}

View File

@ -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,

View File

@ -90,6 +90,7 @@ KNOWN_EXTENSIONS = (
'external-net',
'extra_dhcp_opt',
'extraroute',
'fip-port-details',
'flavors',
'ip-substring-filtering',
'l3-ha',

View File

@ -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 = {}

View File

@ -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,)

View File

@ -0,0 +1,5 @@
---
features:
- |
Add ``fip-port-details`` API extension. This extension add ``port_details``
attribute to the Floating IP resource.