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
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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)

8 changes: 8 additions & 0 deletions src/storagesync/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

0.1.0
++++++
* Initial release.
202 changes: 202 additions & 0 deletions src/storagesync/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
==========================================
# Azure CLI Storage Sync Extension #
This is a extension for StorageSync features.

### How to use ###
Install this extension using the below CLI command
```
az extension add --name storagesync
```

### Included Features
#### Manage storage sync service:

##### Create a new storage sync service.

```
az storagesync storage-sync-service create \
--resource-group rg \
--name storage_sync_service_name \
--location westus \
--tags key1=value1
```

##### 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)

--resource-group rg \
--name storage_sync_service_name
```

##### Show the properties for a given storage sync service.
```
az storagesync storage-sync-service show \
--resource-group rg \
--name storage_sync_service_name
```

##### List all storage sync services in a resource group or a subscription.
```
az storagesync storage-sync-service list
```
```
az storagesync storage-sync-service list \
--resource-group rg
```

#### Manage sync group:

##### 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)

--resource-group rg \
--name sync_group_name \
--storage-sync-service-name storage-sync-service-name
```

##### Delete a given sync group.
```
az storagesync sync-group delete \
--resource-group rg \
--name sync_group_name \
--storage-sync-service-name storage-sync-service-name
```

##### Show the properties for a given sync group.
```
az storagesync sync-group show \
--resource-group rg \
--name sync_group_name \
--storage-sync-service-name storage-sync-service-name
```

##### List all sync groups in a storage sync service.
```
az storagesync sync-group list \
--resource-group rg \
--storage-sync-service-name storage-sync-service-name
```

#### Manage cloud endpoint.

##### Create a new cloud endpoint.
```
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)

--sync-group-name sync-group-name \
--storage-account storageaccountnameorid \
--azure-file-share-name file-share-name
```

##### Delete a given cloud endpoint.
```
az storagesync cloud-endpoint delete \
--resource-group rg \
--name cloud-endpoint-name \
--storage-sync-service-name storage-sync-service-name \
--sync-group-name sync-group-name
```

##### Show the properties for a given cloud endpoint.
```
az storagesync cloud-endpoint show \
--resource-group rg \
--name cloud-endpoint-name \
--storage-sync-service-name storage-sync-service-name \
--sync-group-name sync-group-name
```

##### List all cloud endpoints in a sync group.
```
az storagesync cloud-endpoint list \
--resource-group rg \
--storage-sync-service-name storage-sync-service-name \
--sync-group-name sync-group-name
```

#### Manage cloud endpoint.

##### Create a new server endpoint.
```
az storagesync server-endpoint create \
--resource-group rg \
--name server-endpoint-name \
--storage-sync-service-name storage-sync-service-name \
--sync-group-name sync-group-name \
--server-id server-id \
--server-local-path "d:\\abc"
```

##### Update the properties for a given server endpoint.
```
az storagesync server-endpoint create \
--resource-group rg \
--name server-endpoint-name \
--storage-sync-service-name storage-sync-service-name \
--sync-group-name sync-group-name \
--server-id server-id \
--server-local-path "d:\\abc"
```

##### Delete a given server endpoint.
```
az storagesync server-endpoint delete \
--resource-group rg \
--name server-endpoint-name \
--storage-sync-service-name storage-sync-service-name \
--sync-group-name sync-group-name
```

##### Show the properties for a given server endpoint.
```
az storagesync server-endpoint show \
--resource-group rg \
--name server-endpoint-name \
--storage-sync-service-name storage-sync-service-name \
--sync-group-name sync-group-name
```

##### List all server endpoints in a sync group.
```
az storagesync server-endpoint list \
--resource-group rg \
--storage-sync-service-name storage-sync-service-name \
--sync-group-name sync-group-name
```

#### Manage registered server.

##### Register an on-premises server to a storage sync service.

*This command is not supported in CLI yet. You can use Azure PowerShell command [Register-AzStorageSyncServer](https://docs.microsoft.com/en-us/powershell/module/az.storagesync/register-azstoragesyncserver?view=azps-3.6.1) or [Azure File Sync Agent](https://docs.microsoft.com/en-us/azure/storage/files/storage-sync-files-deployment-guide?tabs=azure-portal#register-windows-server-with-storage-sync-service) instead.*

##### Unregister an on-premises server from it's storage sync service.
```
az storagesync registered-server delete \
--resource-group rg \
--storage-sync-service-name storage-sync-service-name \
--server-id server-id
```

##### Show the properties for a given registered server.
```
az storagesync registered-server show \
--resource-group rg \
--storage-sync-service-name storage-sync-service-name \
--server-id server-id
```

##### List all registered servers for a given storage sync service.
```
az storagesync registered-server list \
--resource-group rg \
--storage-sync-service-name storage-sync-service-name
```

##### Roll the storage sync server certificate used to describe the server identity to the storage sync service.

*This command is not supported in CLI yet. You can use Azure PowerShell command [Reset-AzStorageSyncServerCertificate](https://docs.microsoft.com/en-us/powershell/module/az.storagesync/reset-azstoragesyncservercertificate?view=azps-3.6.1) instead.*

If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues.
32 changes: 32 additions & 0 deletions src/storagesync/azext_storagesync/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader

from azext_storagesync._help import helps # pylint: disable=unused-import


class MicrosoftStorageSyncCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_storagesync._client_factory import cf_storagesync
storagesync_custom = CliCommandType(
operations_tmpl='azext_storagesync.custom#{}',
client_factory=cf_storagesync)
super(MicrosoftStorageSyncCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=storagesync_custom)

def load_command_table(self, args):
from azext_storagesync.commands import load_command_table
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_storagesync._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = MicrosoftStorageSyncCommandsLoader
38 changes: 38 additions & 0 deletions src/storagesync/azext_storagesync/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def cf_storagesync(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from .vendored_sdks.storagesync import StorageSyncManagementClient
return get_mgmt_service_client(cli_ctx, StorageSyncManagementClient)


def cf_storage_sync_services(cli_ctx, *_):
return cf_storagesync(cli_ctx).storage_sync_services


def cf_sync_groups(cli_ctx, *_):
return cf_storagesync(cli_ctx).sync_groups


def cf_cloud_endpoints(cli_ctx, *_):
return cf_storagesync(cli_ctx).cloud_endpoints


def cf_server_endpoints(cli_ctx, *_):
return cf_storagesync(cli_ctx).server_endpoints


def cf_registered_servers(cli_ctx, *_):
return cf_storagesync(cli_ctx).registered_servers


def cf_workflows(cli_ctx, *_):
return cf_storagesync(cli_ctx).workflows


def cf_operation_status(cli_ctx, *_):
return cf_storagesync(cli_ctx).operation_status
Loading