-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
sf ARM cli #4132
sf ARM cli #4132
Conversation
@QingChenmsft, |
azure-cli2017.pyproj
Outdated
@@ -14,8 +14,7 @@ | |||
<LaunchProvider>Standard Python launcher</LaunchProvider> | |||
<InterpreterId>MSBuild|{54f4b6dc-0859-46dc-99bb-b275c9d0aca3}|$(MSBuildProjectFullPath)</InterpreterId> | |||
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging> | |||
<CommandLineArguments> | |||
</CommandLineArguments> | |||
<CommandLineArguments>sf cluster new -g tcli5 -l westus --cluster-size 1 --certificate-subject-name test.com --certificate-output-folder c:\test --vm-password User@123456789</CommandLineArguments> |
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 this from the project file.
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.
okay.
@@ -378,7 +378,7 @@ def get_command_table(module_name=None): | |||
If the module is not found, all commands are loaded. | |||
''' | |||
loaded = False | |||
if module_name and module_name not in BLACKLISTED_MODS: | |||
if module_name and module_name not in BLACKLISTED_MODS and module_name != 'sf': |
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.
Add a TODO to remove this later.
Would you remove once the old module has been deprecated?
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.
- name: Specify an existing Certificate resource in a key vault and a custom template to deploy a cluster | ||
text: > | ||
az sf cluster new -g group-name -n cluster1 -l westus --template-file c:\\template.json --parameter-file c:\\parameter.json | ||
--secret-identifier https://chackokv1.vault.azure.net:443/secrets/chackdantestcertificate4/56ec774dc61a462bbc645ffc9b4b225f |
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.
This points to a real keyvault... would suggest something else.
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.
changed.
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.
changed.
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.
This still looks like real data rather than example data.
help='The password of the certificate file.') | ||
register_cli_argument('sf', 'certificate_subject_name',options_list=('--certificate-subject-name', '-sn','-csn'), | ||
help='The subject name of the certificate to be created.') | ||
register_cli_argument('sf', 'vault_resource_group_name',options_list=('--vault-resource-group', '-vg','-vrg'), |
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.
This looks really strange. 3 options for the same argument?
Also, in the CLI I've only seen short form options that have a single char not 2 or 3.
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, short options must only be a single character. If they are multi-character, they should be preceded by --
. And it is highly unusually to have multiple long-options in the CLI. Only when one is going to be deprecated in a future release.
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 other 2.
|
||
from os.path import exists, join | ||
from OpenSSL import crypto | ||
|
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.
Nothing in this file.
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.
removed.
class ServiceFabricTest(ScenarioTest): | ||
def test_list_storage_account(self): | ||
cluster_list = self.cmd('az sf cluster list').get_output_in_json() | ||
assert len(cluster_list) > 0 |
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.
Need more tests than this.
There are several new commands added and lots of custom logic to be tested.
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.
Not only should you cover all of your new commands, you should exercise as many of your parameters as possible. There are many parameter registrations that have nothing more than help='Text..'
. Usually more kwargs are necessary to support relevant scenarios.
'azure.cli.command_modules.servicefabric' | ||
], | ||
install_requires=DEPENDENCIES, | ||
) |
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.
See https://github.com/Azure/azure-cli/blob/master/doc/authoring_command_modules/example_module_template/setup.py on how this should be structured.
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.
done.
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.
Test coverage is inadequate. We need to see the <command> -h
output for each of the "interesting" commands (creates, updates, adds). I would recommend setting up a quick meeting to go over your command tree structure.
azure-cli2017.pyproj
Outdated
@@ -529,7 +547,6 @@ | |||
<Compile Include="command_modules\azure-cli-component\azure\cli\command_modules\component\custom.py" /> | |||
<Compile Include="command_modules\azure-cli-component\azure\cli\command_modules\component\commands.py" /> | |||
<Compile Include="command_modules\azure-cli-component\azure\cli\command_modules\component\_params.py" /> | |||
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\custom.py" /> |
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.
Revert this change.
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.
done.
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.
This still is showing as being removed.
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, should be fixed now.
type: command | ||
short-summary: Add a secondary cluster certificate to the cluster. | ||
examples: | ||
- name: Example1 |
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.
Needs more descriptive name than "Example1" "Example2"...
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.
changed.
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.
Still says Example1, Example2...
# PARAMETER REGISTRATIONS | ||
|
||
register_cli_argument('sf cluster list', 'resource_group_name', resource_group_name_type, | ||
id_part=None, required=False, help='The resouce group name') |
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.
"requiredness" is inferred from the SDK or custom command signature and does not usually need to be specified here unless the SDK is wrong for some reason.
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.
removed.
|
||
register_cli_argument('sf', 'resource_group_name', resource_group_name_type, | ||
id_part=None, required=True, help='The resouce group name') | ||
register_cli_argument('sf', 'cluster_name',options_list=('--name', '--cluster-name','-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.
This should be registered as name_type
. I'm okay with having both --name
and --cluster-name
, although that is uncommon in the CLI.
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.
keep it same as our powershell
register_cli_argument('sf', 'location', | ||
validator=get_default_location_from_resource_group) | ||
|
||
register_cli_argument('sf', 'secret_identifier',options_list=('--secret-identifier', '-si'), |
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.
Short options must be a single letter. Err on the side of no short options.
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.
removed.
|
||
cli_command(__name__, 'sf cluster reliability update', custom_path.format('update_cluster_reliability_level'), factory, no_wait_param=False) | ||
|
||
cli_command(__name__, 'sf cluster durability update', custom_path.format('update_cluster_durability'), factory, no_wait_param=False) |
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 should not have groups (reliability/durability) with only a single command. These could easily be folded into parameters for a sf cluster update
command (which is missing BTW) as --reliability-level
and --durability-level
respectively.
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.
all the command are related to cluster update, we think keeping them this way, which makes user more clear.
|
||
cli_command(__name__, 'sf cluster durability update', custom_path.format('update_cluster_durability'), factory, no_wait_param=False) | ||
|
||
cli_command(__name__, 'sf cluster node-type add', custom_path.format('add_cluster_node_type'), factory, no_wait_param=False) |
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.
There is no node-type remove
command.
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.
this is a bug in our service, we can't have this command ready for now. we will add when we have resolved the issue.
|
||
cli_command(__name__, 'sf cluster node remove', custom_path.format('remove_cluster_node'), factory, no_wait_param=False) | ||
|
||
cli_command(__name__, 'sf cluster upgrade-type set', custom_path.format('update_cluster_upgrade_type'), factory, no_wait_param=False) |
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.
This should also be folded into a sf cluster update
command as a parameter. Additionally, whatever parameters are exposed on update should (if feasible) be supported on create as well.
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.
do not understand, do you mean "'sf cluster upgrade-type set'" should be "sf cluster update upgrade-type"?
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 would need more context on your service, but this looks like an entire command to update one parameter, which should not be done. If upgrade-type is a property of a cluster, then there should be a sf cluster update
command with --upgrade-type
as a parameter.
|
||
cli_command(__name__, 'sf cluster upgrade-type set', custom_path.format('update_cluster_upgrade_type'), factory, no_wait_param=False) | ||
|
||
cli_command(__name__, 'sf application certificate add', custom_path.format('add_app_cert'), factory, no_wait_param=False) |
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.
This is a subcommand with a single subcommand with a single command! Are there going to be more sf application
commands? Are there going to be more sf application certificate
commands? Why are there no plain sf
commands?
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, there will be more for application commands.
class ServiceFabricTest(ScenarioTest): | ||
def test_list_storage_account(self): | ||
cluster_list = self.cmd('az sf cluster list').get_output_in_json() | ||
assert len(cluster_list) > 0 |
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.
Not only should you cover all of your new commands, you should exercise as many of your parameters as possible. There are many parameter registrations that have nothing more than help='Text..'
. Usually more kwargs are necessary to support relevant scenarios.
14998ec
to
879be6f
Compare
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.
There still seem to be numerous issues.
azure-cli2017.pyproj
Outdated
@@ -529,7 +547,6 @@ | |||
<Compile Include="command_modules\azure-cli-component\azure\cli\command_modules\component\custom.py" /> | |||
<Compile Include="command_modules\azure-cli-component\azure\cli\command_modules\component\commands.py" /> | |||
<Compile Include="command_modules\azure-cli-component\azure\cli\command_modules\component\_params.py" /> | |||
<Compile Include="command_modules\azure-cli-network\azure\cli\command_modules\network\custom.py" /> |
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.
This still is showing as being removed.
@@ -0,0 +1,4 @@ | |||
0.0.1 (2017-8-23) |
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.
Should just say "unreleased"
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.
short-summary: List all the cluster resource in the same subscription | ||
""" | ||
|
||
helps["sf cluster new"] = """ |
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.
This should be sf cluster create
not new
.
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.
we want to keep aligned with PowerShell which is New
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.
This will not be accepted. There are 0 "new" commands in the CLI.
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.
okay, i will update, yesterday, i forgot to push the change, you can take a look, i just pushed.
- name: Specify an existing Certificate resource in a key vault and a custom template to deploy a cluster | ||
text: > | ||
az sf cluster new -g group-name -n cluster1 -l westus --template-file c:\\template.json --parameter-file c:\\parameter.json | ||
--secret-identifier https://chackokv1.vault.azure.net:443/secrets/chackdantestcertificate4/56ec774dc61a462bbc645ffc9b4b225f |
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.
This still looks like real data rather than example data.
type: command | ||
short-summary: Add a secondary cluster certificate to the cluster. | ||
examples: | ||
- name: Example1 |
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.
Still says Example1, Example2...
from azure.cli.testsdk.vcr_test_base import (ResourceGroupVCRTestBase, | ||
JMESPathCheck, NoneCheck) | ||
|
||
class ServiceFabricNewClusterTest(ResourceGroupVCRTestBase): |
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.
This is an older test base--these should really use the ScenarioTest base. Don't change them for this PR, but FYI for the future.
checks=[JMESPathCheck('clientCertificateThumbprints[0].certificateThumbprint', test_thumbprint), | ||
JMESPathCheck('clientCertificateThumbprints[0].isAdmin', False)]) | ||
|
||
self.cmd('sf cluster client-certificate remove --resource-group {} --name {} --thumbprints {}'.format(rg,name,test_thumbprint), |
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.
This needs to test the multi-thumbprint scenario, as I have doubts that it will work the way you have things registered.
self.cmd('sf application certificate add --resource-group {} --cluster-name {} --certificate-subject-name test2.com'.format(rg,name), | ||
checks=NoneCheck()) | ||
|
||
if __name__ == '__main__': |
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 might have missed some, but it looks like tests are missing for the following commands:
sf cluster setting remove
, sf cluster durability update
, sf cluster node-type add
, sf cluster node add/remove
register_cli_argument('sf cluster client-certificate', 'certificate_common_name', | ||
help='Specify client certificate common name.') | ||
register_cli_argument('sf cluster client-certificate', 'admin_client_thumbprints', | ||
help='Specify client certificate thumbprint that only has admin permission.') |
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 "Specify..." from these entries.
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.
register_cli_argument('sf client certificate', 'certificate_common_name', | ||
help='Specify client certificate common name.') | ||
register_cli_argument('sf client certificate', 'admin_client_thumbprints', | ||
help='Specify list of client certificate thumbprint that only has admin permission.') |
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.
How do you specify the list? The only valid lists in the CLI are space-separated lists, and the help should call this out.
from ._client_factory import keyvault_client_factory | ||
from ._client_factory import compute_client_factory | ||
from ._client_factory import storage_client_factory | ||
from ._client_factory import network_client_factory |
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.
from ._client_factory import (resource_client_factory, keyvault_client_factory, ...)
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.
will update.
register_cli_argument('sf cluster client-certificate remove', 'thumbprint', | ||
help='a single or list of client certificate thumbprint(s) to be remove.') | ||
register_cli_argument('sf cluster client-certificate remove', 'thumbprints', nargs='+', | ||
help='A single or Space separated list of client certificate thumbprint(s) to be remove.') |
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 can just say "Space separated list of ...". That's the common pattern in the CLI and no one has ever complained that the didn't realize they could use just one. :)
"""for example: [{"section": "NamingService","parameter": "MaxOperationTimeout","value": 1000},{"section": "MaxFileOperationTimeout","parameter": "Max2","value": 1000]""") | ||
register_cli_argument('sf cluster setting set', 'settings_section_description', type=get_json_object, | ||
help='JSON encoded parameters configuration. Use @{file} to load from a file.' | ||
"""for example: [{"section": "NamingService","parameter": "MaxOperationTimeout","value": 1000},{"section": "MaxFileOperationTimeout","parameter": "Max2","value": 1000]""") # pylint: disable=line-too-long |
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.
This would be more appropriate for the parameter long-summary in the helps.py file.
|
||
self.cmd('sf cluster list', checks=[JMESPathCheck('type(@)', 'array')]) | ||
print('####testing list####') |
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.
Please remove these print statements.
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.
Much closer. Still a few commands missing tests, and please remove the print statements in the tests. Otherwise it's little help doc nits that can easily be done in follow-up PRs.
"""for example: [{"section": "NamingService","parameter": "MaxOperationTimeout"}]""") | ||
register_cli_argument('sf cluster setting remove', 'settings_section_description', type=get_json_object, | ||
help='JSON encoded parameters configuration. Use @{file} to load from a file.' | ||
"""for example: [{"section": "NamingService","parameter": "MaxOperationTimeout"}]""") |
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.
Why is a JSON object needed for a remove operation?
checks=[JMESPathCheck('nodeTypes[0].durabilityLevel', durability_level)]) | ||
|
||
print('####testing add app cert###') | ||
self.cmd('sf application certificate add --resource-group {} --cluster-name {} --certificate-subject-name test2.com'.format(rg, name), |
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.
Looks like node-type add
and node add/remove
are still missing.
** Please check this: The .json files you've included, should they be shipped as part of your package or are they only for tests? (e.g. azure/cli/command_modules/servicefabric/template/linux/template.json). If they are required as part of the shipped package, include them e.g. https://github.com/Azure/azure-cli/blob/master/src/command_modules/azure-cli-acr/setup.py#L61. To verify, run |
Hi Derek, |
@QingChenmsft I included an example in my message above. :) |
Codecov Report
@@ Coverage Diff @@
## master #4132 +/- ##
==========================================
- Coverage 70% 69.03% -0.97%
==========================================
Files 475 484 +9
Lines 29919 31039 +1120
Branches 4627 4850 +223
==========================================
+ Hits 20945 21429 +484
- Misses 7490 8030 +540
- Partials 1484 1580 +96
Continue to review full report at Codecov.
|
86b043c
to
f1aeef5
Compare
321ef03
to
e5137c6
Compare
@tjprescott to take a look also. |
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.
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Command Guidelines
(see Authoring Command Modules)