-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
NFSAAS-1708 add initial version of ANF CLI extension
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:
|
NFSAAS-1708 lint fixes
NFSAAS-1708 code owner
Are you working with anyone in the CLI team on this extension? |
@tjprescott I've been working with the team :). |
.github/CODEOWNERS
Outdated
/src/sqlvm-preview/ @yareyes | ||
|
||
/src/anf-preview/ @williexu |
There was a problem hiding this comment.
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?
src/anf-preview/README.rst
Outdated
=================================================================== | ||
|
||
This package is for the Azure NetApp File (ANF)' module. | ||
i.e. 'az anf' |
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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
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') |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/anf-preview/setup.py
Outdated
from codecs import open | ||
from setuptools import setup, find_packages | ||
|
||
VERSION = "0.0.1" |
There was a problem hiding this comment.
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.
src/anf-preview/setup.py
Outdated
|
||
DEPENDENCIES = [ | ||
'azure-mgmt-netapp==0.1.0', | ||
'azure-cli-core' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Please also add metadata to the extension: https://github.com/Azure/azure-cli/blob/dev/doc/extensions/metadata.md |
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
Ready for re-review. |
There was a problem hiding this 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') |
There was a problem hiding this comment.
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
There was a problem hiding this 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#5256If 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
Ok. Argument type included @williexu |
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
./scripts/ci/test_static.sh
locally? (pip install pylint flake8
required)python scripts/ci/test_index.py -q
locally?For new extensions: