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
18 changes: 9 additions & 9 deletions src/azure-cli/azure/cli/command_modules/privatedns/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
def load_command_table(self, _):

network_privatedns_zone_sdk = CliCommandType(
operations_tmpl='azure.mgmt.privatedns.operations.private_zones_operations#PrivateZonesOperations.{}',
operations_tmpl='azure.mgmt.privatedns.operations#PrivateZonesOperations.{}',
Copy link
Author

Choose a reason for hiding this comment

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

Now the file name is changed from private_zones_operations to _private_zones_operations, so remove this unnecessary subitem in module path. You can find the name in SDK source code.

client_factory=cf_privatedns_mgmt_zones
)

network_privatedns_virtual_network_link_sdk = CliCommandType(
operations_tmpl='azure.mgmt.privatedns.operations.virtual_network_links_operations#VirtualNetworkLinksOperations.{}',
operations_tmpl='azure.mgmt.privatedns.operations#VirtualNetworkLinksOperations.{}',
client_factory=cf_privatedns_mgmt_virtual_network_links
)

network_privatedns_record_set_sdk = CliCommandType(
operations_tmpl='azure.mgmt.privatedns.operations.record_sets_operations#RecordSetsOperations.{}',
operations_tmpl='azure.mgmt.privatedns.operations#RecordSetsOperations.{}',
client_factory=cf_privatedns_mgmt_record_sets
)

Expand All @@ -38,15 +38,15 @@ def load_command_table(self, _):
g.custom_command('import', 'import_zone')
g.custom_command('export', 'export_zone')
g.custom_command('create', 'create_privatedns_zone', client_factory=cf_privatedns_mgmt_zones, supports_no_wait=True)
g.generic_update_command('update', setter_name='begin_create_or_update', custom_func_name='update_privatedns_zone', supports_no_wait=True)
g.generic_update_command('update', setter_name='begin_update', custom_func_name='update_privatedns_zone', supports_no_wait=True)
Copy link
Author

Choose a reason for hiding this comment

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

We use update before, so should use begin_update now.

g.wait_command('wait')

with self.command_group('network private-dns link vnet', network_privatedns_virtual_network_link_sdk) as g:
g.command('delete', 'begin_delete', confirmation=True, supports_no_wait=True)
g.show_command('show', 'get', table_transformer=transform_privatedns_link_table_output)
g.command('list', 'list', table_transformer=transform_privatedns_link_table_output)
g.custom_command('create', 'create_privatedns_link', client_factory=cf_privatedns_mgmt_virtual_network_links, supports_no_wait=True)
g.generic_update_command('update', setter_name='begin_create_or_update', custom_func_name='update_privatedns_link', setter_type=network_privatedns_custom, supports_no_wait=True)
g.generic_update_command('update', setter_name='update_privatedns_link', setter_type=network_privatedns_custom, supports_no_wait=True)
Copy link
Author

Choose a reason for hiding this comment

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

No custom_func_name before for this generic_update_command()

g.wait_command('wait')

with self.command_group('network private-dns record-set') as g:
Expand All @@ -56,22 +56,22 @@ def load_command_table(self, _):
for record in supported_records:
with self.command_group('network private-dns record-set {}'.format(record), network_privatedns_record_set_sdk) as g:
g.show_command('show', 'get', transform=transform_privatedns_record_set_output, table_transformer=transform_privatedns_record_set_table_output)
g.command('delete', 'begin_delete', confirmation=True)
g.command('delete', 'delete', confirmation=True)
Copy link
Author

@jsntcy jsntcy Apr 22, 2021

Choose a reason for hiding this comment

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

Should not add begin_ prefix as delete and create_or_update commands for record-set are not long running operations. You can find the method name in SDK source code.

Remove other unnecessary begin_ prefixes as well.

g.custom_command('list', 'list_privatedns_record_set', client_factory=cf_privatedns_mgmt_record_sets, transform=transform_privatedns_record_set_output, table_transformer=transform_privatedns_record_set_table_output)
g.custom_command('create', 'create_privatedns_record_set', client_factory=cf_privatedns_mgmt_record_sets, transform=transform_privatedns_record_set_output)
g.custom_command('add-record', 'add_privatedns_{}_record'.format(record), client_factory=cf_privatedns_mgmt_record_sets, transform=transform_privatedns_record_set_output)
g.custom_command('remove-record', 'remove_privatedns_{}_record'.format(record), client_factory=cf_privatedns_mgmt_record_sets, transform=transform_privatedns_record_set_output)
g.generic_update_command('update', setter_name='begin_create_or_update', custom_func_name='update_privatedns_record_set', transform=transform_privatedns_record_set_output)
g.generic_update_command('update', setter_name='update', custom_func_name='update_privatedns_record_set', transform=transform_privatedns_record_set_output)

with self.command_group('network private-dns record-set soa', network_privatedns_record_set_sdk) as g:
g.show_command('show', 'get', transform=transform_privatedns_record_set_output, table_transformer=transform_privatedns_record_set_table_output)
g.custom_command('update', 'update_privatedns_soa_record', client_factory=cf_privatedns_mgmt_record_sets, transform=transform_privatedns_record_set_output)

with self.command_group('network private-dns record-set cname', network_privatedns_record_set_sdk) as g:
g.show_command('show', 'get', transform=transform_privatedns_record_set_output, table_transformer=transform_privatedns_record_set_table_output)
g.command('delete', 'begin_delete', confirmation=True)
g.command('delete', 'delete', confirmation=True)
g.custom_command('list', 'list_privatedns_record_set', client_factory=cf_privatedns_mgmt_record_sets, transform=transform_privatedns_record_set_output, table_transformer=transform_privatedns_record_set_table_output)
g.custom_command('create', 'create_privatedns_record_set', client_factory=cf_privatedns_mgmt_record_sets, transform=transform_privatedns_record_set_output)
g.custom_command('set-record', 'add_privatedns_cname_record', client_factory=cf_privatedns_mgmt_record_sets, transform=transform_privatedns_record_set_output)
g.custom_command('remove-record', 'remove_privatedns_cname_record', client_factory=cf_privatedns_mgmt_record_sets, transform=transform_privatedns_record_set_output)
g.generic_update_command('update', setter_name='begin_create_or_update', custom_func_name='update_privatedns_record_set', transform=transform_privatedns_record_set_output)
g.generic_update_command('update', setter_name='update', custom_func_name='update_privatedns_record_set', transform=transform_privatedns_record_set_output)
12 changes: 6 additions & 6 deletions src/azure-cli/azure/cli/command_modules/privatedns/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def import_zone(cmd, resource_group_name, private_zone_name, file_name):
rs.soa_record.host = root_soa.soa_record.host
rs_name = '@'
try:
client.record_sets.begin_create_or_update(
client.record_sets.create_or_update(
resource_group_name, private_zone_name, rs_type, rs_name, rs)
cum_records += record_count
print("({}/{}) Imported {} records of type '{}' and name '{}'"
Expand Down Expand Up @@ -307,15 +307,15 @@ def update_privatedns_link(cmd, resource_group_name, private_zone_name, virtual_

aux_subscription = parse_resource_id(link.virtual_network.id)['subscription']
client = get_mgmt_service_client(cmd.cli_ctx, PrivateDnsManagementClient, aux_subscriptions=[aux_subscription]).virtual_network_links
return client.update(resource_group_name, private_zone_name, virtual_network_link_name, link, if_match=if_match)
return client.begin_update(resource_group_name, private_zone_name, virtual_network_link_name, link, if_match=if_match)


def create_privatedns_record_set(cmd, resource_group_name, private_zone_name, relative_record_set_name, record_type, metadata=None, ttl=3600):
from azure.mgmt.privatedns import PrivateDnsManagementClient
from azure.mgmt.privatedns.models import RecordSet
client = get_mgmt_service_client(cmd.cli_ctx, PrivateDnsManagementClient).record_sets
record_set = RecordSet(ttl=ttl, metadata=metadata)
return client.begin_create_or_update(resource_group_name, private_zone_name, record_type, relative_record_set_name, record_set, if_none_match='*')
return client.create_or_update(resource_group_name, private_zone_name, record_type, relative_record_set_name, record_set, if_none_match='*')


def list_privatedns_record_set(cmd, resource_group_name, private_zone_name, record_type=None):
Expand Down Expand Up @@ -363,7 +363,7 @@ def _privatedns_add_save_record(client, record, record_type, relative_record_set
record_set = RecordSet(ttl=3600)

_privatedns_add_record(record_set, record, record_type, is_list)
return client.begin_create_or_update(resource_group_name, private_zone_name, record_type, relative_record_set_name, record_set)
return client.create_or_update(resource_group_name, private_zone_name, record_type, relative_record_set_name, record_set)


def add_privatedns_aaaa_record(cmd, resource_group_name, private_zone_name, relative_record_set_name, ipv6_address):
Expand Down Expand Up @@ -557,9 +557,9 @@ def _privatedns_remove_record(client, record, record_type, relative_record_set_n

if not records_remaining and not keep_empty_record_set:
logger.info('Removing empty %s record set: %s', record_type, relative_record_set_name)
return client.begin_delete(resource_group_name, private_zone_name, record_type, relative_record_set_name)
return client.delete(resource_group_name, private_zone_name, record_type, relative_record_set_name)

return client.begin_create_or_update(resource_group_name, private_zone_name, record_type, relative_record_set_name, record_set)
return client.create_or_update(resource_group_name, private_zone_name, record_type, relative_record_set_name, record_set)


def dict_matches_filter(d, filter_dict):
Expand Down