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
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/network/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2943,7 +2943,7 @@
--name link1 \\
--macsec-ckn-secret-identifier MacSecCKNSecretID \\
--macsec-cak-secret-identifier MacSecCAKSecretID \\
--macsec-cipher gcm-aes-128
--macsec-cipher GcmAes128
- name: Enable administrative state of an ExpressRoute Link.
text: |-
az network express-route port link update \\
Expand Down
8 changes: 4 additions & 4 deletions src/azure-cli/azure/cli/command_modules/network/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def load_arguments(self, _):
IPVersion, LoadBalancerSkuName, LoadDistribution, ProbeProtocol, ProcessorArchitecture, Protocol, PublicIPAddressSkuName, PublicIPAddressSkuTier,
RouteNextHopType, SecurityRuleAccess, SecurityRuleProtocol, SecurityRuleDirection, TransportProtocol,
VirtualNetworkGatewaySkuName, VirtualNetworkGatewayType, VpnClientProtocol, VpnType,
ExpressRouteLinkMacSecCipher, ExpressRouteLinkAdminState,
ExpressRouteLinkMacSecCipher,
ConnectionMonitorEndpointFilterType, ConnectionMonitorTestConfigurationProtocol,
PreferredIPVersion, HTTPConfigurationMethod, OutputType, DestinationPortBehavior, CoverageLevel, EndpointType, GatewayLoadBalancerTunnelProtocol,
GatewayLoadBalancerTunnelInterfaceType, VpnNatRuleType, VpnNatRuleMode) = self.get_models(
Expand All @@ -74,7 +74,7 @@ def load_arguments(self, _):
'IPVersion', 'LoadBalancerSkuName', 'LoadDistribution', 'ProbeProtocol', 'ProcessorArchitecture', 'Protocol', 'PublicIPAddressSkuName', 'PublicIPAddressSkuTier',
'RouteNextHopType', 'SecurityRuleAccess', 'SecurityRuleProtocol', 'SecurityRuleDirection', 'TransportProtocol',
'VirtualNetworkGatewaySkuName', 'VirtualNetworkGatewayType', 'VpnClientProtocol', 'VpnType',
'ExpressRouteLinkMacSecCipher', 'ExpressRouteLinkAdminState',
'ExpressRouteLinkMacSecCipher',
'ConnectionMonitorEndpointFilterType', 'ConnectionMonitorTestConfigurationProtocol',
'PreferredIPVersion', 'HTTPConfigurationMethod', 'OutputType', 'DestinationPortBehavior', 'CoverageLevel', 'EndpointType', 'GatewayLoadBalancerTunnelProtocol',
'GatewayLoadBalancerTunnelInterfaceType', 'VpnNatRuleType', 'VpnNatRuleMode')
Expand Down Expand Up @@ -107,7 +107,6 @@ def load_arguments(self, _):
ag_servers_type = CLIArgumentType(nargs='+', help='Space-separated list of IP addresses or DNS names corresponding to backend servers.', validator=get_servers_validator())
app_gateway_name_type = CLIArgumentType(help='Name of the application gateway.', options_list='--gateway-name', completer=get_resource_name_completion_list('Microsoft.Network/applicationGateways'), id_part='name')
express_route_link_macsec_cipher_type = CLIArgumentType(get_enum_type(ExpressRouteLinkMacSecCipher))
express_route_link_admin_state_type = CLIArgumentType(get_enum_type(ExpressRouteLinkAdminState))
zone_compatible_type = CLIArgumentType(
options_list=['--zone', '-z'],
nargs='+',
Expand Down Expand Up @@ -848,7 +847,7 @@ def load_arguments(self, _):

with self.argument_context('network express-route port link update', min_api='2019-08-01') as c:
c.argument('admin_state',
arg_type=express_route_link_admin_state_type,
arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True),
help='Enable/Disable administrative state of an ExpressRoute Link')

with self.argument_context('network express-route port link update', arg_group='MACsec', min_api='2019-08-01') as c:
Expand All @@ -857,6 +856,7 @@ def load_arguments(self, _):
c.argument('macsec_ckn_secret_identifier',
help='The connectivity key name (CKN) that stored in the KeyVault.')
c.argument('macsec_cipher', arg_type=express_route_link_macsec_cipher_type, help='Cipher Method')
c.argument('macsec_sci_state', arg_type=get_three_state_flag(positive_label='Enabled', negative_label='Disabled', return_label=True), help='Sci mode', min_api='2020-06-01')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this type the same as admin_state above? It seems very similar and is it possible that we can share a common arg_type?


with self.argument_context('network express-route port location', min_api='2018-08-01') as c:
c.argument('location_name', options_list=['--location', '-l'])
Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ def _make_singular(value):
setter_name='begin_create_or_update',
custom_func_name='update_express_route_port_link',
supports_no_wait=True,
child_collection_prop_name='links',
child_arg_name='link_name',
min_api='2019-08-01')

with self.command_group('network express-route port location', network_er_port_locations_sdk) as g:
Expand Down
28 changes: 10 additions & 18 deletions src/azure-cli/azure/cli/command_modules/network/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2997,9 +2997,9 @@ def show_express_route_port_identity(cmd, resource_group_name, express_route_por
return ports.identity


def update_express_route_port_link(cmd, instance, express_route_port_name, link_name,
def update_express_route_port_link(cmd, instance, parent, express_route_port_name, link_name,
macsec_cak_secret_identifier=None, macsec_ckn_secret_identifier=None,
macsec_cipher=None, admin_state=None):
macsec_sci_state=None, macsec_cipher=None, admin_state=None):
"""
:param cmd:
:param instance: an instance of ExpressRoutePort
Expand All @@ -3011,30 +3011,22 @@ def update_express_route_port_link(cmd, instance, express_route_port_name, link_
:param admin_state:
:return:
"""
if len(instance.links) != 2:
raise CLIError("The number of ExpressRoute Links should be 2. "
"Code may not perform as expected. Please contact us to update CLI.")

try:
link_index = [index for index, link in enumerate(instance.links) if link.name == link_name][0]
except Exception:
raise CLIError('ExpressRoute Link "{}" not found'.format(link_name))

if any([macsec_cak_secret_identifier, macsec_ckn_secret_identifier, macsec_cipher]):
instance.links[link_index].mac_sec_config.cak_secret_identifier = macsec_cak_secret_identifier
instance.links[link_index].mac_sec_config.ckn_secret_identifier = macsec_ckn_secret_identifier
if any([macsec_cak_secret_identifier, macsec_ckn_secret_identifier, macsec_cipher, macsec_sci_state]):
instance.mac_sec_config.cak_secret_identifier = macsec_cak_secret_identifier
instance.mac_sec_config.ckn_secret_identifier = macsec_ckn_secret_identifier

# TODO https://github.com/Azure/azure-rest-api-specs/issues/7569
# need to remove this conversion when the issue is fixed.
if macsec_cipher is not None:
macsec_ciphers_tmp = {'gcm-aes-128': 'GcmAes128', 'gcm-aes-256': 'GcmAes256'}
macsec_cipher = macsec_ciphers_tmp[macsec_cipher]
instance.links[link_index].mac_sec_config.cipher = macsec_cipher
macsec_cipher = macsec_ciphers_tmp.get(macsec_cipher, macsec_cipher)
instance.mac_sec_config.cipher = macsec_cipher
instance.mac_sec_config.sci_state = macsec_sci_state

if admin_state is not None:
instance.links[link_index].admin_state = admin_state
instance.admin_state = admin_state

return instance
return parent
# endregion


Expand Down
Loading