Support allowed_cidrs for Octavia listener

Support ``allowed_cidrs`` property for the resource ``OS::Octavia::Listener``,
the property is allowed to be updated as well. The property 'allowed_cidrs'
was introduced in Octavia since Train release. The default value is empty
list if it is not specified in Heat template.

Task: 38952
Story: 2007378

Change-Id: I9d38716b236b0782f0d09097b7a0f615fe5be041
This commit is contained in:
Feilong Wang 2020-03-05 20:50:37 +13:00
parent 920c4877bf
commit dd29c9508c
4 changed files with 27 additions and 2 deletions

View File

@ -17,6 +17,7 @@ from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine.resources.openstack.octavia import octavia_base
from heat.engine import support
from heat.engine import translation
@ -30,11 +31,11 @@ class Listener(octavia_base.OctaviaBase):
PROPERTIES = (
PROTOCOL_PORT, PROTOCOL, LOADBALANCER, DEFAULT_POOL, NAME,
ADMIN_STATE_UP, DESCRIPTION, DEFAULT_TLS_CONTAINER_REF,
SNI_CONTAINER_REFS, CONNECTION_LIMIT, TENANT_ID
SNI_CONTAINER_REFS, CONNECTION_LIMIT, TENANT_ID, ALLOWED_CIDRS
) = (
'protocol_port', 'protocol', 'loadbalancer', 'default_pool', 'name',
'admin_state_up', 'description', 'default_tls_container_ref',
'sni_container_refs', 'connection_limit', 'tenant_id'
'sni_container_refs', 'connection_limit', 'tenant_id', 'allowed_cidrs'
)
SUPPORTED_PROTOCOLS = (TCP, HTTP, HTTPS, TERMINATED_HTTPS, PROXY, UDP) = (
@ -121,6 +122,20 @@ class Listener(octavia_base.OctaviaBase):
properties.Schema.STRING,
_('The ID of the tenant who owns the listener.')
),
ALLOWED_CIDRS: properties.Schema(
properties.Schema.LIST,
_('A list of IPv4, IPv6 or mix of both CIDRs. The default is all '
'allowed. When a list of CIDRs is provided, the default '
'switches to deny all.'),
update_allowed=True,
schema=properties.Schema(
properties.Schema.STRING,
constraints=[
constraints.CustomConstraint('net_cidr')
]
),
support_status=support.SupportStatus(version='14.0.0'),
)
}
attributes_schema = {

View File

@ -48,6 +48,9 @@ resources:
- ref2
connection_limit: -1
tenant_id: 1234
allowed_cidrs:
- 10.10.0.0/16
- 192.168.0.0/16
'''
POOL_TEMPLATE = '''

View File

@ -75,6 +75,7 @@ class ListenerTest(common.HeatTestCase):
'sni_container_refs': ['ref1', 'ref2'],
'connection_limit': -1,
'tenant_id': '1234',
'allowed_cidrs': ['10.10.0.0/16', '192.168.0.0/16']
}
}

View File

@ -0,0 +1,6 @@
---
features:
- Support ``allowed_cidrs`` property for the resource
``OS::Octavia::Listener``, the property is allowed to be updated as well.
The property 'allowed_cidrs' was introduced in Octavia since Train release.
The default value is empty list if it is not specified in Heat template.