Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -5566,6 +5566,14 @@
text: az network vnet-gateway list-learned-routes -g MyResourceGroup -n MyVnetGateway
"""

helps['network vnet-gateway show-supported-devices'] = """
type: command
short-summary: Get a xml format representation for supported vpn devices.
examples:
- name: Get a xml format representation for supported vpn devices.
text: az network vnet-gateway show-supported-devices -g MyResourceGroup -n MyVnetGateway
"""

helps['network vnet-gateway reset'] = """
type: command
short-summary: Reset a virtual network gateway.
Expand Down Expand Up @@ -5819,6 +5827,14 @@
text: az network vpn-connection list -g MyResourceGroup
"""

helps['network vpn-connection list-ike-sas'] = """
type: command
short-summary: List IKE Security Associations for a VPN connection.
examples:
- name: List IKE Security Associations for a VPN connection.
text: az network vpn-connection list-ike-sas -g MyResourceGroup -n MyConnection
"""

helps['network vpn-connection shared-key'] = """
type: group
short-summary: Manage VPN shared keys.
Expand Down Expand Up @@ -5880,6 +5896,35 @@
crafted: true
"""

helps['network vpn-connection show-device-config-script'] = """
type: command
short-summary: Get a XML format representation for VPN connection device configuration script.
examples:
- name: Get a XML format representation for VPN connection device configuration script.
text: az network vpn-connection show-device-config-script -g MyResourceGroup -n MyConnection --vendor "Cisco" --device-family "Cisco-ISR(IOS)" --firmware-version "Cisco-ISR-15.x--IKEv2+BGP"
"""

helps['network vpn-connection packet-capture'] = """
type: group
short-summary: Manage packet capture on a VPN connection.
"""

helps['network vpn-connection packet-capture start'] = """
type: command
short-summary: Start packet capture on a VPN connection.
examples:
- name: Start packet capture on a VPN connection.
text: az network vpn-connection packet-capture start -g MyResourceGroup -n MyConnection
"""

helps['network vpn-connection packet-capture stop'] = """
type: command
short-summary: Stop packet capture on a VPN connection.
examples:
- name: Stop packet capture on a VPN connection.
text: az network vpn-connection packet-capture stop -g MyResourceGroup -n MyConnection --sas-url https://myStorageAct.blob.azure.com/artifacts?st=2019-04-10T22%3A12Z&se=2019-04-11T09%3A12Z&sp=rl&sv=2018-03-28&sr=c&sig=0000000000
"""

helps['network vrouter'] = """
type: group
short-summary: Manage the virtual router. This feature supports both VirtualHub and VirtualRouter. Considering VirtualRouter is deprecated, we recommend to create VirtualRouter with --hosted-subnet instead
Expand Down
12 changes: 12 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,18 @@ def load_arguments(self, _):
c.argument('key_length', type=int, help='The virtual network connection reset shared key length, should between 1 and 128.')
c.argument('value', help='The virtual network connection shared key value.')

with self.argument_context('network vpn-connection show-device-config-script') as c:
c.argument('vendor', help='The vendor for the VPN device.')
c.argument('device_family', help='The device family for the vpn device.')
c.argument('firmware_version', help='The firmware version for the vpn device.')

with self.argument_context('network vpn-connection packet-capture start') as c:
c.argument('filter_data', options_list=['--filter'], help='Data filter.')

with self.argument_context('network vpn-connection packet-capture stop') as c:
c.argument('sas_url', options_list=['--sas-url'],
help='The SAS url to be used for packet capture on VPN connection.')

with self.argument_context('network vrouter') as c:
c.argument('virtual_router_name', options_list=['--name', '-n'], help='The name of the Virtual Router.')
c.argument('hosted_gateway',
Expand Down
12 changes: 10 additions & 2 deletions src/azure-cli/azure/cli/command_modules/network/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ def _make_singular(value):
g.command('list-bgp-peer-status', 'begin_get_bgp_peer_status', table_transformer=transform_vnet_gateway_bgp_peer_table)
g.command('list-advertised-routes', 'begin_get_advertised_routes', table_transformer=transform_vnet_gateway_routes_table)
g.command('list-learned-routes', 'begin_get_learned_routes', table_transformer=transform_vnet_gateway_routes_table)
g.command('show-supported-devices', 'supported_vpn_devices', is_preview=True, min_api='2017-09-01')

with self.command_group('network vnet-gateway vpn-client', network_vgw_sdk, client_factory=cf_virtual_network_gateways) as g:
g.custom_command('generate', 'generate_vpn_client')
Expand Down Expand Up @@ -1364,19 +1365,26 @@ def _make_singular(value):
g.show_command('show', 'get', transform=transform_vpn_connection)
g.command('list', 'list', transform=transform_vpn_connection_list)
g.generic_update_command('update', setter_name='begin_create_or_update', custom_func_name='update_vpn_connection')
g.command('list-ike-sas', 'begin_get_ike_sas', is_preview=True, min_api='2020-08-01')
g.custom_command('show-device-config-script', 'show_vpn_connection_device_config_script', client_factory=cf_virtual_network_gateways, is_preview=True, min_api='2017-09-01')

with self.command_group('network vpn-connection shared-key', network_vpn_sdk) as g:
with self.command_group('network vpn-connection shared-key', network_vpn_sdk, client_factory=cf_virtual_network_gateway_connections) as g:
g.show_command('show', 'get_shared_key')
g.custom_command('reset', 'reset_shared_key')
g.generic_update_command('update',
getter_name='get_shared_key',
custom_func_name='update_shared_key',
setter_name='begin_set_shared_key')

with self.command_group('network vpn-connection ipsec-policy', network_vpn_sdk, min_api='2017-03-01') as g:
with self.command_group('network vpn-connection ipsec-policy', network_vpn_sdk, client_factory=cf_virtual_network_gateway_connections, min_api='2017-03-01') as g:
g.custom_command('add', 'add_vpn_conn_ipsec_policy', supports_no_wait=True, doc_string_source='IpsecPolicy')
g.custom_command('list', 'list_vpn_conn_ipsec_policies')
g.custom_command('clear', 'clear_vpn_conn_ipsec_policies', supports_no_wait=True)

with self.command_group('network vpn-connection packet-capture', network_vpn_sdk, client_factory=cf_virtual_network_gateway_connections, is_preview=True, min_api='2019-07-01') as g:
g.custom_command('start', 'start_vpn_conn_package_capture', supports_no_wait=True)
g.custom_command('stop', 'stop_vpn_conn_package_capture', supports_no_wait=True)

# endregion

# region VirtualRouter
Expand Down
53 changes: 39 additions & 14 deletions src/azure-cli/azure/cli/command_modules/network/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6567,6 +6567,35 @@ def update_vpn_connection(cmd, instance, routing_weight=None, shared_key=None, t
gateway2_id['resource_group'], gateway2_id['name'])

return instance


def start_vpn_conn_package_capture(cmd, client, resource_group_name, virtual_network_gateway_connection_name,
filter_data=None, no_wait=False):
VpnPacketCaptureStartParameters = cmd.get_models('VpnPacketCaptureStartParameters')
parameters = VpnPacketCaptureStartParameters(filter_data=filter_data)
return sdk_no_wait(no_wait, client.begin_start_packet_capture, resource_group_name,
virtual_network_gateway_connection_name, parameters=parameters)


def stop_vpn_conn_package_capture(cmd, client, resource_group_name, virtual_network_gateway_connection_name,
sas_url, no_wait=False):
VpnPacketCaptureStopParameters = cmd.get_models('VpnPacketCaptureStopParameters')
parameters = VpnPacketCaptureStopParameters(sas_url=sas_url)
return sdk_no_wait(no_wait, client.begin_stop_packet_capture, resource_group_name,
virtual_network_gateway_connection_name, parameters=parameters)


def show_vpn_connection_device_config_script(cmd, client, resource_group_name, virtual_network_gateway_connection_name,
vendor, device_family, firmware_version):
VpnDeviceScriptParameters = cmd.get_models('VpnDeviceScriptParameters')
parameters = VpnDeviceScriptParameters(
vendor=vendor,
device_family=device_family,
firmware_version=firmware_version
)
return client.vpn_device_configuration_script(resource_group_name, virtual_network_gateway_connection_name,
parameters=parameters)

# endregion


Expand Down Expand Up @@ -6620,7 +6649,7 @@ def list_vnet_gateway_ipsec_policies(cmd, resource_group_name, gateway_name):
raise CLIError('VPN client configuration must first be set through `az network vnet-gateway create/update`.')


def add_vpn_conn_ipsec_policy(cmd, resource_group_name, connection_name,
def add_vpn_conn_ipsec_policy(cmd, client, resource_group_name, connection_name,
sa_life_time_seconds, sa_data_size_kilobytes,
ipsec_encryption, ipsec_integrity,
ike_encryption, ike_integrity, dh_group, pfs_group, no_wait=False):
Expand All @@ -6634,31 +6663,28 @@ def add_vpn_conn_ipsec_policy(cmd, resource_group_name, connection_name,
dh_group=dh_group,
pfs_group=pfs_group)

ncf = network_client_factory(cmd.cli_ctx).virtual_network_gateway_connections
conn = ncf.get(resource_group_name, connection_name)
conn = client.get(resource_group_name, connection_name)
if conn.ipsec_policies:
conn.ipsec_policies.append(new_policy)
else:
conn.ipsec_policies = [new_policy]
return sdk_no_wait(no_wait, ncf.begin_create_or_update, resource_group_name, connection_name, conn)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, connection_name, conn)


def clear_vpn_conn_ipsec_policies(cmd, resource_group_name, connection_name, no_wait=False):
ncf = network_client_factory(cmd.cli_ctx).virtual_network_gateway_connections
conn = ncf.get(resource_group_name, connection_name)
def clear_vpn_conn_ipsec_policies(cmd, client, resource_group_name, connection_name, no_wait=False):
conn = client.get(resource_group_name, connection_name)
conn.ipsec_policies = None
conn.use_policy_based_traffic_selectors = False
if no_wait:
return sdk_no_wait(no_wait, ncf.begin_create_or_update, resource_group_name, connection_name, conn)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, connection_name, conn)

from azure.cli.core.commands import LongRunningOperation
poller = sdk_no_wait(no_wait, ncf.begin_create_or_update, resource_group_name, connection_name, conn)
poller = sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, connection_name, conn)
return LongRunningOperation(cmd.cli_ctx)(poller).ipsec_policies


def list_vpn_conn_ipsec_policies(cmd, resource_group_name, connection_name):
ncf = network_client_factory(cmd.cli_ctx).virtual_network_gateway_connections
return ncf.get(resource_group_name, connection_name).ipsec_policies
def list_vpn_conn_ipsec_policies(cmd, client, resource_group_name, connection_name):
return client.get(resource_group_name, connection_name).ipsec_policies


def assign_vnet_gateway_aad(cmd, resource_group_name, gateway_name,
Expand Down Expand Up @@ -7188,10 +7214,9 @@ def list_security_partner_provider(cmd, resource_group_name=None):


# region network gateway connection
def reset_shared_key(cmd, virtual_network_gateway_connection_name, key_length, resource_group_name=None):
def reset_shared_key(cmd, client, virtual_network_gateway_connection_name, key_length, resource_group_name=None):
ConnectionResetSharedKey = cmd.get_models('ConnectionResetSharedKey')
shared_key = ConnectionResetSharedKey(key_length=key_length)
client = network_client_factory(cmd.cli_ctx).virtual_network_gateway_connections
return client.begin_reset_shared_key(resource_group_name=resource_group_name,
virtual_network_gateway_connection_name=virtual_network_gateway_connection_name, # pylint: disable=line-too-long
parameters=shared_key)
Expand Down
Loading