Skip to content

Conversation

@leonardbf
Copy link
Contributor

Previously the Azure NetApp Files CLI was an extension only.
R4 standard of RP for GA
Replaces #9365 which was incorrectly applied to master.


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

  • The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).

  • I adhere to the Command Guidelines.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

Requires command review as a new module and due to declaring the commands are GA.

@leonardbf
Copy link
Contributor Author

@tjprescott Comments from command review incorporated in _help.py and code. The account set command was able to be removed by incorporating the subgroup commands as suggested.

@leonardbf
Copy link
Contributor Author

@tjprescott As I have seen every time, all tests involving volume creation, specifically vnet, fail. These were newly run locally in live mode and verified with a playback with all passing (there is also a temporary test, a placeholder for a new test which I will clean up but I was keen to push the new changes for command and code review).

@leonardbf
Copy link
Contributor Author

@tjprescott I have tidied the subgroup test so there is now a test for each of the two new subgroups. From my side then I believe I have addressed all comments from the review to this point. Just for info, I will be on vacation from Wednesday next week for two weeks. It would be great to get an agreed code base before then but if not I will be passing this on to one of my team.

doc_string_source='azure.mgmt.netapp.models#NetAppAccountPatch',
exception_handler=netappfiles_exception_handler)

with self.command_group('netappfiles account active-directory', netappfiles_accounts_sdk) as g:
Copy link
Member

Choose a reason for hiding this comment

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

This should be netappfiles account ad to remain consistent with the existing ad command group for Active Directory.

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 update



1.0.0
++++++++++++++++++
Copy link
Member

Choose a reason for hiding this comment

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

Should be 2.0.0. Shouldn't matter much longer, but still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No clear on why? Isn't this the first release of the new command set, so 1.0.0?

Copy link
Member

Choose a reason for hiding this comment

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

No, all GA modules in the CLI are 2.0. Weird historical reasons.

from azure.cli.core.commands import CliCommandType
netappfiles_custom = CliCommandType(operations_tmpl='azure.cli.command_modules.netappfiles.custom#{}')
super(NetAppFilesCommandsLoader, self).__init__(cli_ctx=cli_ctx,
min_profile='2017-03-10-profile',
Copy link
Member

Choose a reason for hiding this comment

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

This line will need to be removed. Please ping @limingu for what the appropriate convention will be with the updated CLI core.

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've requested info from him

c.argument('account_name', help='The name of the ANF account', id_part=None)

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

Choose a reason for hiding this comment

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

All of these things under a single context (i.e. 'netappfiles') should really be grouped together.

with self.argument_context('netappfiles') as c:
  c.argument('resource_group',...)
  c.argument('tags', …)
  c.argument('account_name', …)
  c.argument('pool_name', …)

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 regroup


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

Choose a reason for hiding this comment

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

This should use the standard resource_group_name_type from the CLI core.

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 add

c.argument('tags', arg_type=tags_type)

with self.argument_context('netappfiles') as c:
c.argument('account_name', options_list=['--account-name', '-a'], required=True, help='The name of the ANF account')
Copy link
Member

Choose a reason for hiding this comment

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

required=True/False should not be necessary anywhere in this file. It is inferred from the command signatures.

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, removed

c.argument('pool_name', id_part='child_name_1', options_list=['--pool-name', '--name', '-n', '-p'], required=True, help='The name of the ANF pool')

with self.argument_context('netappfiles pool list') as c:
c.argument('account_name', options_list=['--account-name', '--name', '-n', '-a'], help='The name of the ANF account', id_part=None)
Copy link
Member

Choose a reason for hiding this comment

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

There's a lot of duplication of metadata throughout. Not crucial, but you could simplify the maintenance of your module using CLIArgumentTypes. Here's a pattern used in Network.

account_name_type = CLIArgumentType(options_list=['--account-name', '-a'], id_part='name', help='Name of the ANF account.')

with self.argument_context('netappfiles') as c:
  c.argument('account_name', account_name_type)

with self.argument_context('netappfiles account') as c:
  c.argument('account_name', account_name_type, options_list=['--account-name', '-a', '-n', '--name'])

with self.argument_context('netappfiles pool list') as c:
  c.argument('account_name', account_name_type, id_part=None)

This will allow you to change the help text for account name in only one place instead of several, for example.

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 update this

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

with self.argument_context('netappfiles') as c:
c.argument('tag', options_list=['--tags'], required=False, help='A list of space separated tags to apply to the account')
Copy link
Member

Choose a reason for hiding this comment

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

This should also use the standard tags_type and should likely be grouped together with other calls under this scope.

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 update

exception_handler=netappfiles_exception_handler)

with self.command_group('netappfiles mount-target', netappfiles_mount_targets_sdk) as g:
g.command('list', 'list')
Copy link
Member

Choose a reason for hiding this comment

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

Unless you plan on having additional "mount-target" commands, this should be netappfiles list-mount-targets.

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 update because I see it is little effort to change and it is more likely that this will be removed rather than new ones added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tjprescott Ok, didn't work quite as expected. Currently the command.py contains a command_group and a command but this change removes the command group. Not sure how this should change

_with self.command_group('netappfiles mount-target', netappfiles_mount_targets_sdk) as g:
     g.command('list', 'list')_

rg = '{rg}'

volume = self.create_volume(account_name, pool_name, volume_name, rg)
snapshot = self.cmd("az netappfiles snapshot create -g %s -a %s -p %s -v %s -s %s -l %s --file-system-id %s" % (rg, account_name, pool_name, volume_name, snapshot_name, LOCATION, volume['fileSystemId'])).get_output_in_json()
Copy link
Member

Choose a reason for hiding this comment

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

In the future, you might wish to refactor your tests to use the authoring patterns described in the docs:
https://github.com/Azure/azure-cli/blob/dev/doc/authoring_tests.md#sample-5-get-more-from-resourcegrouppreparer

The kwargs mechanism is more concise and makes your tests more readable. Not crucial for this PR, but a strong suggestion for future maintainability since new tests will likely borrow the pattern shown here.

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 not change this now but will add a comment in the test as a refactoring consideration for future changes.

@leonardbf
Copy link
Contributor Author

@tjprescott made all the changes locally and will push once I get feedback from @limingu on the remaining item. Thanks.

@leonardbf
Copy link
Contributor Author

All changes made I think.

@leonardbf
Copy link
Contributor Author

I see failures here https://travis-ci.org/Azure/azure-cli/jobs/540766170. I'm not sure about the cause "FAIL: no_ids_for_list_commands". Trying to run locally.

@tjprescott
Copy link
Member

@leonardbf looks like you either need to re-record your tests or that you have randomness in your tests such that they won't play back.

There is guidance for fixing "no --ids in list commands" here:
https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#supporting-the-ids-parameter

It is at the very end of the section.

@leonardbf
Copy link
Contributor Author

@leonardbf looks like you either need to re-record your tests or that you have randomness in your tests such that they won't play back.

There is guidance for fixing "no --ids in list commands" here:
https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#supporting-the-ids-parameter

It is at the very end of the section.

Yeah I have fixed the ids issue. I hadn't added the id_part=None. As for the randomness, I am aware that some of the tests use the random name generation offered but I have tested this before to see if this was the problem. The mount_target test for instance does not have any but still fails. Also they do not fail in record or playback locally, only in the azure pipeline so I'm really not sure how to fix this. It is always the vnet command that fails it seems and has done so in every version of the CLI (extension) so far.

@leonardbf
Copy link
Contributor Author

As well as the possible issue with vnet API version (as emailed) I continue to get the naming failure in the help https://travis-ci.org/Azure/azure-cli/jobs/541009105. All have been removed except these 7 for account despite them working locally. Note that I changed the ordering for pool and volume but that did not work for account so there seems to be an additional consideration. I'm not certain what all the rules are that govern the correct order for this list.

@jaredmoo
Copy link
Contributor

jaredmoo commented Jun 4, 2019

Why is sql module affected by these changes?

@leonardbf
Copy link
Contributor Author

@jaredmoo sql should not be affected. Perhaps there are some changes due to my merge from azure dev into my fork to pull latest due to failing tests (network version).

@leonardbf
Copy link
Contributor Author

@tjprescott I've pulled from azure dev and my tests now pass. However there are other failures which seem to be outside of my changes.

@tomasm9-zz
Copy link

tomasm9-zz commented Jun 12, 2019

Hi, Lenny is on a vacation and I was asked to take over this. Is anything that needs to be done on our end?

@paulomarquesc

@tjprescott
Copy link
Member

@tomasm9 you need to resolve the conflicts and get the CI to pass for us to be able to merge this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants