-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create initial CLI Extension for ANF resource provider (#527)
* NFSAAS-1708 add initial version of anf cli extension * NFSAAS-1708 lint fixes * NFSAAS-1708 code owner * NFSAAS-1708 update from review comments * NFSAAS-1708 update from review comments * NFSAAS-1708 update with code review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments (#9) * Nfsaas 1708 initial cli extension (#10) * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * Nfsaas 1708 initial cli extension (#11) * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * Nfsaas 1708 initial cli extension (#13) * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * Nfsaas 1708 initial cli extension (#14) * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * Nfsaas 1708 initial cli extension (#16) * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * Nfsaas 1708 initial cli extension (#17) * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments * NFSAAS-1708 updates from review comments
- Loading branch information
Showing
84 changed files
with
13,447 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.. :changelog: | ||
Release History | ||
=============== | ||
|
||
0.1.0 | ||
+++++ | ||
* Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Azure CLI for Azure NetApp Files (ANF) Extension # | ||
This is an extension to azure cli which provides commands to create and manage Azure NetApp File (ANF) storage resources. | ||
|
||
## How to use ## | ||
First, install the extension: | ||
``` | ||
az extension add --name anf-preview | ||
``` | ||
|
||
It can then be used to create volumes and snapshots. The typical sequence would be to first create an account | ||
``` | ||
az anf account create --resource-group rg -n account_name | ||
``` | ||
|
||
Then allocate a storage pool in which volumes can be created | ||
``` | ||
az anf pool create --resource-group rg -a account_name -n pool_name -l location --size 4398046511104 --service-level "Premium" | ||
``` | ||
|
||
Volumes are created within the pool resource | ||
``` | ||
az anf volume create --resource-group rg -a account_name -p pool_name -n volume_name -l location --service-level "Premium" --usage-threshold 107374182400 --creation-token "unique-token" --subnet-id "/subscriptions/mysubsid/resourceGroups/myrg/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/default" | ||
``` | ||
|
||
Snapshots of volumes can also be created | ||
``` | ||
az anf snapshot create --resource-group rg -a account_name --p pool_name -v vname -n snapshot_name -l location --file-system-id volume-uuid | ||
``` | ||
|
||
These resources can be updated, deleted and listed. See the help to find out more | ||
``` | ||
az anf --help | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from azure.cli.core import AzCommandsLoader | ||
from ._help import helps # pylint: disable=unused-import | ||
|
||
|
||
class NetAppExtensionCommandsLoader(AzCommandsLoader): | ||
|
||
def __init__(self, cli_ctx=None): | ||
from azure.cli.core.commands import CliCommandType | ||
netapp_custom = CliCommandType(operations_tmpl='azext_anf_preview.custom#{}') | ||
super(NetAppExtensionCommandsLoader, self).__init__(cli_ctx=cli_ctx, | ||
min_profile='2017-03-10-profile', | ||
custom_command_type=netapp_custom) | ||
|
||
def load_command_table(self, args): | ||
super(NetAppExtensionCommandsLoader, self).load_command_table(args) | ||
from .commands import load_command_table | ||
load_command_table(self, args) | ||
return self.command_table | ||
|
||
def load_arguments(self, command): | ||
super(NetAppExtensionCommandsLoader, self).load_arguments(command) | ||
from ._params import load_arguments | ||
load_arguments(self, command) | ||
|
||
|
||
COMMAND_LOADER_CLS = NetAppExtensionCommandsLoader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# pylint: disable=unused-argument | ||
|
||
|
||
def cf_netapp(cli_ctx, *kwargs): | ||
from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
from azext_anf_preview.vendored_sdks import AzureNetAppFilesManagementClient | ||
return get_mgmt_service_client(cli_ctx, AzureNetAppFilesManagementClient) | ||
|
||
|
||
def accounts_mgmt_client_factory(cli_ctx, _): | ||
return cf_netapp(cli_ctx).accounts | ||
|
||
|
||
def pools_mgmt_client_factory(cli_ctx, _): | ||
return cf_netapp(cli_ctx).pools | ||
|
||
|
||
def volumes_mgmt_client_factory(cli_ctx, _): | ||
return cf_netapp(cli_ctx).volumes | ||
|
||
|
||
def mount_targets_mgmt_client_factory(cli_ctx, _): | ||
return cf_netapp(cli_ctx).mount_targets | ||
|
||
|
||
def snapshots_mgmt_client_factory(cli_ctx, _): | ||
return cf_netapp(cli_ctx).snapshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from knack.util import CLIError | ||
|
||
|
||
def netapp_exception_handler(ex): | ||
from azext_anf_preview.vendored_sdks.models import ErrorException | ||
if isinstance(ex, ErrorException): | ||
message = ex | ||
raise CLIError(message) | ||
else: | ||
import sys | ||
from six import reraise | ||
reraise(*sys.exc_info()) |
Oops, something went wrong.