Skip to content

Commit 28ce299

Browse files
authored
[Network] az network vnet peering: Refine command interface of subnet peering (Azure#29817)
* chore: refine command interface * fix: resolve linter issue * test: add case and recording
1 parent 94da233 commit 28ce299

File tree

5 files changed

+444
-243
lines changed

5 files changed

+444
-243
lines changed

linter_exclusions.yml

+8
Original file line numberDiff line numberDiff line change
@@ -2754,6 +2754,14 @@ network vnet peering create:
27542754
allow_gateway_transit:
27552755
rule_exclusions:
27562756
- option_length_too_long
2757+
network vnet peering update:
2758+
parameters:
2759+
allow_forwarded_traffic:
2760+
rule_exclusions:
2761+
- option_length_too_long
2762+
allow_gateway_transit:
2763+
rule_exclusions:
2764+
- option_length_too_long
27572765
network vnet subnet create:
27582766
parameters:
27592767
service_endpoint_policy:

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

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
9191
_args_schema.peer_complete_vnets = AAZBoolArg(
9292
options=["--peer-complete-vnets"],
9393
help="Whether complete virtual network address space is peered.",
94+
default=True,
9495
)
9596
_args_schema.remote_subnet_names = AAZListArg(
9697
options=["--remote-subnet-names"],

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

+84-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"network vnet peering update",
1616
)
1717
class Update(AAZCommand):
18-
"""Update a peering.
18+
"""Update a peering in the specified virtual network.
1919
2020
:example: Change forwarded traffic configuration of a virtual network peering.
2121
az network vnet peering update -g MyResourceGroup -n MyVnet1ToMyVnet2 --vnet-name MyVnet1 --set allowForwardedTraffic=true
@@ -71,6 +71,66 @@ def _build_arguments_schema(cls, *args, **kwargs):
7171
required=True,
7272
id_part="child_name_1",
7373
)
74+
_args_schema.sync_remote = AAZStrArg(
75+
options=["--sync-remote"],
76+
help="Parameter indicates the intention to sync the peering with the current address space on the remote vNet after it's updated.",
77+
enum={"true": "true"},
78+
)
79+
_args_schema.allow_forwarded_traffic = AAZBoolArg(
80+
options=["--allow-forwarded-traffic"],
81+
help="Allows forwarded traffic from the local VNet to the remote VNet.",
82+
nullable=True,
83+
)
84+
_args_schema.allow_gateway_transit = AAZBoolArg(
85+
options=["--allow-gateway-transit"],
86+
help="Allows gateway link to be used in the remote VNet.",
87+
nullable=True,
88+
)
89+
_args_schema.allow_vnet_access = AAZBoolArg(
90+
options=["--allow-vnet-access"],
91+
help="Allows access from the local VNet to the remote VNet.",
92+
nullable=True,
93+
)
94+
_args_schema.enable_only_ipv6 = AAZBoolArg(
95+
options=["--enable-only-ipv6"],
96+
help="Whether only Ipv6 address space is peered for subnet peering.",
97+
nullable=True,
98+
)
99+
_args_schema.local_subnet_names = AAZListArg(
100+
options=["--local-subnet-names"],
101+
help="List of local subnet names that are subnet peered with remote virtual network.",
102+
nullable=True,
103+
)
104+
_args_schema.peer_complete_vnets = AAZBoolArg(
105+
options=["--peer-complete-vnets"],
106+
help="Whether complete virtual network address space is peered.",
107+
nullable=True,
108+
)
109+
_args_schema.remote_subnet_names = AAZListArg(
110+
options=["--remote-subnet-names"],
111+
help="List of remote subnet names from remote virtual network that are subnet peered.",
112+
nullable=True,
113+
)
114+
_args_schema.remote_vnet = AAZStrArg(
115+
options=["--remote-vnet"],
116+
help="Name or ID of the remote VNet.",
117+
nullable=True,
118+
)
119+
_args_schema.use_remote_gateways = AAZBoolArg(
120+
options=["--use-remote-gateways"],
121+
help="Allows VNet to use the remote VNet's gateway. Remote VNet gateway must have --allow-gateway-transit enabled for remote peering. Only 1 peering can have this flag enabled. Cannot be set if the VNet already has a gateway.",
122+
nullable=True,
123+
)
124+
125+
local_subnet_names = cls._args_schema.local_subnet_names
126+
local_subnet_names.Element = AAZStrArg(
127+
nullable=True,
128+
)
129+
130+
remote_subnet_names = cls._args_schema.remote_subnet_names
131+
remote_subnet_names.Element = AAZStrArg(
132+
nullable=True,
133+
)
74134

75135
# define Arg Group "Properties"
76136

@@ -287,6 +347,9 @@ def url_parameters(self):
287347
@property
288348
def query_parameters(self):
289349
parameters = {
350+
**self.serialize_query_param(
351+
"syncRemoteAddressSpace", self.ctx.args.sync_remote,
352+
),
290353
**self.serialize_query_param(
291354
"api-version", "2023-11-01",
292355
required=True,
@@ -351,7 +414,27 @@ def _update_instance(self, instance):
351414

352415
properties = _builder.get(".properties")
353416
if properties is not None:
417+
properties.set_prop("allowForwardedTraffic", AAZBoolType, ".allow_forwarded_traffic")
418+
properties.set_prop("allowGatewayTransit", AAZBoolType, ".allow_gateway_transit")
419+
properties.set_prop("allowVirtualNetworkAccess", AAZBoolType, ".allow_vnet_access")
420+
properties.set_prop("enableOnlyIPv6Peering", AAZBoolType, ".enable_only_ipv6")
421+
properties.set_prop("localSubnetNames", AAZListType, ".local_subnet_names")
422+
properties.set_prop("peerCompleteVnets", AAZBoolType, ".peer_complete_vnets")
423+
properties.set_prop("remoteSubnetNames", AAZListType, ".remote_subnet_names")
354424
properties.set_prop("remoteVirtualNetwork", AAZObjectType)
425+
properties.set_prop("useRemoteGateways", AAZBoolType, ".use_remote_gateways")
426+
427+
local_subnet_names = _builder.get(".properties.localSubnetNames")
428+
if local_subnet_names is not None:
429+
local_subnet_names.set_elements(AAZStrType, ".")
430+
431+
remote_subnet_names = _builder.get(".properties.remoteSubnetNames")
432+
if remote_subnet_names is not None:
433+
remote_subnet_names.set_elements(AAZStrType, ".")
434+
435+
remote_virtual_network = _builder.get(".properties.remoteVirtualNetwork")
436+
if remote_virtual_network is not None:
437+
remote_virtual_network.set_prop("id", AAZStrType, ".remote_vnet")
355438

356439
return _instance_value
357440

0 commit comments

Comments
 (0)