Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create initial CLI Extension for ANF resource provider #527

Merged
merged 24 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b64c7c2
NFSAAS-1708 add initial version of anf cli extension
leonardbf Feb 19, 2019
e1c85e3
Merge pull request #1 from leonardbf/NFSAAS-1708-initial-cli-extension
leonardbf Feb 19, 2019
51733d1
NFSAAS-1708 lint fixes
leonardbf Feb 19, 2019
faa9bd8
Merge pull request #2 from leonardbf/NFSAAS-1708-initial-cli-extension
leonardbf Feb 19, 2019
f1781de
NFSAAS-1708 code owner
leonardbf Feb 19, 2019
6e07811
Merge pull request #3 from leonardbf/NFSAAS-1708-initial-cli-extension
leonardbf Feb 19, 2019
5d7a03a
NFSAAS-1708 update from review comments
leonardbf Feb 20, 2019
2ea3977
Merge pull request #4 from leonardbf/NFSAAS-1708-initial-cli-extension
leonardbf Feb 20, 2019
46deb54
NFSAAS-1708 update from review comments
leonardbf Feb 20, 2019
6b6cac0
Merge pull request #5 from leonardbf/NFSAAS-1708-initial-cli-extension
leonardbf Feb 20, 2019
b3bb6e1
NFSAAS-1708 update with code review comments
leonardbf Feb 20, 2019
5c84c92
Merge pull request #6 from leonardbf/NFSAAS-1708-initial-cli-extension
leonardbf Feb 20, 2019
a7becd6
NFSAAS-1708 updates from review comments
leonardbf Feb 20, 2019
3f11bc3
Merge pull request #7 from leonardbf/NFSAAS-1708-initial-cli-extension
leonardbf Feb 20, 2019
a8e625a
NFSAAS-1708 updates from review comments
leonardbf Feb 20, 2019
d4d3dd3
Merge pull request #8 from leonardbf/NFSAAS-1708-initial-cli-extension
leonardbf Feb 20, 2019
9ec6de4
NFSAAS-1708 updates from review comments (#9)
leonardbf Feb 25, 2019
898a90d
Nfsaas 1708 initial cli extension (#10)
leonardbf Feb 25, 2019
a1722a1
Nfsaas 1708 initial cli extension (#11)
leonardbf Feb 25, 2019
c92c760
Nfsaas 1708 initial cli extension (#13)
leonardbf Feb 25, 2019
e9d77d1
Nfsaas 1708 initial cli extension (#14)
leonardbf Feb 25, 2019
8ab79e3
Nfsaas 1708 initial cli extension (#16)
leonardbf Feb 25, 2019
9be88a3
Nfsaas 1708 initial cli extension (#17)
leonardbf Feb 28, 2019
e1e41ee
Merge branch 'master' into master
williexu Feb 28, 2019
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
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,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