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

[Breadth Coverage] Support StorageSync in Azure CLI cmdlets #1389

Merged
merged 10 commits into from
Apr 7, 2020

Conversation

jsntcy
Copy link
Member

@jsntcy jsntcy commented Mar 13, 2020

What does this PR do?

What's the key use case?

  • Create ‘Storage Sync Service’ resource
  • Create a ‘Registered Server'
  • Create a ‘Sync Group’
  • Create a 'Cloud Endpoint’ requiring a sync group
  • Create a ‘Server Endpoint’ requiring a sync group and a registered server.

Which commands will be supported?
az storagesync storage-sync-service create\delete\show\list
az storagesync sync-group create\delete\show\list
az storagesync cloud-endpoint create\delete\show\list
az storagesync server-endpoint create\delete\show\list
az storagesync registered-server delete\show\list

Notes
az storagesync registered-server create and az storagesync registered-server reset-certificate are operations mixing cloud and local COM operations. Azure CLI will not support these two commands because of technical limitation. User need use Azure PowerShell or Azure File Share Agent instead for these two commands.


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

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your PR is merged into master branch, a new PR will be created to update src/index.json automatically.
The precondition is to put your code inside this repo and upgrade the version in the PR but do not modify src/index.json.

@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/jsntcy/azure-cli-extensions.git@bc-storagesync-final#subdirectory=src/$EXT&egg=$EXT"

@jsntcy jsntcy self-assigned this Mar 13, 2020
@yonzhan yonzhan added this to the S167 milestone Mar 13, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented Mar 13, 2020

add to S167

@yungezz
Copy link
Member

yungezz commented Mar 15, 2020

just curious, is AzStorageSyncServerCertificate Azure powershell module? Any context it could be Azure Powershell, but not in CLI? #WontFix

az storagesync cloud-endpoint create \
--resource-group rg \
--name cloud-endpoint-name \
--storage-sync-service-name storage-sync-service-name \
Copy link
Member

Choose a reason for hiding this comment

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

storage-sync-service to support both name and id?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, only support name


In reply to: 392648605 [](ancestors = 392648605)

Copy link
Contributor

@mmyyrroonn mmyyrroonn Mar 16, 2020

Choose a reason for hiding this comment

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

it should support both of them. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

support both now


In reply to: 392866324 [](ancestors = 392866324)

"SampleStorageSyncService"
"""

helps['storagesync registered-server wait'] = """
Copy link
Member

@yungezz yungezz Mar 15, 2020

Choose a reason for hiding this comment

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

pair with no-wait? #WontFix

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because we define 'delete' as supporting 'no-wait', we need a 'wait' command to query the 'delete' status.


In reply to: 392648677 [](ancestors = 392648677)

@yonzhan
Copy link
Collaborator

yonzhan commented Mar 15, 2020

just curious, is AzStorageSyncServerCertificate Azure powershell module? Any context it could be Azure Powershell, but not in CLI?

Thanks for the review. After confirm with PM. az storagesync registered-server create and az storagesync registered-server reset-certificate are operations mixing cloud and local COM operations. Azure CLI will not support these two commands because of technical limitation. User need use Azure PowerShell or Azure File Share Agent instead for these two commands.

@jsntcy
Copy link
Member Author

jsntcy commented Mar 16, 2020

This command mixes cloud call and local COM calls which internally call Win32 API, while local COM calls are not easy to implement in Python (PowerShell is using .Net), I forward a email to you about the context.


In reply to: 599177453 [](ancestors = 599177453)

@@ -73,3 +73,5 @@
/src/connectedmachine/ @farehar

/src/ip-group/ @haroldrandom

/src/storagesync/ @jsntcy
Copy link
Member

Choose a reason for hiding this comment

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

Shall we use storage-sync as the extension name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure which one should be as both patterns exist in CLI, and we can have a discussion.


In reply to: 392828794 [](ancestors = 392828794)

Copy link
Member

Choose a reason for hiding this comment

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

There is guideline on command naming. But we can discuss it for sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

az [ group ] [ subgroup ] [ command ] {parameters}
Multi-word subgroups should be hyphenated (e.g. foo-resource instead of fooresource)

  • It seems storagesync is group, but not subgroup.
  • Also discuss within our team, they agree I can keep it without hyphen.
    So I'll keep it without hyphen.

In reply to: 392864381 [](ancestors = 392864381)

validator=parse_server_id)
server_id_type = CLIArgumentType(help='GUID identifying the on-premises server.')

with self.argument_context('storagesync storage-sync-service create') as c:
Copy link
Member

@fengzhou-msft fengzhou-msft Mar 16, 2020

Choose a reason for hiding this comment

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

The prefix of the subcommand name seems redundant. just use storagesync service create? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

After internal discussion, we decide to use 'storagesync create'


In reply to: 392831198 [](ancestors = 392831198)


def list_storagesync_storage_sync_service(client,
resource_group_name=None):
if resource_group_name is not None:
Copy link
Member

@fengzhou-msft fengzhou-msft Mar 16, 2020

Choose a reason for hiding this comment

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

Use if resource_group_name: in order to use the workaround -g= to temparorily disable appending default resource group as we discussed. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

will update it.


In reply to: 392833381 [](ancestors = 392833381)


##### Delete a given storage sync service.
```
az storagesync storage-sync-service delete \
Copy link
Contributor

@mmyyrroonn mmyyrroonn Mar 16, 2020

Choose a reason for hiding this comment

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

should it be az storage-sync service? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

will be az storagesync delete after internal discussion


In reply to: 392865778 [](ancestors = 392865778)


##### Create a new sync group.
```
az storagesync sync-group create \
Copy link
Contributor

Choose a reason for hiding this comment

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

az storage-sync group create ?

Copy link
Member Author

Choose a reason for hiding this comment

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

use az storagesync sync-group create after discussion


In reply to: 392865940 [](ancestors = 392865940)

az storagesync cloud-endpoint create \
--resource-group rg \
--name cloud-endpoint-name \
--storage-sync-service-name storage-sync-service-name \
Copy link
Contributor

@mmyyrroonn mmyyrroonn Mar 16, 2020

Choose a reason for hiding this comment

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

it should support both of them. #Resolved

examples:
- name: Create a new storage sync service "SampleStorageSyncService" in resource group 'SampleResourceGroup'.
text: |-
az storagesync storage-sync-service create --resource-group "SampleResourceGroup" \\
Copy link
Contributor

Choose a reason for hiding this comment

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

better to use MyResourceGroup. Align with other examples.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's generated by codegen, and it should be from swagger samples, in the future, we should just use the rg from swagger without manual update.


In reply to: 392867347 [](ancestors = 392867347)


with self.argument_context('storagesync storage-sync-service delete') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('storage_sync_service_name', storage_sync_service_name_type, options_list=['--name', '-n'])
Copy link
Contributor

@mmyyrroonn mmyyrroonn Mar 16, 2020

Choose a reason for hiding this comment

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

how about adding id_part=name? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

updated


In reply to: 392868000 [](ancestors = 392868000)


with self.argument_context('storagesync sync-group create') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('storage_sync_service_name', storage_sync_service_name_type)
Copy link
Contributor

@mmyyrroonn mmyyrroonn Mar 16, 2020

Choose a reason for hiding this comment

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

is it suitable to support id of storage sync service as well? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

supported now


In reply to: 392868326 [](ancestors = 392868326)

c.argument('cloud_endpoint_name', cloud_endpoint_name_type, options_list=['--name', '-n'])
c.argument('storage_account_resource_id', storage_account_type)
c.argument('azure_file_share_name', azure_file_share_name_type)
c.argument('storage_account_tenant_id', storage_account_tenant_id_type)
Copy link
Contributor

@mmyyrroonn mmyyrroonn Mar 16, 2020

Choose a reason for hiding this comment

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

can we get this tenant id by storage_account_resource_id? #WontFix

Copy link
Member Author

@jsntcy jsntcy Mar 16, 2020

Choose a reason for hiding this comment

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

Yes, I do it in validator: _get_tenant_id():


In reply to: 392868993 [](ancestors = 392868993)

c.argument('server_resource_id', server_resource_id_type)
c.argument('server_local_path', help='The local path of the registered server.')
c.argument('cloud_tiering', arg_type=get_enum_type(['on', 'off']), help='Cloud Tiering.')
c.argument('volume_free_space_percent',
Copy link
Contributor

@mmyyrroonn mmyyrroonn Mar 16, 2020

Choose a reason for hiding this comment

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

The following four parameters are too long. It's also a little bit confused to me. Is it able to add more help messages and examples? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add more help for them and add use these parameters in example


In reply to: 392869872 [](ancestors = 392869872)

body['server_resource_id'] = server_resource_id # str
body['server_local_path'] = server_local_path # str
body['cloud_tiering'] = cloud_tiering # str
body['volume_free_space_percent'] = volume_free_space_percent # number
Copy link
Contributor

@mmyyrroonn mmyyrroonn Mar 16, 2020

Choose a reason for hiding this comment

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

what's the meaning of number? should it be type=int? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

should be int,, number is generated from codegen,


In reply to: 392870777 [](ancestors = 392870777)

'--name {server_endpoint_name} '
'--server-id {server_id} '
'--server-local-path "c:\\users\\syncfolder"',
checks=[JMESPathCheck('provisioningState', 'Succeeded'),
Copy link
Contributor

@mmyyrroonn mmyyrroonn Mar 16, 2020

Choose a reason for hiding this comment

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

this command can accept four arguments. Could we add more tests? Looks like this should be an important command. #WontFix

Copy link
Member Author

@jsntcy jsntcy Mar 17, 2020

Choose a reason for hiding this comment

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

OK, I'll try to add more parameters for test.


In reply to: 392873316 [](ancestors = 392873316)

@yonzhan yonzhan modified the milestones: S167, S168 Mar 28, 2020
@jsntcy jsntcy force-pushed the bc-storagesync-final branch from 0aa238f to b44d532 Compare April 7, 2020 07:34
@jsntcy jsntcy merged commit 73928e0 into Azure:master Apr 7, 2020
ManuInNZ pushed a commit to ManuInNZ/azure-cli-extensions that referenced this pull request Apr 11, 2020
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.

6 participants