Merge "Validation: Cannot create network with segmentation id alone"

This commit is contained in:
Zuul
2025-09-11 17:49:10 +00:00
committed by Gerrit Code Review
2 changed files with 27 additions and 0 deletions

View File

@@ -401,6 +401,16 @@ class CreateNetwork(
)
raise exceptions.CommandError(msg)
if (
parsed_args.segmentation_id
and not parsed_args.provider_network_type
):
msg = _(
"--provider-segment requires --provider-network-type "
"to be specified."
)
raise exceptions.CommandError(msg)
attrs.update(
self._parse_extra_properties(parsed_args.extra_properties)
)

View File

@@ -330,6 +330,23 @@ class TestCreateNetworkIdentityV3(TestNetwork):
exceptions.CommandError, self.cmd.take_action, parsed_args
)
def test_create_with_provider_segment_without_provider_type(self):
arglist = [
"--provider-segment",
"123",
self._network.name,
]
verifylist = [
('provider_network_type', None),
('segmentation_id', "123"),
('name', self._network.name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaises(
exceptions.CommandError, self.cmd.take_action, parsed_args
)
class TestCreateNetworkIdentityV2(
identity_fakes_v2.FakeClientMixin,