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

Merge master Azure to forked repo #19

Merged
merged 3 commits into from
Mar 4, 2019
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
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