From 71d3962b8e0739f152767779d7c646ad4962e9f5 Mon Sep 17 00:00:00 2001 From: "RuiJun Hu (MSFT)" Date: Sun, 27 Apr 2025 13:07:12 +0800 Subject: [PATCH] fix address prefixes processing --- .../aaz/latest/network/vnet/_create.py | 2 +- .../network/aaz/latest/network/vnet/_list.py | 24 +++++++++---------- .../aaz/latest/network/vnet/_update.py | 2 +- .../cli/command_modules/network/custom.py | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_create.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_create.py index 748deda30cb..61bb9592dcb 100644 --- a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_create.py +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_create.py @@ -147,7 +147,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema.ipam_pool_prefix_allocations = AAZListArg( options=["--ipam-allocations", "--ipam-pool-prefix-allocations"], arg_group="AddressSpace", - help="A list of IPAM Pools allocating IP address prefixes. If provided, --address-prefixes would be empty and should not be specified.", + help="A list of IPAM Pools allocating IP address prefixes. If provided, --address-prefixes would be ignored and should not be specified.", ) ipam_pool_prefix_allocations = cls._args_schema.ipam_pool_prefix_allocations diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_list.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_list.py index f8c52aeae5f..1d799ff95b8 100644 --- a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_list.py +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_list.py @@ -57,12 +57,12 @@ def _build_arguments_schema(cls, *args, **kwargs): def _execute_operations(self): self.pre_operations() - condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True - condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True if condition_0: - self.VirtualNetworksListAll(ctx=self.ctx)() - if condition_1: self.VirtualNetworksList(ctx=self.ctx)() + if condition_1: + self.VirtualNetworksListAll(ctx=self.ctx)() self.post_operations() @register_callback @@ -78,7 +78,7 @@ def _output(self, *args, **kwargs): next_link = self.deserialize_output(self.ctx.vars.instance.next_link) return result, next_link - class VirtualNetworksListAll(AAZHttpOperation): + class VirtualNetworksList(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -92,7 +92,7 @@ def __call__(self, *args, **kwargs): @property def url(self): return self.client.format_url( - "/subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualNetworks", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks", **self.url_parameters ) @@ -107,6 +107,10 @@ def error_format(self): @property def url_parameters(self): parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), **self.serialize_url_param( "subscriptionId", self.ctx.subscription_id, required=True, @@ -376,7 +380,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 - class VirtualNetworksList(AAZHttpOperation): + class VirtualNetworksListAll(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -390,7 +394,7 @@ def __call__(self, *args, **kwargs): @property def url(self): return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks", + "/subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualNetworks", **self.url_parameters ) @@ -405,10 +409,6 @@ def error_format(self): @property def url_parameters(self): parameters = { - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), **self.serialize_url_param( "subscriptionId", self.ctx.subscription_id, required=True, diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_update.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_update.py index 86fcefdec58..b6602216fd7 100644 --- a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_update.py +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_update.py @@ -129,7 +129,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema.ipam_pool_prefix_allocations = AAZListArg( options=["--ipam-allocations", "--ipam-pool-prefix-allocations"], arg_group="AddressSpace", - help="A list of IPAM Pools allocating IP address prefixes. If provided, --address-prefixes would be empty and should not be specified.", + help="A list of IPAM Pools allocating IP address prefixes. If a non-empty value is provided, --address-prefixes would be ignored.", nullable=True, ) diff --git a/src/azure-cli/azure/cli/command_modules/network/custom.py b/src/azure-cli/azure/cli/command_modules/network/custom.py index c09e34ce733..03f113cf257 100644 --- a/src/azure-cli/azure/cli/command_modules/network/custom.py +++ b/src/azure-cli/azure/cli/command_modules/network/custom.py @@ -5575,7 +5575,7 @@ def _build_arguments_schema(cls, *args, **kwargs): def pre_operations(self): args = self.ctx.args - if has_value(args.ipam_pool_prefix_allocations): + if args.ipam_pool_prefix_allocations.to_serialized_data(): args.address_prefixes = [] def post_instance_update(self, instance):