Skip to content

Commit

Permalink
Create initial CLI Extension for ANF resource provider (#527)
Browse files Browse the repository at this point in the history
* 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
leonardbf authored and williexu committed Feb 28, 2019
1 parent 704752a commit 5a82cfc
Show file tree
Hide file tree
Showing 84 changed files with 13,447 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@

/src/aks-preview/ @zqingqing1

/src/sqlvm-preview/ @yareyes
/src/sqlvm-preview/ @yareyes

/src/anf-preview/ @b-lefr
8 changes: 8 additions & 0 deletions src/anf-preview/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:
Release History
===============

0.1.0
+++++
* Initial release
33 changes: 33 additions & 0 deletions src/anf-preview/README.md
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
```
31 changes: 31 additions & 0 deletions src/anf-preview/azext_anf_preview/__init__.py
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
32 changes: 32 additions & 0 deletions src/anf-preview/azext_anf_preview/_client_factory.py
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
17 changes: 17 additions & 0 deletions src/anf-preview/azext_anf_preview/_exception_handler.py
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())
Loading

0 comments on commit 5a82cfc

Please sign in to comment.