Skip to content

Commit 7481ead

Browse files
authored
[Network] Fix #31294: az network vnet update: Refine processing logic of --address-prefixes (#31365)
1 parent f0643c2 commit 7481ead

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
147147
_args_schema.ipam_pool_prefix_allocations = AAZListArg(
148148
options=["--ipam-allocations", "--ipam-pool-prefix-allocations"],
149149
arg_group="AddressSpace",
150-
help="A list of IPAM Pools allocating IP address prefixes. If provided, --address-prefixes would be empty and should not be specified.",
150+
help="A list of IPAM Pools allocating IP address prefixes. If provided, --address-prefixes would be ignored and should not be specified.",
151151
)
152152

153153
ipam_pool_prefix_allocations = cls._args_schema.ipam_pool_prefix_allocations

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_list.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
5757

5858
def _execute_operations(self):
5959
self.pre_operations()
60-
condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True
61-
condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id)
60+
condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id)
61+
condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True
6262
if condition_0:
63-
self.VirtualNetworksListAll(ctx=self.ctx)()
64-
if condition_1:
6563
self.VirtualNetworksList(ctx=self.ctx)()
64+
if condition_1:
65+
self.VirtualNetworksListAll(ctx=self.ctx)()
6666
self.post_operations()
6767

6868
@register_callback
@@ -78,7 +78,7 @@ def _output(self, *args, **kwargs):
7878
next_link = self.deserialize_output(self.ctx.vars.instance.next_link)
7979
return result, next_link
8080

81-
class VirtualNetworksListAll(AAZHttpOperation):
81+
class VirtualNetworksList(AAZHttpOperation):
8282
CLIENT_TYPE = "MgmtClient"
8383

8484
def __call__(self, *args, **kwargs):
@@ -92,7 +92,7 @@ def __call__(self, *args, **kwargs):
9292
@property
9393
def url(self):
9494
return self.client.format_url(
95-
"/subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualNetworks",
95+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks",
9696
**self.url_parameters
9797
)
9898

@@ -107,6 +107,10 @@ def error_format(self):
107107
@property
108108
def url_parameters(self):
109109
parameters = {
110+
**self.serialize_url_param(
111+
"resourceGroupName", self.ctx.args.resource_group,
112+
required=True,
113+
),
110114
**self.serialize_url_param(
111115
"subscriptionId", self.ctx.subscription_id,
112116
required=True,
@@ -376,7 +380,7 @@ def _build_schema_on_200(cls):
376380

377381
return cls._schema_on_200
378382

379-
class VirtualNetworksList(AAZHttpOperation):
383+
class VirtualNetworksListAll(AAZHttpOperation):
380384
CLIENT_TYPE = "MgmtClient"
381385

382386
def __call__(self, *args, **kwargs):
@@ -390,7 +394,7 @@ def __call__(self, *args, **kwargs):
390394
@property
391395
def url(self):
392396
return self.client.format_url(
393-
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks",
397+
"/subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualNetworks",
394398
**self.url_parameters
395399
)
396400

@@ -405,10 +409,6 @@ def error_format(self):
405409
@property
406410
def url_parameters(self):
407411
parameters = {
408-
**self.serialize_url_param(
409-
"resourceGroupName", self.ctx.args.resource_group,
410-
required=True,
411-
),
412412
**self.serialize_url_param(
413413
"subscriptionId", self.ctx.subscription_id,
414414
required=True,

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
129129
_args_schema.ipam_pool_prefix_allocations = AAZListArg(
130130
options=["--ipam-allocations", "--ipam-pool-prefix-allocations"],
131131
arg_group="AddressSpace",
132-
help="A list of IPAM Pools allocating IP address prefixes. If provided, --address-prefixes would be empty and should not be specified.",
132+
help="A list of IPAM Pools allocating IP address prefixes. If a non-empty value is provided, --address-prefixes would be ignored.",
133133
nullable=True,
134134
)
135135

src/azure-cli/azure/cli/command_modules/network/custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5575,7 +5575,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
55755575

55765576
def pre_operations(self):
55775577
args = self.ctx.args
5578-
if has_value(args.ipam_pool_prefix_allocations):
5578+
if args.ipam_pool_prefix_allocations.to_serialized_data():
55795579
args.address_prefixes = []
55805580

55815581
def post_instance_update(self, instance):

0 commit comments

Comments
 (0)