Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
7 changes: 7 additions & 0 deletions src/spring-cloud/azext_spring_cloud/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from .vendored_sdks.appplatform.v2021_06_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20210601preview
)
from .vendored_sdks.appplatform.v2021_09_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20210901preview
)


def cf_spring_cloud(cli_ctx, *_):
Expand All @@ -25,6 +28,10 @@ def cf_spring_cloud_20210601preview(cli_ctx, *_):
return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient_20210601preview)


def cf_spring_cloud_20210901preview(cli_ctx, *_):
return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient_20210901preview)


def cf_resource_groups(cli_ctx, subscription_id=None):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id).resource_groups
Expand Down
61 changes: 61 additions & 0 deletions src/spring-cloud/azext_spring_cloud/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,59 @@
short-summary: Regenerate a test-endpoint key for the Azure Spring Cloud.
"""

helps['spring-cloud storage'] = """
type: group
short-summary: Commands to manage Storages in Azure Spring Cloud.
"""

helps['spring-cloud storage add'] = """
type: command
short-summary: Create a new storage in the Azure Spring Cloud.
examples:
- name: Create a Storage resource with your own storage account.
text: az spring-cloud storage add --storage-type StorageAccount --account-name MyAccountName --account-key MyAccountKey -g MyResourceGroup -s MyService -n MyStorageName
"""

helps['spring-cloud storage update'] = """
type: command
short-summary: Update an existing storage in the Azure Spring Cloud.
examples:
- name: Update a Storage resource with new name or new key.
text: az spring-cloud storage update --storage-type StorageAccount --account-name MyAccountName --account-key MyAccountKey -g MyResourceGroup -s MyService -n MyStorageName
"""

helps['spring-cloud storage show'] = """
type: command
short-summary: Get an existing storage in the Azure Spring Cloud.
examples:
- name: Get a Storage resource.
text: az spring-cloud storage show -g MyResourceGroup -s MyService -n MyStorageName
"""

helps['spring-cloud storage list'] = """
type: command
short-summary: List all existing storages in the Azure Spring Cloud.
examples:
- name: List all Storage resources.
text: az spring-cloud storage list -g MyResourceGroup -s MyService
"""

helps['spring-cloud storage remove'] = """
type: command
short-summary: Remove an existing storage in the Azure Spring Cloud.
examples:
- name: Remove a Storage resource.
text: az spring-cloud storage remove -g MyResourceGroup -s MyService -n MyStorageName
"""

helps['spring-cloud storage list-persistent-storage'] = """
type: command
short-summary: List all the persistent storages related to an existing storage in the Azure Spring Cloud.
examples:
- name: list all the persistent-storage related to an existing storage.
text: az spring-cloud storage list-persistent-storage -g MyResourceGroup -s MyService -n MyStorageName
"""

helps['spring-cloud app'] = """
type: group
short-summary: Commands to manage apps in Azure Spring Cloud.
Expand All @@ -96,6 +149,14 @@
text: az spring-cloud app create -n MyApp -s MyCluster -g MyResourceGroup --assign-endpoint true --cpu 2 --memory 3 --instance-count 3
"""

helps['spring-cloud app append-persistent-storage'] = """
type: command
short-summary: Append a new persistent storage to an app in the Azure Spring Cloud.
examples:
- name: Append a new persistent storage to an app.
text: az spring-cloud app append-persistent-storage --persistent-storage-type AzureFileVolume --share-name MyShareName --mount-path /MyMountPath --storage-name MyStorageName -n MyApp -g MyResourceGroup -s MyService
"""

helps['spring-cloud app update'] = """
type: command
short-summary: Update configurations of an app.
Expand Down
29 changes: 29 additions & 0 deletions src/spring-cloud/azext_spring_cloud/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,28 @@ def load_arguments(self, _):
help='Memory resource quantity. Should be 512Mi or #Gi, e.g., 1Gi, 3Gi.')
c.argument('instance_count', type=int,
default=1, help='Number of instance.', validator=validate_instance_count)
c.argument('persistent_storage', type=str,
help='A json file path for the persistent storages to be mounted to the app')

with self.argument_context('spring-cloud app update') as c:
c.argument('assign_endpoint', arg_type=get_three_state_flag(),
help='If true, assign endpoint URL for direct access.',
options_list=['--assign-endpoint', c.deprecate(target='--is-public', redirect='--assign-endpoint', hide=True)])
c.argument('https_only', arg_type=get_three_state_flag(), help='If true, access app via https', default=False)
c.argument('enable_end_to_end_tls', arg_type=get_three_state_flag(), help='If true, enable end to end tls')
c.argument('persistent_storage', type=str,
help='A json file path for the persistent storages to be mounted to the app')

with self.argument_context('spring-cloud app append-persistent-storage') as c:
c.argument('storage_name', type=str,
help='Name of the storage resource you created in Azure Spring Cloud.')
c.argument('persistent_storage_type', options_list=['--persistent-storage-type', '-t'], type=str, help='Type of the persistent storage volumed.')
c.argument('share_name', type=str,
help="The name of the pre-created file share. "
"ShareName should be provided only if the type of the persistent storage volume is AzureFileVolume.")
c.argument('mount_path', type=str, help='The path for the persistent storage volume to be mounted.')
c.argument('mount_options', nargs='+', help='[optional] The mount options for the persistent storage volume.', default=None)
c.argument('read_only', arg_type=get_three_state_flag(), help='[optional] If true, the persistent storage volume will be read only.', default=False)

for scope in ['spring-cloud app update', 'spring-cloud app start', 'spring-cloud app stop', 'spring-cloud app restart', 'spring-cloud app deploy', 'spring-cloud app scale', 'spring-cloud app set-deployment', 'spring-cloud app show-deploy-log']:
with self.argument_context(scope) as c:
Expand Down Expand Up @@ -279,6 +294,20 @@ def prepare_logs_argument(c):
c.argument('deployment', options_list=[
'--deployment', '-d'], help='Name of an existing deployment of the app. Default to the production deployment if not specified.', validator=validate_deployment_name)

with self.argument_context('spring-cloud storage') as c:
c.argument('service', service_name_type)
c.argument('name', help='Name of storage.')

with self.argument_context('spring-cloud storage add') as c:
c.argument('storage_type', help='The type of the torage. e.g. StorageAccount')
c.argument('account_name', help='The name of the storage account. Only available when the type is StorageAccount.')
c.argument('account_key', help='The account key of the storage account. Only available when the type is StorageAccount.')

with self.argument_context('spring-cloud storage update') as c:
c.argument('storage_type', help='The type of the torage. e.g. StorageAccount')
c.argument('account_name', help='The name of the storage account. Only available when the type is StorageAccount.')
c.argument('account_key', help='The account key of the storage account. Only available when the type is StorageAccount.')

with self.argument_context('spring-cloud certificate') as c:
c.argument('service', service_name_type)
c.argument('name', help='Name of certificate.')
Expand Down
11 changes: 11 additions & 0 deletions src/spring-cloud/azext_spring_cloud/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
cf_spring_cloud,
cf_spring_cloud_20201101preview,
cf_spring_cloud_20210601preview,
cf_spring_cloud_20210901preview,
cf_config_servers)
from ._transformers import (transform_spring_cloud_table_output,
transform_app_table_output,
Expand Down Expand Up @@ -69,6 +70,7 @@ def load_command_table(self, _):
g.custom_command('stop', 'app_stop', supports_no_wait=True)
g.custom_command('restart', 'app_restart', supports_no_wait=True)
g.custom_command('logs', 'app_tail_log')
g.custom_command('append-persistent-storage', 'app_append_persistent_storage')

with self.command_group('spring-cloud app identity', client_factory=cf_spring_cloud,
exception_handler=handle_asc_exception) as g:
Expand Down Expand Up @@ -102,6 +104,15 @@ def load_command_table(self, _):
g.custom_command('redis update', 'binding_redis_update')
g.custom_show_command('remove', 'binding_remove')

with self.command_group('spring-cloud storage', client_factory=cf_spring_cloud_20210901preview,
exception_handler=handle_asc_exception) as g:
g.custom_command('list', 'storage_list')
g.custom_show_command('show', 'storage_get')
g.custom_command('add', 'storage_add')
g.custom_command('update', 'storage_update')
g.custom_command('remove', 'storage_remove')
g.custom_command('list-persistent-storage', "storage_list_persistent_storage", table_transformer=transform_app_table_output)

with self.command_group('spring-cloud certificate', client_factory=cf_spring_cloud,
exception_handler=handle_asc_exception) as g:
g.custom_command('add', 'certificate_add')
Expand Down
Loading