Add 'dns_publish_fixed_ip' attribute to Subnet

Add a new attribute ``dns_publish_fixed_ip`` into ``subnet``
resource. This attribute will be used to indicate whether to publish DNS
records for fixed IPs from this subnet.

Neutron patch: https://review.opendev.org/662409

Thanks go to [0] which I took as a reference to create this patch.

[0] I1371fc0b47c0015423e4346ffd43d39c8264b1a3

Change-Id: I08ef19fcc06559c92ae3f8e6e66c5fd896815232
Partial-Bug: 1784879
This commit is contained in:
Jens Harbott 2019-05-24 13:39:24 +00:00 committed by Slawek Kaplonski
parent cc975851a5
commit 56e0979fdd
12 changed files with 157 additions and 1 deletions

View File

@ -1274,9 +1274,16 @@ state-query:
in: query
required: false
type: string
subnet-dns_publish_fixed_ip-query:
description: |
Filter the subnet list result based on if ``dns_publish_fixed_ip`` is
enabled or disabled for the subnet.
in: query
required: false
type: boolean
subnet-enable_dhcp-query:
description: |
Filter the subnet list result based on if is enabled or disabled
Filter the subnet list result based on if DHCP is enabled or disabled
for the subnet.
in: query
required: false
@ -5984,6 +5991,19 @@ subnet-dns_nameservers-request:
in: body
required: false
type: array
subnet-dns_publish_fixed_ip:
description: |
Whether to publish DNS records for IPs from this subnet.
in: body
required: true
type: boolean
subnet-dns_publish_fixed_ip-request:
description: |
Whether to publish DNS records for IPs from this subnet. Default
is ``false``.
in: body
required: false
type: boolean
subnet-enable_dhcp:
description: |
Indicates whether dhcp is enabled or disabled

View File

@ -7,6 +7,7 @@
"project_id": "4fd44f30292945e481c7b8a0c8908869",
"tenant_id": "4fd44f30292945e481c7b8a0c8908869",
"dns_nameservers": [],
"dns_publish_fixed_ip": false,
"allocation_pools": [
{
"start": "192.168.199.2",

View File

@ -8,6 +8,7 @@
"tenant_id": "4fd44f30292945e481c7b8a0c8908869",
"created_at": "2016-03-08T20:19:41",
"dns_nameservers": [],
"dns_publish_fixed_ip": false,
"allocation_pools": [
{
"start": "192.0.0.2",

View File

@ -9,6 +9,7 @@
"tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
"created_at": "2016-03-08T20:19:41",
"dns_nameservers": [],
"dns_publish_fixed_ip": false,
"service_types": [],
"allocation_pools": [
{

View File

@ -9,6 +9,7 @@
],
"cidr": "192.168.199.0/24",
"dns_nameservers": [],
"dns_publish_fixed_ip": false,
"enable_dhcp": true,
"gateway_ip": "192.168.199.1",
"host_routes": [],
@ -38,6 +39,7 @@
],
"cidr": "10.56.4.0/22",
"dns_nameservers": [],
"dns_publish_fixed_ip": false,
"enable_dhcp": true,
"gateway_ip": "10.56.4.1",
"host_routes": [],

View File

@ -8,6 +8,7 @@
"project_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
"tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
"dns_nameservers": [],
"dns_publish_fixed_ip": false,
"allocation_pools": [
{
"start": "10.0.0.2",
@ -37,6 +38,7 @@
"project_id": "4fd44f30292945e481c7b8a0c8908869",
"tenant_id": "4fd44f30292945e481c7b8a0c8908869",
"dns_nameservers": [],
"dns_publish_fixed_ip": false,
"allocation_pools": [
{
"start": "192.0.0.2",

View File

@ -28,6 +28,13 @@ Subnet allocation extension
Subnet allocation extension (``subnet_allocation``) enables allocation of
subnets from a subnet pool.
Subnet DNS publish fixed IP extension
=====================================
The ``subnet-dns-publish-fixed-ip`` extension adds the ``dns_publish_fixed_ip``
attribute to subnets. It allows to select per subnet whether DNS records
for fixed IPs are to be published in an external DNS service.
Segment extension
=================
@ -126,6 +133,7 @@ Request
- tags-any: tags-any-query
- not-tags: not-tags-query
- not-tags-any: not-tags-any-query
- dns_publish_fixed_ip: subnet-dns_publish_fixed_ip-query
- fields: fields
Response Parameters
@ -156,6 +164,7 @@ Response Parameters
- subnetpool_id: subnet-subnetpool_id
- updated_at: updated_at_resource
- tags: tags
- dns_publish_fixed_ip: subnet-dns_publish_fixed_ip
Response Example
----------------
@ -235,6 +244,7 @@ Request
- subnetpool_id: subnet-subnetpool_id-request
- use_default_subnetpool: use_default_subnetpool
- service_types: subnet-service_types-optional
- dns_publish_fixed_ip: subnet-dns_publish_fixed_ip-request
Request Example
---------------
@ -270,6 +280,7 @@ Response Parameters
- segment_id: subnet-segment_id
- updated_at: updated_at_resource
- tags: tags
- dns_publish_fixed_ip: subnet-dns_publish_fixed_ip
Response Example
----------------
@ -316,6 +327,7 @@ Request
- subnetpool_id: subnet-subnetpool_id-request
- use_default_subnetpool: use_default_subnetpool
- service_types: subnet-service_types-optional
- dns_publish_fixed_ip: subnet-dns_publish_fixed_ip-request
Request Example
---------------
@ -351,6 +363,7 @@ Response Parameters
- subnetpool_id: subnet-subnetpool_id
- updated_at: updated_at_resource
- tags: tags
- dns_publish_fixed_ip: subnet-dns_publish_fixed_ip
Response Example
----------------
@ -406,6 +419,7 @@ Response Parameters
- service_types: subnet-service_types
- subnetpool_id: subnet-subnetpool_id
- tags: tags
- dns_publish_fixed_ip: subnet-dns_publish_fixed_ip
Response Example
----------------
@ -443,6 +457,7 @@ Request
- description: description-request
- service_types: subnet-service_types-optional
- segment_id: subnet-segment_id-request
- dns_publish_fixed_ip: subnet-dns_publish_fixed_ip-request
Request Example
---------------
@ -478,6 +493,7 @@ Response Parameters
- subnetpool_id: subnet-subnetpool_id
- updated_at: updated_at_resource
- tags: tags
- dns_publish_fixed_ip: subnet-dns_publish_fixed_ip
Response Example
----------------

View File

@ -98,6 +98,7 @@ from neutron_lib.api.definitions import sort_key_validation
from neutron_lib.api.definitions import sorting
from neutron_lib.api.definitions import standard_attr_segment
from neutron_lib.api.definitions import subnet
from neutron_lib.api.definitions import subnet_dns_publish_fixed_ip
from neutron_lib.api.definitions import subnet_onboard
from neutron_lib.api.definitions import subnet_segmentid_enforce
from neutron_lib.api.definitions import subnet_segmentid_writable
@ -202,6 +203,7 @@ _ALL_API_DEFINITIONS = {
sorting,
standard_attr_segment,
subnet,
subnet_dns_publish_fixed_ip,
subnet_onboard,
subnet_segmentid_enforce,
subnet_segmentid_writable,

View File

@ -140,6 +140,7 @@ KNOWN_EXTENSIONS = (
'standard-attr-timestamp',
'subnet',
'subnet_allocation',
'subnet_dns_publish_fixed_ip',
'subnet_onboard',
'subnetpool-prefix-ops',
'subnet-segmentid-enforce',

View File

@ -0,0 +1,81 @@
# 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 import converters
from neutron_lib.api.definitions import dns
from neutron_lib.api.definitions import subnet
DNS_PUBLISH_FIXED_IP = 'dns_publish_fixed_ip'
# The alias of the extension.
ALIAS = 'subnet-dns-publish-fixed-ip'
# Whether or not this extension is simply signaling behavior to the user
# or it actively modifies the attribute map.
IS_SHIM_EXTENSION = False
# Whether the extension is marking the adoption of standardattr model for
# legacy resources, or introducing new standardattr attributes. False or
# None if the standardattr model is adopted since the introduction of
# resource extension.
# If this is True, the alias for the extension should be prefixed with
# 'standard-attr-'.
IS_STANDARD_ATTR_EXTENSION = False
# The name of the extension.
NAME = 'Subnet DNS publish fixed IP'
# The description of the extension.
DESCRIPTION = 'Support choosing to publish DNS records for IPs from a subnet'
# A timestamp of when the extension was introduced.
UPDATED_TIMESTAMP = "2019-05-24T10:00:00-00:00"
# The name of the resource introduced or being extended.
RESOURCE_NAME = subnet.RESOURCE_NAME
# The plural for the resource introduced or being extended.
COLLECTION_NAME = subnet.COLLECTION_NAME
# The resource attribute map for the extension.
RESOURCE_ATTRIBUTE_MAP = {
COLLECTION_NAME: {
DNS_PUBLISH_FIXED_IP: {
'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True
}
}
}
# The subresource attribute map for the extension.
SUB_RESOURCE_ATTRIBUTE_MAP = {
}
# The action map.
ACTION_MAP = {
}
# The action status.
ACTION_STATUS = {
}
# The list of required extensions.
REQUIRED_EXTENSIONS = [
dns.ALIAS,
subnet.ALIAS
]
# The list of optional extensions.
OPTIONAL_EXTENSIONS = [
]

View File

@ -0,0 +1,21 @@
# Copyright (c) 2019 x-ion GmbH. All rights reserved.
#
# 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 subnet_dns_publish_fixed_ip as sn
from neutron_lib.tests.unit.api.definitions import base
class SubnetDNSPublishFixedIpTestCase(base.DefinitionBaseTestCase):
extension_module = sn
extension_attributes = (sn.DNS_PUBLISH_FIXED_IP,)

View File

@ -0,0 +1,8 @@
---
features:
- |
The ``subnet-dns-publish-fixed-ip`` API extension is added. It adds the
``dns_publish_fixed_ip`` attribute to subnets, indicating whether
to publish DNS records for fixed IPs from this subnet in an external
DNS service. For details see
[`bug 1784879 <https://launchpad.net/bugs/1784879>`_].