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
3 changes: 2 additions & 1 deletion scripts/sdk_process/patch_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def find_autorest_generated_folder(module_prefix="azure.mgmt"):
'azure.mgmt.rdbms'
'azure.mgmt.loganalytics',
'azure.mgmt.web',
'azure.mgmt.cosmosdb'
'azure.mgmt.cosmosdb',
'azure.mgmt.privatedns'
]
prefix = sys.argv[1] if len(sys.argv) >= 2 else "azure.mgmt"
for autorest_package in find_autorest_generated_folder(prefix):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ def transform_privatedns_link_table_output(result):


def transform_privatedns_record_set_output(result):
from azure.mgmt.privatedns.models import RecordSetPaged
from azure.mgmt.privatedns.models import RecordSetListResult

def _strip_null_records(item):
for prop in [x for x in dir(item) if 'record' in x]:
if not getattr(item, prop):
delattr(item, prop)

if isinstance(result, RecordSetPaged):
if isinstance(result, RecordSetListResult):
result = list(result)
for item in result:
_strip_null_records(item)
Expand Down
12 changes: 6 additions & 6 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.{}',
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 @@ -32,17 +32,17 @@ def load_command_table(self, _):
)

with self.command_group('network private-dns zone', network_privatedns_zone_sdk) as g:
g.command('delete', 'delete', confirmation=True, supports_no_wait=True)
g.command('delete', 'begin_delete', confirmation=True, supports_no_wait=True)
g.show_command('show', 'get', table_transformer=transform_privatedns_zone_table_output)
g.custom_command('list', 'list_privatedns_zones', client_factory=cf_privatedns_mgmt_zones, table_transformer=transform_privatedns_zone_table_output)
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='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)
g.wait_command('wait')

with self.command_group('network private-dns link vnet', network_privatedns_virtual_network_link_sdk) as g:
g.command('delete', 'delete', confirmation=True, supports_no_wait=True)
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)
Expand Down
14 changes: 7 additions & 7 deletions src/azure-cli/azure/cli/command_modules/privatedns/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# pylint: disable=line-too-long
from collections import Counter, OrderedDict
from knack.log import get_logger
from msrestazure.azure_exceptions import CloudError
from msrestazure.tools import parse_resource_id
from azure.cli.core.util import CLIError
from azure.cli.core.commands import LongRunningOperation
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.cli.command_modules.network.zone_file.make_zone_file import make_zone_file
from azure.cli.command_modules.network.zone_file.parse_zone_file import parse_zone_file
from azure.core.exceptions import HttpResponseError

logger = get_logger(__name__)

Expand Down Expand Up @@ -104,7 +104,7 @@ def import_zone(cmd, resource_group_name, private_zone_name, file_name):
logger.warning(("Please be aware that DNS names ending with .local are reserved for use with multicast DNS "
"and may not work as expected with some operating systems. For details refer to your operating systems documentation."))
zone = PrivateZone(location='global')
result = LongRunningOperation(cmd.cli_ctx)(client.private_zones.create_or_update(resource_group_name, private_zone_name, zone))
result = LongRunningOperation(cmd.cli_ctx)(client.private_zones.begin_create_or_update(resource_group_name, private_zone_name, zone))
if result.provisioning_state != 'Succeeded':
raise CLIError('Error occured while creating or updating private dns zone.')

Expand All @@ -129,7 +129,7 @@ def import_zone(cmd, resource_group_name, private_zone_name, file_name):
cum_records += record_count
print("({}/{}) Imported {} records of type '{}' and name '{}'"
.format(cum_records, total_records, record_count, rs_type, rs_name), file=sys.stderr)
except CloudError as ex:
except HttpResponseError as ex:
logger.error(ex)
print("\n== {}/{} RECORDS IMPORTED SUCCESSFULLY: '{}' =="
.format(cum_records, total_records, private_zone_name), file=sys.stderr)
Expand Down Expand Up @@ -270,7 +270,7 @@ def create_privatedns_zone(cmd, resource_group_name, private_zone_name, tags=Non
logger.warning(("Please be aware that DNS names ending with .local are reserved for use with multicast DNS "
"and may not work as expected with some operating systems. For details refer to your operating systems documentation."))
zone = PrivateZone(location='global', tags=tags)
return client.create_or_update(resource_group_name, private_zone_name, zone, if_none_match='*')
return client.begin_create_or_update(resource_group_name, private_zone_name, zone, if_none_match='*')


def update_privatedns_zone(instance, tags=None):
Expand All @@ -292,7 +292,7 @@ def create_privatedns_link(cmd, resource_group_name, private_zone_name, virtual_
link.virtual_network = virtual_network

client = get_mgmt_service_client(cmd.cli_ctx, PrivateDnsManagementClient, aux_subscriptions=[aux_subscription]).virtual_network_links
return client.create_or_update(resource_group_name, private_zone_name, virtual_network_link_name, link, if_none_match='*')
return client.begin_create_or_update(resource_group_name, private_zone_name, virtual_network_link_name, link, if_none_match='*')


def update_privatedns_link(cmd, resource_group_name, private_zone_name, virtual_network_link_name, registration_enabled=None, tags=None, if_match=None, **kwargs):
Expand All @@ -307,7 +307,7 @@ 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):
Expand Down Expand Up @@ -359,7 +359,7 @@ def _privatedns_add_save_record(client, record, record_type, relative_record_set
try:
record_set = client.get(
resource_group_name, private_zone_name, record_type, relative_record_set_name)
except CloudError:
except HttpResponseError:
record_set = RecordSet(ttl=3600)

_privatedns_add_record(record_set, record, record_type, is_list)
Expand Down
Loading