Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

def cf_netappfiles(cli_ctx, *kwargs):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.mgmt.netapp import AzureNetAppFilesManagementClient
return get_mgmt_service_client(cli_ctx, AzureNetAppFilesManagementClient)
from azure.mgmt.netapp import NetAppManagementClient
return get_mgmt_service_client(cli_ctx, NetAppManagementClient)


def accounts_mgmt_client_factory(cli_ctx, _):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long

from knack.util import CLIError
from msrest.exceptions import ValidationError # pylint: disable=import-error
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError


def netappfiles_exception_handler(ex):
if isinstance(ex, (CloudError, ValidationError, ValueError)):
if isinstance(ex, (ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError,
ValidationError, ValueError)):
message = ex
raise CLIError(message)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
short-summary: Domain Users in the Active directory to be given SeSecurityPrivilege privilege (Needed for SMB Continuously available shares for SQL). A list of unique usernames without domain specifier
- name: --ldap-over-tls
short-summary: Specifies whether or not the LDAP traffic needs to be secured via TLS
- name: --allow-local-ldap-users
short-summary: If enabled, NFS client local users can also (in addition to LDAP users) access the NFS volumes
examples:
- name: Add an active directory to the account
text: >
Expand Down Expand Up @@ -548,6 +550,8 @@
short-summary: Read only access
- name: --unix-read-write
short-summary: Read and write access
- name: --ldap-enabled
short-summary: Specifies whether LDAP is enabled or not for a given NFS volume
examples:
- name: Create an ANF volume
text: >
Expand Down
10 changes: 2 additions & 8 deletions src/azure-cli/azure/cli/command_modules/netappfiles/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def load_arguments(self, _):
with self.argument_context('netappfiles account ad') as c:
c.argument('backup_operators', arg_type=tags_type)
c.argument('security_operators', arg_type=tags_type)
c.argument('allow_local_ldap_users', arg_type=tags_type)

with self.argument_context('netappfiles account ad list') as c:
c.argument('account_name', help='The name of the ANF account', id_part=None)
Expand All @@ -58,14 +59,6 @@ def load_arguments(self, _):
load_snapshotArguments(self, account_name_type, pool_name_type, volume_name_type)
load_vaultArguments(self, account_name_type)

with self.argument_context('netappfiles account backup') as c:
c.argument('account_name', account_name_type, id_part=None)

load_poolArguments(self, account_name_type, pool_name_type)
load_volumeArguments(self, account_name_type, pool_name_type, volume_name_type)
load_snapshotArguments(self, account_name_type, pool_name_type, volume_name_type)
load_vaultArguments(self, account_name_type)


def load_poolArguments(self, account_name_type, pool_name_type):
with self.argument_context('netappfiles pool') as c:
Expand All @@ -89,6 +82,7 @@ def load_volumeArguments(self, account_name_type, pool_name_type, volume_name_ty
c.argument('unix_read_only', arg_type=get_three_state_flag())
c.argument('unix_read_write', arg_type=get_three_state_flag())
c.argument('cifs', arg_type=get_three_state_flag())
c.argument('ldap_enabled', arg_type=get_three_state_flag())

with self.argument_context('netappfiles volume list') as c:
c.argument('account_name', account_name_type, id_part=None)
Expand Down
68 changes: 38 additions & 30 deletions src/azure-cli/azure/cli/command_modules/netappfiles/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ def load_accounts_command_groups(self, netappfiles_accounts_sdk):
with self.command_group('netappfiles account', netappfiles_accounts_sdk) as g:
g.show_command('show', 'get')
g.command('list', 'list')
g.command('delete', 'delete')
g.command('delete', 'begin_delete')
g.custom_command('create', 'create_account',
client_factory=accounts_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#NetAppAccount',
exception_handler=netappfiles_exception_handler)
g.generic_update_command('update',
setter_name='update',
setter_name='begin_update',
custom_func_name='patch_account',
setter_arg_name='body',
doc_string_source='azure.mgmt.netapp.models#NetAppAccountPatch',
exception_handler=netappfiles_exception_handler)

with self.command_group('netappfiles account ad', netappfiles_accounts_sdk) as g:
g.generic_update_command('add',
setter_name='update',
setter_name='begin_update',
custom_func_name='add_active_directory',
setter_arg_name='body',
doc_string_source='azure.mgmt.netapp.models#NetAppAccountPatch',
Expand All @@ -114,25 +114,24 @@ def load_accounts_command_groups(self, netappfiles_accounts_sdk):
client_factory=accounts_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#NetAppAccount',
exception_handler=netappfiles_exception_handler)

g.custom_command('remove', 'remove_active_directory',
client_factory=accounts_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#NetAppAccount',
exception_handler=netappfiles_exception_handler)


def load_account_backup_command_groups(self, netappfiles_account_backups_sdk):
with self.command_group('netappfiles account backup', netappfiles_account_backups_sdk) as g:
with self.command_group('netappfiles account backup', netappfiles_account_backups_sdk, is_preview=True) as g:
g.show_command('show', 'get')
g.command('list', 'list')
g.command('delete', 'delete', confirmation=True)
g.command('delete', 'begin_delete', confirmation=True)


def load_backup_policies_command_groups(self, netappfiles_backup_policies_sdk):
with self.command_group('netappfiles account backup-policy', netappfiles_backup_policies_sdk) as g:
g.show_command('show', 'get')
g.command('list', 'list')
g.command('delete', 'delete')
g.command('delete', 'begin_delete')
g.custom_command('update', 'patch_backup_policy',
client_factory=backup_policies_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#BackupPolicyPatch',
Expand All @@ -147,13 +146,13 @@ def load_pools_command_groups(self, netappfiles_pools_sdk):
with self.command_group('netappfiles pool', netappfiles_pools_sdk) as g:
g.show_command('show', 'get')
g.command('list', 'list')
g.command('delete', 'delete')
g.command('delete', 'begin_delete')
g.custom_command('create', 'create_pool',
client_factory=pools_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#CapacityPool',
exception_handler=netappfiles_exception_handler)
g.generic_update_command('update',
setter_name='update',
setter_name='begin_update',
custom_func_name='patch_pool',
setter_arg_name='body',
doc_string_source='azure.mgmt.netapp.models#CapacityPoolPatch',
Expand All @@ -164,26 +163,29 @@ def load_volumes_command_groups(self, netappfiles_volumes_sdk):
with self.command_group('netappfiles volume', netappfiles_volumes_sdk) as g:
g.show_command('show', 'get')
g.command('list', 'list')
g.command('delete', 'delete')
g.command('delete', 'begin_delete')
g.custom_command('create', 'create_volume',
client_factory=volumes_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#Volume',
exception_handler=netappfiles_exception_handler)
g.generic_update_command('update',
setter_name='update',
setter_name='begin_update',
custom_func_name='patch_volume',
setter_arg_name='body',
doc_string_source='azure.mgmt.netapp.models#VolumePatch',
exception_handler=netappfiles_exception_handler)
g.custom_command('revert', 'revert_snapshot',
g.custom_command('revert', 'volume_revert',
client_factory=volumes_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#Volume',
exception_handler=netappfiles_exception_handler)
g.custom_command('pool-change', 'pool_change',
client_factory=volumes_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#Volume',
exception_handler=netappfiles_exception_handler)
g.command('pool-change', 'pool_change')

with self.command_group('netappfiles volume export-policy', netappfiles_volumes_sdk) as g:
g.generic_update_command('add',
setter_name='update',
setter_name='begin_update',
custom_func_name='add_export_policy_rule',
setter_arg_name='body',
doc_string_source='azure.mgmt.netapp.models#VolumePatch',
Expand All @@ -193,7 +195,7 @@ def load_volumes_command_groups(self, netappfiles_volumes_sdk):
doc_string_source='azure.mgmt.netapp.models#Volume',
exception_handler=netappfiles_exception_handler)
g.generic_update_command('remove',
setter_name='update',
setter_name='begin_update',
custom_func_name='remove_export_policy_rule',
setter_arg_name='body',
doc_string_source='azure.mgmt.netapp.models#VolumePatch',
Expand All @@ -204,42 +206,48 @@ def load_volumes_command_groups(self, netappfiles_volumes_sdk):
client_factory=volumes_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#Volume',
exception_handler=netappfiles_exception_handler)
g.command('suspend', 'break_replication')
g.command('resume', 'resync_replication')
g.command('remove', 'delete_replication')
g.command('status', 'replication_status_method')
g.command('re-initialize', 're_initialize_replication')
g.custom_command('suspend', 'break_replication',
client_factory=volumes_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#Volume',
exception_handler=netappfiles_exception_handler)
g.command('resume', 'begin_resync_replication')
g.command('remove', 'begin_delete_replication')
g.command('status', 'replication_status')
g.command('re-initialize', 'begin_re_initialize_replication')


def load_backups_command_groups(self, netappfiles_backups_sdk):
with self.command_group('netappfiles volume backup', netappfiles_backups_sdk) as g:
with self.command_group('netappfiles volume backup', netappfiles_backups_sdk, is_preview=True) as g:
g.show_command('show', 'get')
g.command('list', 'list')
g.command('delete', 'delete')
g.command('update', 'update')
g.command('create', 'create')
g.command('delete', 'begin_delete')
g.custom_command('update', 'update_backup',
doc_string_source='azure.mgmt.netapp.models#BackupPatch',
exception_handler=netappfiles_exception_handler)
g.custom_command('create', 'create_backup',
client_factory=snapshots_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#Backup',
exception_handler=netappfiles_exception_handler)


def load_snapshots_command_groups(self, netappfiles_snapshots_sdk):
with self.command_group('netappfiles snapshot', netappfiles_snapshots_sdk) as g:
g.show_command('show', 'get')
g.command('list', 'list')
g.command('delete', 'delete')
g.command('delete', 'begin_delete')
g.custom_command('create', 'create_snapshot',
client_factory=snapshots_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#Snapshot',
exception_handler=netappfiles_exception_handler)
g.command('update', 'begin_update')


def load_snapshots_policies_command_groups(self, netappfiles_snapshot_policies_sdk):
with self.command_group('netappfiles snapshot policy', netappfiles_snapshot_policies_sdk) as g:
g.show_command('show', 'get')
g.command('list', 'list')
g.custom_command('volumes', 'list_volumes',
client_factory=snapshot_policies_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#SnapshotPolicy',
exception_handler=netappfiles_exception_handler)
g.command('delete', 'delete')
g.command('volumes', 'list_volumes')
g.command('delete', 'begin_delete')
g.custom_command('update', 'patch_snapshot_policy',
client_factory=snapshot_policies_mgmt_client_factory,
doc_string_source='azure.mgmt.netapp.models#SnapshotPolicyPatch',
Expand Down
Loading