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

NFSAAS-1708 add initial version of ANF CLI extension #1

Merged
merged 1 commit into from
Feb 19, 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
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.0.1
+++++
* Initial release
5 changes: 5 additions & 0 deletions src/anf-preview/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Microsoft Azure CLI 'Azure NetApp File (ANF)' Command Module
===================================================================

This package is for the Azure NetApp File (ANF)' module.
i.e. 'az anf'
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
25 changes: 25 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,25 @@
# --------------------------------------------------------------------------------------------
# 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 azure.mgmt.netapp 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
16 changes: 16 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,16 @@
# --------------------------------------------------------------------------------------------
# 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 azure.mgmt.netapp.models import ErrorException
if isinstance(ex, ErrorException):
message = ex
raise CLIError(message)
else:
import sys
from six import reraise
reraise(*sys.exc_info())
Loading