Skip to content

Commit 643ee40

Browse files
authored
[Network] az network vnet-gateway migration: Support vpn gateway migration feature (#31429)
1 parent 5b614e8 commit 643ee40

File tree

13 files changed

+4153
-1
lines changed

13 files changed

+4153
-1
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
9090
)
9191
_args_schema.enable_high_bandwidth_vpn_gateway = AAZBoolArg(
9292
options=["--enable-high-bandwidth", "--enable-high-bandwidth-vpn-gateway"],
93-
help="To enable high-bandwidth Advanced Connectivity feature for VPN gateway",
93+
help="To enable Advanced Connectivity feature for VPN gateway",
9494
)
9595
_args_schema.enable_private_ip = AAZBoolArg(
9696
options=["--enable-private-ip"],
@@ -328,6 +328,27 @@ def _build_arguments_schema(cls, *args, **kwargs):
328328
help="Gateway SKU tier.",
329329
enum={"Basic": "Basic", "ErGw1AZ": "ErGw1AZ", "ErGw2AZ": "ErGw2AZ", "ErGw3AZ": "ErGw3AZ", "ErGwScale": "ErGwScale", "HighPerformance": "HighPerformance", "Standard": "Standard", "UltraPerformance": "UltraPerformance", "VpnGw1": "VpnGw1", "VpnGw1AZ": "VpnGw1AZ", "VpnGw2": "VpnGw2", "VpnGw2AZ": "VpnGw2AZ", "VpnGw3": "VpnGw3", "VpnGw3AZ": "VpnGw3AZ", "VpnGw4": "VpnGw4", "VpnGw4AZ": "VpnGw4AZ", "VpnGw5": "VpnGw5", "VpnGw5AZ": "VpnGw5AZ"},
330330
)
331+
_args_schema.virtual_network_gateway_migration_status = AAZObjectArg(
332+
options=["--virtual-network-gateway-migration-status"],
333+
arg_group="Properties",
334+
help="The reference to the VirtualNetworkGatewayMigrationStatus which represents the status of migration.",
335+
)
336+
337+
virtual_network_gateway_migration_status = cls._args_schema.virtual_network_gateway_migration_status
338+
virtual_network_gateway_migration_status.error_message = AAZStrArg(
339+
options=["error-message"],
340+
help="Error if any occurs during migration.",
341+
)
342+
virtual_network_gateway_migration_status.phase = AAZStrArg(
343+
options=["phase"],
344+
help="Represent the current migration phase of gateway.",
345+
enum={"Abort": "Abort", "AbortSucceeded": "AbortSucceeded", "Commit": "Commit", "CommitSucceeded": "CommitSucceeded", "Execute": "Execute", "ExecuteSucceeded": "ExecuteSucceeded", "None": "None", "Prepare": "Prepare", "PrepareSucceeded": "PrepareSucceeded"},
346+
)
347+
virtual_network_gateway_migration_status.state = AAZStrArg(
348+
options=["state"],
349+
help="Represent the current state of gateway migration.",
350+
enum={"Failed": "Failed", "InProgress": "InProgress", "None": "None", "Succeeded": "Succeeded"},
351+
)
331352

332353
# define Arg Group "Root Cert Authentication"
333354

@@ -579,6 +600,7 @@ def content(self):
579600
properties.set_prop("resiliencyModel", AAZStrType, ".resiliency_model")
580601
properties.set_prop("sku", AAZObjectType)
581602
properties.set_prop("vNetExtendedLocationResourceId", AAZStrType, ".edge_zone_vnet_id")
603+
properties.set_prop("virtualNetworkGatewayMigrationStatus", AAZObjectType, ".virtual_network_gateway_migration_status")
582604
properties.set_prop("vpnClientConfiguration", AAZObjectType)
583605
properties.set_prop("vpnGatewayGeneration", AAZStrType, ".vpn_gateway_generation")
584606
properties.set_prop("vpnType", AAZStrType, ".vpn_type")
@@ -672,6 +694,12 @@ def content(self):
672694
sku.set_prop("name", AAZStrType, ".sku")
673695
sku.set_prop("tier", AAZStrType, ".sku_tier")
674696

697+
virtual_network_gateway_migration_status = _builder.get(".properties.virtualNetworkGatewayMigrationStatus")
698+
if virtual_network_gateway_migration_status is not None:
699+
virtual_network_gateway_migration_status.set_prop("errorMessage", AAZStrType, ".error_message")
700+
virtual_network_gateway_migration_status.set_prop("phase", AAZStrType, ".phase")
701+
virtual_network_gateway_migration_status.set_prop("state", AAZStrType, ".state")
702+
675703
vpn_client_configuration = _builder.get(".properties.vpnClientConfiguration")
676704
if vpn_client_configuration is not None:
677705
vpn_client_configuration.set_prop("aadAudience", AAZStrType, ".aad_audience")

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
7979
help="Minimum scale units for auto-scale configuration.",
8080
nullable=True,
8181
)
82+
_args_schema.enable_high_bandwidth_vpn_gateway = AAZBoolArg(
83+
options=["--enable-high-bandwidth", "--enable-high-bandwidth-vpn-gateway"],
84+
help="To enable Advanced Connectivity feature for VPN gateway",
85+
nullable=True,
86+
)
8287
_args_schema.enable_private_ip = AAZBoolArg(
8388
options=["--enable-private-ip"],
8489
help="Whether private IP needs to be enabled on this gateway for connections or not.",
@@ -217,6 +222,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
217222
nullable=True,
218223
enum={"Basic": "Basic", "ErGw1AZ": "ErGw1AZ", "ErGw2AZ": "ErGw2AZ", "ErGw3AZ": "ErGw3AZ", "ErGwScale": "ErGwScale", "HighPerformance": "HighPerformance", "Standard": "Standard", "UltraPerformance": "UltraPerformance", "VpnGw1": "VpnGw1", "VpnGw1AZ": "VpnGw1AZ", "VpnGw2": "VpnGw2", "VpnGw2AZ": "VpnGw2AZ", "VpnGw3": "VpnGw3", "VpnGw3AZ": "VpnGw3AZ", "VpnGw4": "VpnGw4", "VpnGw4AZ": "VpnGw4AZ", "VpnGw5": "VpnGw5", "VpnGw5AZ": "VpnGw5AZ"},
219224
)
225+
_args_schema.virtual_network_gateway_migration_status = AAZObjectArg(
226+
options=["--virtual-network-gateway-migration-status"],
227+
arg_group="Properties",
228+
help="The reference to the VirtualNetworkGatewayMigrationStatus which represents the status of migration.",
229+
nullable=True,
230+
)
220231

221232
ip_configurations = cls._args_schema.ip_configurations
222233
ip_configurations.Element = AAZObjectArg(
@@ -247,6 +258,25 @@ def _build_arguments_schema(cls, *args, **kwargs):
247258
nullable=True,
248259
)
249260

261+
virtual_network_gateway_migration_status = cls._args_schema.virtual_network_gateway_migration_status
262+
virtual_network_gateway_migration_status.error_message = AAZStrArg(
263+
options=["error-message"],
264+
help="Error if any occurs during migration.",
265+
nullable=True,
266+
)
267+
virtual_network_gateway_migration_status.phase = AAZStrArg(
268+
options=["phase"],
269+
help="Represent the current migration phase of gateway.",
270+
nullable=True,
271+
enum={"Abort": "Abort", "AbortSucceeded": "AbortSucceeded", "Commit": "Commit", "CommitSucceeded": "CommitSucceeded", "Execute": "Execute", "ExecuteSucceeded": "ExecuteSucceeded", "None": "None", "Prepare": "Prepare", "PrepareSucceeded": "PrepareSucceeded"},
272+
)
273+
virtual_network_gateway_migration_status.state = AAZStrArg(
274+
options=["state"],
275+
help="Represent the current state of gateway migration.",
276+
nullable=True,
277+
enum={"Failed": "Failed", "InProgress": "InProgress", "None": "None", "Succeeded": "Succeeded"},
278+
)
279+
250280
# define Arg Group "Root Cert Authentication"
251281

252282
_args_schema = cls._args_schema
@@ -695,12 +725,14 @@ def _update_instance(self, instance):
695725
properties.set_prop("bgpSettings", AAZObjectType)
696726
properties.set_prop("customRoutes", AAZObjectType)
697727
properties.set_prop("enableBgp", AAZBoolType, ".enable_bgp")
728+
properties.set_prop("enableHighBandwidthVpnGateway", AAZBoolType, ".enable_high_bandwidth_vpn_gateway")
698729
properties.set_prop("enablePrivateIpAddress", AAZBoolType, ".enable_private_ip")
699730
properties.set_prop("gatewayDefaultSite", AAZObjectType)
700731
properties.set_prop("gatewayType", AAZStrType, ".gateway_type")
701732
properties.set_prop("ipConfigurations", AAZListType, ".ip_configurations")
702733
properties.set_prop("resiliencyModel", AAZStrType, ".resiliency_model")
703734
properties.set_prop("sku", AAZObjectType)
735+
properties.set_prop("virtualNetworkGatewayMigrationStatus", AAZObjectType, ".virtual_network_gateway_migration_status")
704736
properties.set_prop("vpnClientConfiguration", AAZObjectType)
705737
properties.set_prop("vpnType", AAZStrType, ".vpn_type")
706738

@@ -755,6 +787,12 @@ def _update_instance(self, instance):
755787
sku.set_prop("name", AAZStrType, ".sku")
756788
sku.set_prop("tier", AAZStrType, ".sku_tier")
757789

790+
virtual_network_gateway_migration_status = _builder.get(".properties.virtualNetworkGatewayMigrationStatus")
791+
if virtual_network_gateway_migration_status is not None:
792+
virtual_network_gateway_migration_status.set_prop("errorMessage", AAZStrType, ".error_message")
793+
virtual_network_gateway_migration_status.set_prop("phase", AAZStrType, ".phase")
794+
virtual_network_gateway_migration_status.set_prop("state", AAZStrType, ".state")
795+
758796
vpn_client_configuration = _builder.get(".properties.vpnClientConfiguration")
759797
if vpn_client_configuration is not None:
760798
vpn_client_configuration.set_prop("aadAudience", AAZStrType, ".aad_audience")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command_group(
15+
"network vnet-gateway migration",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Migrate vpn gateway from basic IP CSES to Standard IP based VMSS deployment.
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from .__cmd_group import *
12+
from ._abort import *
13+
from ._commit import *
14+
from ._execute import *
15+
from ._prepare import *
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command(
15+
"network vnet-gateway migration abort",
16+
)
17+
class Abort(AAZCommand):
18+
"""Trigger abort migration for the virtual network gateway.
19+
20+
:example: Abort a gateway migration
21+
az network vnet-gateway migration abort -g group -n gateway
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2024-07-01",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/virtualnetworkgateways/{}/abortmigration", "2024-07-01"],
28+
]
29+
}
30+
31+
AZ_SUPPORT_NO_WAIT = True
32+
33+
def _handler(self, command_args):
34+
super()._handler(command_args)
35+
return self.build_lro_poller(self._execute_operations, None)
36+
37+
_args_schema = None
38+
39+
@classmethod
40+
def _build_arguments_schema(cls, *args, **kwargs):
41+
if cls._args_schema is not None:
42+
return cls._args_schema
43+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
44+
45+
# define Arg Group ""
46+
47+
_args_schema = cls._args_schema
48+
_args_schema.resource_group = AAZResourceGroupNameArg(
49+
required=True,
50+
)
51+
_args_schema.vnet_gateway_name = AAZStrArg(
52+
options=["-n", "--gateway-name", "--vnet-gateway-name"],
53+
help="The name of the gateway.",
54+
required=True,
55+
id_part="name",
56+
)
57+
return cls._args_schema
58+
59+
def _execute_operations(self):
60+
self.pre_operations()
61+
yield self.VirtualNetworkGatewaysInvokeAbortMigration(ctx=self.ctx)()
62+
self.post_operations()
63+
64+
@register_callback
65+
def pre_operations(self):
66+
pass
67+
68+
@register_callback
69+
def post_operations(self):
70+
pass
71+
72+
class VirtualNetworkGatewaysInvokeAbortMigration(AAZHttpOperation):
73+
CLIENT_TYPE = "MgmtClient"
74+
75+
def __call__(self, *args, **kwargs):
76+
request = self.make_request()
77+
session = self.client.send_request(request=request, stream=False, **kwargs)
78+
if session.http_response.status_code in [202]:
79+
return self.client.build_lro_polling(
80+
self.ctx.args.no_wait,
81+
session,
82+
None,
83+
self.on_error,
84+
lro_options={"final-state-via": "location"},
85+
path_format_arguments=self.url_parameters,
86+
)
87+
88+
return self.on_error(session.http_response)
89+
90+
@property
91+
def url(self):
92+
return self.client.format_url(
93+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/abortMigration",
94+
**self.url_parameters
95+
)
96+
97+
@property
98+
def method(self):
99+
return "POST"
100+
101+
@property
102+
def error_format(self):
103+
return "ODataV4Format"
104+
105+
@property
106+
def url_parameters(self):
107+
parameters = {
108+
**self.serialize_url_param(
109+
"resourceGroupName", self.ctx.args.resource_group,
110+
required=True,
111+
),
112+
**self.serialize_url_param(
113+
"subscriptionId", self.ctx.subscription_id,
114+
required=True,
115+
),
116+
**self.serialize_url_param(
117+
"virtualNetworkGatewayName", self.ctx.args.vnet_gateway_name,
118+
required=True,
119+
),
120+
}
121+
return parameters
122+
123+
@property
124+
def query_parameters(self):
125+
parameters = {
126+
**self.serialize_query_param(
127+
"api-version", "2024-07-01",
128+
required=True,
129+
),
130+
}
131+
return parameters
132+
133+
134+
class _AbortHelper:
135+
"""Helper class for Abort"""
136+
137+
138+
__all__ = ["Abort"]

0 commit comments

Comments
 (0)