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
31 changes: 29 additions & 2 deletions src/azure-cli/azure/cli/command_modules/network/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def load_arguments(self, _):
VirtualNetworkGatewaySkuName, VirtualNetworkGatewayType, VpnClientProtocol, VpnType,
ExpressRouteLinkMacSecCipher, ExpressRouteLinkAdminState,
ConnectionMonitorEndpointFilterType, ConnectionMonitorTestConfigurationProtocol,
PreferredIPVersion, HTTPConfigurationMethod, OutputType, DestinationPortBehavior) = self.get_models(
PreferredIPVersion, HTTPConfigurationMethod, OutputType, DestinationPortBehavior, CoverageLevel, EndpointType) = self.get_models(
'Access', 'ApplicationGatewayFirewallMode', 'ApplicationGatewayProtocol', 'ApplicationGatewayRedirectType',
'ApplicationGatewayRequestRoutingRuleType', 'ApplicationGatewaySkuName', 'ApplicationGatewaySslProtocol', 'AuthenticationMethod',
'Direction',
Expand All @@ -72,7 +72,7 @@ def load_arguments(self, _):
'VirtualNetworkGatewaySkuName', 'VirtualNetworkGatewayType', 'VpnClientProtocol', 'VpnType',
'ExpressRouteLinkMacSecCipher', 'ExpressRouteLinkAdminState',
'ConnectionMonitorEndpointFilterType', 'ConnectionMonitorTestConfigurationProtocol',
'PreferredIPVersion', 'HTTPConfigurationMethod', 'OutputType', 'DestinationPortBehavior')
'PreferredIPVersion', 'HTTPConfigurationMethod', 'OutputType', 'DestinationPortBehavior', 'CoverageLevel', 'EndpointType')

ZoneType = self.get_models('ZoneType', resource_type=ResourceType.MGMT_NETWORK_DNS)

Expand Down Expand Up @@ -1155,6 +1155,12 @@ def load_arguments(self, _):
help='Resource ID of the destination of connection monitor endpoint')
c.argument('endpoint_dest_address',
help='Address of the destination of connection monitor endpoint (IP or domain name)')
c.argument('endpoint_dest_type',
arg_type=get_enum_type(EndpointType),
help='The endpoint type')
c.argument('endpoint_dest_coverage_level',
arg_type=get_enum_type(CoverageLevel),
help='Test coverage for the endpoint')
c.argument('endpoint_source_name',
help='The name of the source of connection monitor endpoint. '
'If you are creating a V2 Connection Monitor, it\'s required')
Expand All @@ -1163,6 +1169,12 @@ def load_arguments(self, _):
'If endpoint is intended to used as source, this option is required.')
c.argument('endpoint_source_address',
help='Address of the source of connection monitor endpoint (IP or domain name)')
c.argument('endpoint_source_type',
arg_type=get_enum_type(EndpointType),
help='The endpoint type')
c.argument('endpoint_source_coverage_level',
arg_type=get_enum_type(CoverageLevel),
help='Test coverage for the endpoint')

# Argument Group for test configuration to create a V2 connection monitor
with self.argument_context('network watcher connection-monitor',
Expand Down Expand Up @@ -1271,12 +1283,27 @@ def load_arguments(self, _):
help='Resource ID of the connection monitor endpoint')
c.argument('address',
help='Address of the connection monitor endpoint (IP or domain name)')
c.argument('address_include',
nargs='+',
help='List of address of the endpoint item which needs to be included to the endpoint scope')
c.argument('address_exclude',
nargs='+',
help='List of address of the endpoint item which needs to be included to the endpoint scope')
c.argument('endpoint_type',
options_list=['--type'],
help='The endpoint type',
arg_type=get_enum_type(EndpointType))
c.argument('coverage_level',
arg_type=get_enum_type(CoverageLevel),
help='Test coverage for the endpoint')
c.argument('filter_type',
arg_type=get_enum_type(ConnectionMonitorEndpointFilterType),
deprecate_info=c.deprecate(hide=False),
help="The behavior of the endpoint filter. Currently only 'Include' is supported.")
c.argument('filter_items',
options_list=['--filter-item'],
action=NWConnectionMonitorEndpointFilterItemAction,
deprecate_info=c.deprecate(hide=False),
nargs='+',
help="List of property=value pairs to define filter items. "
"Property currently include: type, address. "
Expand Down
67 changes: 54 additions & 13 deletions src/azure-cli/azure/cli/command_modules/network/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4055,9 +4055,13 @@ def create_nw_connection_monitor(cmd,
endpoint_source_name=None,
endpoint_source_resource_id=None,
endpoint_source_address=None,
endpoint_source_type=None,
endpoint_source_coverage_level=None,
endpoint_dest_name=None,
endpoint_dest_resource_id=None,
endpoint_dest_address=None,
endpoint_dest_type=None,
endpoint_dest_coverage_level=None,
test_config_name=None,
test_config_frequency=None,
test_config_protocol=None,
Expand All @@ -4084,8 +4088,8 @@ def create_nw_connection_monitor(cmd,
]

v2_required_parameter_set = [
endpoint_source_name, endpoint_source_resource_id,
endpoint_dest_name, endpoint_dest_address,
endpoint_source_name, endpoint_source_resource_id, endpoint_source_type, endpoint_source_coverage_level,
endpoint_dest_name, endpoint_dest_address, endpoint_dest_type, endpoint_dest_coverage_level,
test_config_name, test_config_protocol,
output_type, workspace_ids,
]
Expand Down Expand Up @@ -4115,9 +4119,13 @@ def create_nw_connection_monitor(cmd,
endpoint_source_name,
endpoint_source_resource_id,
endpoint_source_address,
endpoint_source_type,
endpoint_source_coverage_level,
endpoint_dest_name,
endpoint_dest_resource_id,
endpoint_dest_address,
endpoint_dest_type,
endpoint_dest_coverage_level,
test_config_name,
test_config_frequency,
test_config_protocol,
Expand Down Expand Up @@ -4191,9 +4199,13 @@ def _create_nw_connection_monitor_v2(cmd,
endpoint_source_name=None,
endpoint_source_resource_id=None,
endpoint_source_address=None,
endpoint_source_type=None,
endpoint_source_coverage_level=None,
endpoint_dest_name=None,
endpoint_dest_resource_id=None,
endpoint_dest_address=None,
endpoint_dest_type=None,
endpoint_dest_coverage_level=None,
test_config_name=None,
test_config_frequency=None,
test_config_protocol=None,
Expand All @@ -4216,12 +4228,16 @@ def _create_nw_connection_monitor_v2(cmd,
notes=None):
src_endpoint = _create_nw_connection_monitor_v2_endpoint(cmd,
endpoint_source_name,
endpoint_source_resource_id,
endpoint_source_address)
endpoint_resource_id=endpoint_source_resource_id,
address=endpoint_source_address,
endpoint_type=endpoint_source_type,
coverage_level=endpoint_source_coverage_level)
dst_endpoint = _create_nw_connection_monitor_v2_endpoint(cmd,
endpoint_dest_name,
endpoint_dest_resource_id,
endpoint_dest_address)
endpoint_resource_id=endpoint_dest_resource_id,
address=endpoint_dest_address,
endpoint_type=endpoint_dest_type,
coverage_level=endpoint_dest_coverage_level)
test_config = _create_nw_connection_monitor_v2_test_configuration(cmd,
test_config_name,
test_config_frequency,
Expand Down Expand Up @@ -4271,15 +4287,21 @@ def _create_nw_connection_monitor_v2_endpoint(cmd,
endpoint_resource_id=None,
address=None,
filter_type=None,
filter_items=None):
filter_items=None,
endpoint_type=None,
coverage_level=None):
if (filter_type and not filter_items) or (not filter_type and filter_items):
raise CLIError('usage error: '
'--filter-type and --filter-item for endpoint filter must be present at the same time.')

ConnectionMonitorEndpoint, ConnectionMonitorEndpointFilter = cmd.get_models(
'ConnectionMonitorEndpoint', 'ConnectionMonitorEndpointFilter')

endpoint = ConnectionMonitorEndpoint(name=name, resource_id=endpoint_resource_id, address=address)
endpoint = ConnectionMonitorEndpoint(name=name,
resource_id=endpoint_resource_id,
address=address,
type=endpoint_type,
coverage_level=coverage_level)

if filter_type and filter_items:
endpoint_filter = ConnectionMonitorEndpointFilter(type=filter_type, items=filter_items)
Expand Down Expand Up @@ -4387,16 +4409,35 @@ def add_nw_connection_monitor_v2_endpoint(cmd,
connection_monitor_name,
location,
name,
coverage_level=None,
endpoint_type=None,
source_test_groups=None,
dest_test_groups=None,
endpoint_resource_id=None,
address=None,
filter_type=None,
filter_items=None):
ConnectionMonitorEndpoint, ConnectionMonitorEndpointFilter = cmd.get_models(
'ConnectionMonitorEndpoint', 'ConnectionMonitorEndpointFilter')

endpoint = ConnectionMonitorEndpoint(name=name, resource_id=endpoint_resource_id, address=address)
filter_items=None,
address_include=None,
address_exclude=None):
(ConnectionMonitorEndpoint, ConnectionMonitorEndpointFilter,
ConnectionMonitorEndpointScope, ConnectionMonitorEndpointScopeItem) = cmd.get_models(
'ConnectionMonitorEndpoint', 'ConnectionMonitorEndpointFilter',
'ConnectionMonitorEndpointScope', 'ConnectionMonitorEndpointScopeItem')

endpoint_scope = ConnectionMonitorEndpointScope(include=[], exclude=[])
for ip in address_include or []:
include_item = ConnectionMonitorEndpointScopeItem(address=ip)
endpoint_scope.include.append(include_item)
for ip in address_exclude or []:
exclude_item = ConnectionMonitorEndpointScopeItem(address=ip)
endpoint_scope.exclude.append(exclude_item)

endpoint = ConnectionMonitorEndpoint(name=name,
resource_id=endpoint_resource_id,
address=address,
type=endpoint_type,
coverage_level=coverage_level,
scope=endpoint_scope if address_include or address_exclude else None)

if filter_type and filter_items:
endpoint_filter = ConnectionMonitorEndpointFilter(type=filter_type, items=filter_items)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ network vnet subnet create:
disable_private_link_service_network_policies:
rule_exclusions:
- option_length_too_long
network watcher connection-monitor create:
parameters:
endpoint_dest_coverage_level:
rule_exclusions:
- option_length_too_long
endpoint_source_coverage_level:
rule_exclusions:
- option_length_too_long
...
Loading