Skip to content

Commit

Permalink
{Network} az network nic: Migrate commands to codegen v2 (Azure#25454)
Browse files Browse the repository at this point in the history
  • Loading branch information
necusjz authored Feb 15, 2023
1 parent 5834e13 commit 01e7cf9
Show file tree
Hide file tree
Showing 20 changed files with 19,276 additions and 1,559 deletions.
10 changes: 2 additions & 8 deletions src/azure-cli/azure/cli/command_modules/network/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ def transform_traffic_manager_create_output(result):
return {'TrafficManagerProfile': result}


def transform_nic_create_output(result):
if result:
return {'NewNIC': result.result()}
return None


def transform_nsg_rule_table_output(result):
item = OrderedDict()
item['Name'] = result['name']
Expand Down Expand Up @@ -218,9 +212,9 @@ def transform_effective_route_table(result):
transformed.append(OrderedDict([
('Source', item['source']),
('State', item['state']),
('Address Prefix', ' '.join(item['addressPrefix'] or [])),
('Address Prefix', ' '.join(item.get('addressPrefix', []))),
('Next Hop Type', item['nextHopType']),
('Next Hop IP', ' '.join(item['nextHopIpAddress'] or []))
('Next Hop IP', ' '.join(item.get('nextHopIpAddress', []))),
]))
return transformed

Expand Down
18 changes: 1 addition & 17 deletions src/azure-cli/azure/cli/command_modules/network/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,18 +600,6 @@ def load_arguments(self, _):
# endregion

# region NetworkInterfaces (NIC)
with self.argument_context('network nic') as c:
c.argument('enable_accelerated_networking', min_api='2016-09-01', options_list=['--accelerated-networking'], help='Enable accelerated networking.', arg_type=get_three_state_flag())
c.argument('network_interface_name', nic_type, options_list=['--name', '-n'])
c.argument('internal_dns_name_label', options_list='--internal-dns-name', help='The internal DNS name label.', arg_group='DNS')
c.argument('dns_servers', help='Space-separated list of DNS server IP addresses.', nargs='+', arg_group='DNS')
c.argument('enable_ip_forwarding', options_list='--ip-forwarding', help='Enable IP forwarding.', arg_type=get_three_state_flag())

with self.argument_context('network nic create') as c:
c.argument('private_ip_address_version', min_api='2016-09-01', help='The private IP address version to use.', default=IPVersion.I_PV4.value if IPVersion else '')
c.argument('network_interface_name', nic_type, options_list=['--name', '-n'], id_part=None)
c.argument('edge_zone', edge_zone)

public_ip_help = get_folded_parameter_help_string('public IP address', allow_none=True, default_none=True)
c.argument('public_ip_address', help=public_ip_help, completer=get_resource_name_completion_list('Microsoft.Network/publicIPAddresses'))

Expand All @@ -621,11 +609,7 @@ def load_arguments(self, _):
subnet_help = get_folded_parameter_help_string('subnet', other_required_option='--vnet-name', allow_cross_sub=False)
c.argument('subnet', help=subnet_help, completer=subnet_completion_list)

with self.argument_context('network nic update') as c:
c.argument('network_security_group', help='Name or ID of the associated network security group.', validator=get_nsg_validator(), completer=get_resource_name_completion_list('Microsoft.Network/networkSecurityGroups'))
c.argument('dns_servers', help='Space-separated list of DNS server IP addresses. Use ""(\'""\' in PowerShell) to revert to default Azure servers.', nargs='+', arg_group='DNS')

for item in ['create', 'ip-config update', 'ip-config create']:
for item in ['ip-config update', 'ip-config create']:
with self.argument_context('network nic {}'.format(item)) as c:
c.argument('application_security_groups', options_list=['--application-security-groups', '--asgs'], min_api='2017-09-01', help='Space-separated list of application security groups.', nargs='+', validator=get_asg_validator(self, 'application_security_groups'))

Expand Down
15 changes: 0 additions & 15 deletions src/azure-cli/azure/cli/command_modules/network/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,21 +653,6 @@ def process_cross_region_lb_create_namespace(cmd, namespace):
'specify --public-ip-dns-name only if creating a new public IP address.')


def process_nic_create_namespace(cmd, namespace):
get_default_location_from_resource_group(cmd, namespace)
validate_tags(namespace)

validate_ag_address_pools(cmd, namespace)
validate_address_pool_id_list(cmd, namespace)
validate_inbound_nat_rule_id_list(cmd, namespace)
get_asg_validator(cmd.loader, 'application_security_groups')(cmd, namespace)

# process folded parameters
get_subnet_validator(has_type_field=False)(cmd, namespace)
get_public_ip_validator(has_type_field=False, allow_none=True, default_none=True)(cmd, namespace)
get_nsg_validator(has_type_field=False, allow_none=True, default_none=True)(cmd, namespace)


def process_public_ip_create_namespace(cmd, namespace):
get_default_location_from_resource_group(cmd, namespace)
validate_public_ip_prefix(cmd, namespace)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"network nic",
)
class __CMDGroup(AAZCommandGroup):
"""Manage network interfaces.
To learn more about network interfaces in Azure, visit https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-network-interface?tabs=network-interface-portal.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._list import *
from ._list_effective_nsg import *
from ._show import *
from ._show_effective_route_table import *
from ._update import *
from ._wait import *
Loading

0 comments on commit 01e7cf9

Please sign in to comment.