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

Conversation

leonardbf
Copy link
Contributor

From NetApp internal ticket NFSAAS-1708 create initial CLI Extension for ANF resource provider

This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Have you run ./scripts/ci/test_static.sh locally? (pip install pylint flake8 required)
  • Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

@azuresdkci
Copy link

If this PR is for a new extension or change to an existing extension, use the following to try out the changes in this PR:

docker run -it microsoft/azure-cli:latest
export EXT=<NAME>
pip install --upgrade --target ~/.azure/cliextensions/$EXT "git+https://github.com/leonardbf/azure-cli-extensions.git@master#subdirectory=src/$EXT&egg=$EXT"

@tjprescott
Copy link
Member

Are you working with anyone in the CLI team on this extension?

@williexu
Copy link
Contributor

@tjprescott I've been working with the team :).

/src/sqlvm-preview/ @yareyes

/src/anf-preview/ @williexu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to reference whoever on your team will be the prime codeowner/reviewer?

===================================================================

This package is for the Azure NetApp File (ANF)' module.
i.e. 'az anf'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to add a little more info- i.e. how to install the extension, basic usage, link to docs for the service, etc..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. Install and some examples added. We have no docs to link to yet.


def load_arguments(self, _):
with self.argument_context('anf') as c:
c.argument('resource_group', options_list=['--resource-group', '-g'], required=True, help='The name of the resource group')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need this. The CLI has a default argument context for resource_group

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I'd seen this and fully expected to be able to use either --resource-group or -g. However what I found was that without these lines in the _param file that specifying the command with -g resulted in 'argument --resource-group is required'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the problem, some of your resource_group parameter names are resource_group, while some are resource_group_name. They should all be resource_group_name to take advantage of the CLI's context. Please change the names to all match.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that does indeed make it available for the custom commands. However list, show and delete still require the full --resource-group and cannot use -g without this in the _params.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I believe for the most part, the swagger def name for resource group is resourceGroupName, as indicated: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/common-types/resource-management/v1/types.json#L291
A team member of mine has raised the following PR to address this: Azure/azure-rest-api-specs#5256

If changing the swagger and generating new sdks is impossible for whatever reason, you will also be able to use: https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-core/azure/cli/core/commands/parameters.py#L236-L241

c.argument('volume_name', options_list=['--volume-name', '-v'], required=True, help='The name of the ANF volume')

with self.argument_context('anf') as c:
c.argument('snapshot_name', options_list=['--snapshot-name', '-s'], required=True, help='The name of the ANF snapshot')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention, the CLI also has the shorthand option -n for the target resource of the command. It would be nice if these parameters did the same. For example, for az anf account commands, --account-name should also be referred to by -n.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I will add the -n with a resource specific argument_context.

c.argument('account_name', options_list=['--account-name', '-a'], required=True, help='The name of the ANF account')

with self.argument_context('anf') as c:
c.argument('pool_name', options_list=['--pool-name', '-p'], required=True, help='The name of the ANF pool')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which of these resources can be referred to by a ARM id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required or nice to have?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added --ids for each resource in focus

from codecs import open
from setuptools import setup, find_packages

VERSION = "0.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is still in development, and the goal is to hold off on releasing, this is fine. If the goal is to release for preview soon, this will need to be bumped to 0.1.0.


DEPENDENCIES = [
'azure-mgmt-netapp==0.1.0',
'azure-cli-core'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these dependencies.
azure-cli-core will be taken from the CLI's installation dependency.
For azure-mgmt-netapp, please vendor the sdk in the extension under a vendored_sdks folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will remove and add sdk

@williexu
Copy link
Contributor

Please also add metadata to the extension: https://github.com/Azure/azure-cli/blob/dev/doc/extensions/metadata.md

@leonardbf
Copy link
Contributor Author

Ready for re-review.

Copy link
Contributor

@williexu williexu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more change, otherwise looks good.


def load_arguments(self, _):
with self.argument_context('anf') as c:
c.argument('resource_group', options_list=['--resource-group', '-g'], required=True, help='The name of the resource group')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the problem, some of your resource_group parameter names are resource_group, while some are resource_group_name. They should all be resource_group_name to take advantage of the CLI's context. Please change the names to all match.

* 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

* 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
* 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
Copy link
Contributor

@williexu williexu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I believe for the most part, the swagger def name for resource group is resourceGroupName, as indicated: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/common-types/resource-management/v1/types.json#L291
A team member of mine has raised the following PR to address this: Azure/azure-rest-api-specs#5256

If changing the swagger and generating new sdks is impossible for whatever reason, you will also be able to use: https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-core/azure/cli/core/commands/parameters.py#L236-L241

@leonardbf one last request before merging this PR, could you use the argument type above?

* 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
@leonardbf
Copy link
Contributor Author

Ok. Argument type included @williexu

@williexu williexu merged commit 5a82cfc into Azure:master Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants