support "tenant_id" property in provider_net and router

Currently, OS::Neutron::ProviderNet and OS::Neutron::Router do not
support the property tenant_id. Supporting this field can enable an
admin user to create physnet and router for non-admin users.

Change-Id: I451f73098ee8af9b562fe19fae8a92cfb2d8a5d0
This commit is contained in:
Suiong Ng
2024-12-25 13:39:38 +08:00
committed by Takashi Kajinami
parent 042bed8044
commit 8a02abd8af
4 changed files with 27 additions and 5 deletions

View File

@@ -38,13 +38,12 @@ class ProviderNet(net.Net):
NAME, PROVIDER_NETWORK_TYPE, PROVIDER_PHYSICAL_NETWORK,
PROVIDER_SEGMENTATION_ID, ADMIN_STATE_UP, SHARED,
PORT_SECURITY_ENABLED, ROUTER_EXTERNAL, DNS_DOMAIN,
AVAILABILITY_ZONE_HINTS, TAGS,
AVAILABILITY_ZONE_HINTS, TAGS, TENANT_ID,
) = (
'name', 'network_type', 'physical_network',
'segmentation_id', 'admin_state_up', 'shared',
'port_security_enabled', 'router_external', 'dns_domain',
'availability_zone_hints', 'tags',
'availability_zone_hints', 'tags', 'tenant_id',
)
ATTRIBUTES = (
@@ -128,6 +127,13 @@ class ProviderNet(net.Net):
update_allowed=True,
support_status=support.SupportStatus(version='19.0.0')
),
TENANT_ID: properties.Schema(
properties.Schema.STRING,
_('The ID of the tenant which will own the provider network. Only '
'administrative users can set the tenant identifier; this '
'cannot be changed using authorization policies.'),
support_status=support.SupportStatus(version='24.0.0')
),
}
attributes_schema = {

View File

@@ -36,11 +36,11 @@ class Router(neutron.NeutronResource):
PROPERTIES = (
NAME, EXTERNAL_GATEWAY, VALUE_SPECS, ADMIN_STATE_UP,
L3_AGENT_ID, L3_AGENT_IDS, DISTRIBUTED, HA, AVAILABILITY_ZONE_HINTS,
TAGS,
TAGS, TENANT_ID,
) = (
'name', 'external_gateway_info', 'value_specs', 'admin_state_up',
'l3_agent_id', 'l3_agent_ids', 'distributed', 'ha',
'availability_zone_hints', 'tags',
'availability_zone_hints', 'tags', 'tenant_id',
)
_EXTERNAL_GATEWAY_KEYS = (
@@ -187,6 +187,13 @@ class Router(neutron.NeutronResource):
update_allowed=True,
support_status=support.SupportStatus(version='9.0.0')
),
TENANT_ID: properties.Schema(
properties.Schema.STRING,
_('The ID of the tenant which will own the router. Only '
'administrative users can set the tenant identifier; this '
'cannot be changed using authorization policies.'),
support_status=support.SupportStatus(version='24.0.0')
),
}
attributes_schema = {

View File

@@ -251,6 +251,7 @@ class NeutronProviderNetTest(common.HeatTestCase):
'router_external': False,
'availability_zone_hints': [],
'tags': ['tag1', 'tag2'],
'tenant_id': 'df49ea64e87c43a792a510698364f03e',
}
self.assertEqual(expected, reality)

View File

@@ -0,0 +1,8 @@
---
features:
- |
Added the ``tenant_id`` property to the following resources. This property
allows admin users to create these resources in specific tenants.
- ``OS::Neutron::ProviderNet``
- ``OS::Neutron::Router``