Merge "Tweak trunk extension to support Ironic use case"
This commit is contained in:
commit
485928f654
@ -95,6 +95,8 @@ REQUIRED_EXTENSIONS = [
|
||||
]
|
||||
|
||||
# The list of optional extensions.
|
||||
OPTIONAL_EXTENSIONS = None
|
||||
OPTIONAL_EXTENSIONS = [
|
||||
"provider", # needed to learn about network segmentation details.
|
||||
]
|
||||
|
||||
# TODO(armax): add support for modeling custom queries
|
||||
|
@ -924,12 +924,15 @@ def validate_subports(data, valid_values=None):
|
||||
return msg
|
||||
subport_ids.add(subport["port_id"])
|
||||
|
||||
# Validate that both segmentation id and segmentation type are
|
||||
# Validate that both segmentation ID and segmentation type are
|
||||
# specified, and that the client does not duplicate segmentation
|
||||
# ids
|
||||
segmentation_id = subport.get("segmentation_id")
|
||||
# IDs (unless it is explicitly asked to inherit segmentation
|
||||
# details from the underlying subport's network).
|
||||
segmentation_type = subport.get("segmentation_type")
|
||||
if (not segmentation_id or not segmentation_type) and len(subport) > 1:
|
||||
if segmentation_type == 'inherit':
|
||||
return
|
||||
segmentation_id = subport.get("segmentation_id")
|
||||
if (not segmentation_type or not segmentation_id) and len(subport) > 1:
|
||||
msg = _("Invalid subport details '%s': missing segmentation "
|
||||
"information. Must specify both segmentation_id and "
|
||||
"segmentation_type") % subport
|
||||
|
@ -1013,6 +1013,13 @@ class TestAttributeValidation(base.BaseTestCase):
|
||||
]
|
||||
self.assertIsNotNone(validators.validate_subports(body))
|
||||
|
||||
def test_validate_subports_inherit_segmentation_details(self):
|
||||
body = [
|
||||
{'port_id': '00000000-ffff-ffff-ffff-000000000000',
|
||||
'segmentation_type': 'inherit'}
|
||||
]
|
||||
self.assertIsNone(validators.validate_subports(body))
|
||||
|
||||
def test_validate_subports_valid_unique_segmentation_id(self):
|
||||
body = [
|
||||
{'port_id': '00000000-ffff-ffff-ffff-000000000000',
|
||||
|
Loading…
Reference in New Issue
Block a user