Skip to content
Merged
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
110 changes: 109 additions & 1 deletion src/azure-cli/azure/cli/command_modules/network/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -5501,6 +5501,14 @@
text: az network vnet-gateway delete -g MyResourceGroup -n MyVnetGateway
"""

helps['network vnet-gateway disconnect-vpn-connections'] = """
type: command
short-summary: Disconnect vpn connections of virtual network gateway.
examples:
- name: Disconnect vpn connections of virtual network gateway.
text: az network vnet-gateway disconnect-vpn-connections -g MyResourceGroup -n MyVnetGateway --vpn-connections MyConnetion1ByName MyConnection2ByID
"""

helps['network vnet-gateway ipsec-policy'] = """
type: group
short-summary: Manage virtual network gateway IPSec policies.
Expand Down Expand Up @@ -5566,6 +5574,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 @@ -5651,6 +5667,27 @@
crafted: true
"""

helps['network vnet-gateway packet-capture'] = """
type: group
short-summary: Manage packet capture on a virtual network gateway.
"""

helps['network vnet-gateway packet-capture start'] = """
type: command
short-summary: Start packet capture on a virtual network gateway.
examples:
- name: Start packet capture on a virtual network gateway.
text: az network vnet-gateway packet-capture start -g MyResourceGroup -n MyVnetGateway
"""

helps['network vnet-gateway packet-capture stop'] = """
type: command
short-summary: Stop packet capture on a virtual network gateway.
examples:
- name: Stop packet capture on a virtual network gateway.
text: az network vnet-gateway packet-capture stop -g MyResourceGroup -n MyVnetGateway --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 vnet-gateway vpn-client'] = """
type: group
short-summary: Download a VPN client configuration required to connect to Azure via point-to-site.
Expand Down Expand Up @@ -5680,6 +5717,38 @@
text: az network vnet-gateway vpn-client show-url -g MyResourceGroup -n MyVnetGateway
"""

helps['network vnet-gateway vpn-client show-health'] = """
type: command
short-summary: Get the VPN client connection health detail per P2S client connection of the virtual network gateway.
examples:
- name: Get the VPN client connection health detail per P2S client connection of the virtual network gateway.
text: az network vnet-gateway vpn-client show-health -g MyResourceGroup -n MyVnetGateway
"""

helps['network vnet-gateway vpn-client ipsec-policy'] = """
type: group
short-summary: Manage the VPN client connection ipsec-policy for P2S client connection of the virtual network gateway.
"""

helps['network vnet-gateway vpn-client ipsec-policy show'] = """
type: command
short-summary: Get the VPN client connection ipsec policy per P2S client connection of the virtual network gateway.
examples:
- name: Get the VPN client connection ipsec policy per P2S client connection of the virtual network gateway.
text: az network vnet-gateway vpn-client ipsec-policy show -g MyResourceGroup -n MyVnetGateway
"""

helps['network vnet-gateway vpn-client ipsec-policy set'] = """
type: command
short-summary: Set the VPN client connection ipsec policy per P2S client connection of the virtual network gateway.
examples:
- name: Set the VPN client connection ipsec policy per P2S client connection of the virtual network gateway.
text: |-
az network vnet-gateway vpn-client ipsec-policy set -g MyResourceGroup -n MyVnetGateway \
--dh-group DHGroup14 --ike-encryption AES256 --ike-integrity SHA384 --ipsec-encryption DES3 \
--ipsec-integrity GCMAES256 --pfs-group PFS2048 --sa-lifetime 27000 --sa-max-size 102400000
"""

helps['network vnet-gateway wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of the virtual network gateway is met.
Expand Down Expand Up @@ -5813,10 +5882,20 @@

helps['network vpn-connection list'] = """
type: command
short-summary: List all VPN connections in a resource group.
short-summary: List all VPN connections.
examples:
- name: List all VPN connections in a resource group.
text: az network vpn-connection list -g MyResourceGroup
- name: List all VPN connections in a virtual network gateway.
text: az network vpn-connection list -g MyResourceGroup --vnet-gateway MyVnetGateway
"""

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'] = """
Expand Down Expand Up @@ -5880,6 +5959,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
62 changes: 47 additions & 15 deletions src/azure-cli/azure/cli/command_modules/network/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
validate_user_assigned_identity, validate_virtul_network_gateway, validate_private_dns_zone,
NWConnectionMonitorEndpointFilterItemAction, NWConnectionMonitorTestConfigurationHTTPRequestHeaderAction,
process_private_link_resource_id_argument, process_private_endpoint_connection_id_argument,
validate_vpn_connection_name_or_id,
process_vnet_name_or_id, validate_trusted_client_cert)
from azure.mgmt.trafficmanager.models import MonitorProtocol, ProfileStatus
from azure.cli.command_modules.network._completers import (
Expand Down Expand Up @@ -1948,12 +1949,24 @@ def load_arguments(self, _):
with self.argument_context('network vnet-gateway revoked-cert create') as c:
c.argument('thumbprint', help='Certificate thumbprint.')

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

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

with self.argument_context('network vnet-gateway vpn-client') as c:
c.argument('processor_architecture', help='Processor architecture of the target system.', arg_type=get_enum_type(ProcessorArchitecture))
c.argument('authentication_method', help='Method used to authenticate with the generated client.', arg_type=get_enum_type(AuthenticationMethod))
c.argument('radius_server_auth_certificate', help='Public certificate data for the Radius server auth certificate in Base-64 format. Required only if external Radius auth has been configured with EAPTLS auth.')
c.argument('client_root_certificates', nargs='+', help='Space-separated list of client root certificate public certificate data in Base-64 format. Optional for external Radius-based auth with EAPTLS')
c.argument('use_legacy', min_api='2017-06-01', help='Generate VPN client package using legacy implementation.', arg_type=get_three_state_flag())

with self.argument_context('network vnet-gateway disconnect-vpn-connections') as c:
c.argument('vpn_connection_ids', options_list=['--vpn-connections'], nargs='+',
help='List of Name or ID of VPN connections.',
validator=validate_vpn_connection_name_or_id)
# endregion

# region VirtualNetworkGatewayConnections
Expand All @@ -1965,6 +1978,9 @@ def load_arguments(self, _):
c.argument('use_policy_based_traffic_selectors', min_api='2017-03-01', help='Enable policy-based traffic selectors.', arg_type=get_three_state_flag())
c.argument('express_route_gateway_bypass', min_api='2018-07-01', arg_type=get_three_state_flag(), help='Bypass ExpressRoute gateway for data forwarding.')

with self.argument_context('network vpn-connection list') as c:
c.argument('virtual_network_gateway_name', options_list=['--vnet-gateway'], help='Name of the VNet gateway.', completer=get_resource_name_completion_list('Microsoft.Network/virtualNetworkGateways'))

with self.argument_context('network vpn-connection create') as c:
c.argument('connection_name', options_list=['--name', '-n'], metavar='NAME', help='Connection name.')
c.ignore('connection_type')
Expand All @@ -1980,6 +1996,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 Expand Up @@ -2020,21 +2048,25 @@ def load_arguments(self, _):
with self.argument_context('network routeserver peering list') as c:
c.argument('virtual_hub_name', id_part=None)

param_map = {
'dh_group': 'DhGroup',
'ike_encryption': 'IkeEncryption',
'ike_integrity': 'IkeIntegrity',
'ipsec_encryption': 'IpsecEncryption',
'ipsec_integrity': 'IpsecIntegrity',
'pfs_group': 'PfsGroup'
}
for scope in ['vpn-connection', 'vnet-gateway']:
with self.argument_context('network {} ipsec-policy'.format(scope)) as c:
for dest, model_name in param_map.items():
model = self.get_models(model_name)
c.argument(dest, arg_type=get_enum_type(model))
c.argument('sa_data_size_kilobytes', options_list=['--sa-max-size'], type=int)
c.argument('sa_life_time_seconds', options_list=['--sa-lifetime'], type=int)
for scope in ['vpn-connection', 'vnet-gateway', 'vnet-gateway vpn-client']:
with self.argument_context('network {} ipsec-policy'.format(scope), arg_group='Security Association') as c:
c.argument('sa_data_size_kilobytes', options_list=['--sa-max-size'], type=int, help='The payload size in KB for P2S client.')
c.argument('sa_life_time_seconds', options_list=['--sa-lifetime'], type=int, help='The lifetime in seconds for P2S client.')
with self.argument_context('network {} ipsec-policy'.format(scope), arg_group='IKE Phase 1') as c:
c.argument('dh_group', arg_type=get_enum_type(self.get_models('DhGroup')),
help='The DH Groups used for initial SA.')
c.argument('ipsec_encryption', arg_type=get_enum_type(self.get_models('IpsecEncryption')),
help='The IPSec encryption algorithm.')
c.argument('ipsec_integrity', arg_type=get_enum_type(self.get_models('IpsecIntegrity')),
help='The IPSec integrity algorithm.')
with self.argument_context('network {} ipsec-policy'.format(scope), arg_group='IKE Phase 2') as c:
c.argument('pfs_group', arg_type=get_enum_type(self.get_models('PfsGroup')),
help='The Pfs Groups used for new child SA.')
c.argument('ike_encryption', arg_type=get_enum_type(self.get_models('IkeEncryption')),
help='The IKE encryption algorithm.')
c.argument('ike_integrity', arg_type=get_enum_type(self.get_models('IkeIntegrity')),
help='The IKE integrity algorithm.')

# endregion

# region Remove --ids from listsaz
Expand Down
14 changes: 14 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ def _validate_vpn_gateway_generation(namespace):
raise CLIError('vpn_gateway_generation should not be provided if gateway_type is not Vpn.')


def validate_vpn_connection_name_or_id(cmd, namespace):
if namespace.vpn_connection_ids:
from msrestazure.tools import is_valid_resource_id, resource_id
for index, vpn_connection_id in enumerate(namespace.vpn_connection_ids):
if not is_valid_resource_id(vpn_connection_id):
namespace.vpn_connection_ids[index] = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=namespace.resource_group_name,
namespace='Microsoft.Network',
type='connections',
name=vpn_connection_id
)


def validate_ddos_name_or_id(cmd, namespace):
if namespace.ddos_protection_plan:
from msrestazure.tools import is_valid_resource_id, resource_id
Expand Down
26 changes: 23 additions & 3 deletions src/azure-cli/azure/cli/command_modules/network/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,10 +1333,23 @@ 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')
g.custom_command('disconnect-vpn-connections', 'disconnect_vnet_gateway_vpn_connections', client_factory=cf_virtual_network_gateways, supports_no_wait=True, is_preview=True, min_api='2019-11-01')

with self.command_group('network vnet-gateway packet-capture', network_vgw_sdk, client_factory=cf_virtual_network_gateways, is_preview=True, min_api='2019-07-01') as g:
g.custom_command('start', 'start_vnet_gateway_package_capture', supports_no_wait=True)
g.custom_command('stop', 'stop_vnet_gateway_package_capture', supports_no_wait=True)

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')
g.command('show-url', 'begin_get_vpn_profile_package_url', min_api='2017-08-01')
g.command('show-health', 'begin_get_vpnclient_connection_health', is_preview=True, min_api='2019-04-01')

with self.command_group('network vnet-gateway vpn-client ipsec-policy', network_vgw_sdk, client_factory=cf_virtual_network_gateways, is_preview=True, min_api='2018-02-01') as g:
g.custom_command('set', 'set_vpn_client_ipsec_policy', supports_no_wait=True)
g.show_command('show', 'begin_get_vpnclient_ipsec_parameters')

# with self.command_group

with self.command_group('network vnet-gateway revoked-cert', network_vgw_sdk) as g:
g.custom_command('create', 'create_vnet_gateway_revoked_cert')
Expand All @@ -1362,21 +1375,28 @@ def _make_singular(value):
g.custom_command('create', 'create_vpn_connection', transform=DeploymentOutputLongRunningOperation(self.cli_ctx), table_transformer=deployment_validate_table_format, validator=process_vpn_connection_create_namespace, exception_handler=handle_template_based_exception)
g.command('delete', 'begin_delete')
g.show_command('show', 'get', transform=transform_vpn_connection)
g.command('list', 'list', transform=transform_vpn_connection_list)
g.custom_command('list', 'list_vpn_connections', 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
Loading