From de34a23041c7c5d8696246264fe8154f32e3a11e Mon Sep 17 00:00:00 2001 From: annatisch Date: Fri, 27 Jan 2017 09:57:15 -0800 Subject: [PATCH 1/6] node-user -> node user --- .../azure/cli/command_modules/batch/_help.py | 6 +++--- .../azure/cli/command_modules/batch/commands.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py index b53194bd7fa..da36e7fff61 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py @@ -59,7 +59,7 @@ helps['batch certificate'] = """ type: group - short-summary: Commands to manage your Batch certificate. + short-summary: Commands to manage your Batch certificates. """ helps['batch task file'] = """ @@ -92,12 +92,12 @@ short-summary: Commands to manage your Batch job schedules. """ -helps['batch node-user'] = """ +helps['batch node user'] = """ type: group short-summary: Commands to manage your Batch compute node users. """ -helps['batch node-user create'] = """ +helps['batch node user create'] = """ type: command short-summary: Adds a user account to the specified compute node. """ diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/commands.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/commands.py index f6a24f64b9b..3102f6c1eae 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/commands.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/commands.py @@ -115,9 +115,9 @@ cli_batch_data_plane_command('batch task file show', data_path.format('file', 'FileOperations.get_node_file_properties_from_task'), file_client_factory) cli_batch_data_plane_command('batch task file list', data_path.format('file', 'FileOperations.list_from_task'), file_client_factory) -cli_batch_data_plane_command('batch node-user create', data_path.format('compute_node', 'ComputeNodeOperations.add_user'), compute_node_client_factory) -cli_batch_data_plane_command('batch node-user delete', data_path.format('compute_node', 'ComputeNodeOperations.delete_user'), compute_node_client_factory) -cli_batch_data_plane_command('batch node-user set', data_path.format('compute_node', 'ComputeNodeOperations.update_user'), compute_node_client_factory) +cli_batch_data_plane_command('batch node user create', data_path.format('compute_node', 'ComputeNodeOperations.add_user'), compute_node_client_factory) +cli_batch_data_plane_command('batch node user delete', data_path.format('compute_node', 'ComputeNodeOperations.delete_user'), compute_node_client_factory) +cli_batch_data_plane_command('batch node user set', data_path.format('compute_node', 'ComputeNodeOperations.update_user'), compute_node_client_factory) cli_batch_data_plane_command('batch node show', data_path.format('compute_node', 'ComputeNodeOperations.get'), compute_node_client_factory) cli_batch_data_plane_command('batch node list', data_path.format('compute_node', 'ComputeNodeOperations.list'), compute_node_client_factory) cli_batch_data_plane_command('batch node reboot', data_path.format('compute_node', 'ComputeNodeOperations.reboot'), compute_node_client_factory) From 62ddaa79ec53c0b460aec5c8af9c8fc328b02e55 Mon Sep 17 00:00:00 2001 From: annatisch Date: Fri, 27 Jan 2017 12:55:24 -0800 Subject: [PATCH 2/6] Review feedback --- .../command_modules/batch/_command_type.py | 7 ++- .../azure/cli/command_modules/batch/_help.py | 55 +++++++++++++++---- .../cli/command_modules/batch/_params.py | 14 +++-- .../cli/command_modules/batch/_validators.py | 4 +- .../cli/command_modules/batch/commands.py | 4 +- 5 files changed, 62 insertions(+), 22 deletions(-) diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py index 007d3894d96..83b4483b609 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py @@ -307,6 +307,7 @@ def compile_args(self): for name, details in self._arg_tree.items(): if details['type'] == 'bool': details['options']['action'] = 'store_true' + details['options']['help'] += ' True if flag present, otherwise default will be used.' elif details['type'].startswith('['): details['options']['nargs'] = '+' elif details['type'] in ['iso-8601', 'rfc-1123']: @@ -692,9 +693,9 @@ def _load_transformed_arguments(self, handler): yield flattened_arg param = 'json_file' json_class = class_name(arg_type).split('.')[-1] - docstring = "A file containing the {} object in JSON format, " \ - "if this parameter is specified, all other parameters" \ - " are ignored.".format(json_class) + docstring = "A file containing the {} object in JSON format. " \ + "If this parameter is specified, all {} arguments" \ + " are ignored.".format(json_class, group_title(arg[0])) yield (param, CliCommandArgument(param, options_list=[arg_name(param)], required=False, diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py index da36e7fff61..c177fc04a8c 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py @@ -27,6 +27,11 @@ short-summary: Creates a new Batch account with the specified parameters. """ +helps['batch account set'] = """ + type: command + short-summary: Updates the properties of the specified Batch account. +""" + helps['batch account autostorage-keys'] = """ type: group short-summary: Commands to manage the access keys for the auto storage account configured for your Batch account. @@ -42,11 +47,21 @@ short-summary: Commands to manage your Batch applications. """ +helps['batch application set'] = """ + type: command + short-summary: Updates the properties of the specified application. +""" + helps['batch application package'] = """ type: group short-summary: Commands to manage your Batch application packages. """ +helps['batch application summary'] = """ + type: group + short-summary: Commands to view a summary of your Batch application packages. +""" + helps['batch location'] = """ type: group short-summary: Commands to manage Batch service options for a subscription at the region level. @@ -67,6 +82,11 @@ short-summary: Commands to manage your Batch task files. """ +helps['batch task file download'] = """ + type: command + short-summary: Downloads the content of the specified task file. +""" + helps['batch node file'] = """ type: group short-summary: Commands to manage your Batch compute node files. @@ -79,7 +99,12 @@ helps['batch job all-stats'] = """ type: group - short-summary: Commands to manage all the jobs under your Batch account. + short-summary: Commands to manage the statistics of all the jobs under your Batch account +""" + +helps['batch job all-stats show'] = """ + type: command + short-summary: Gets lifetime summary statistics for all of the jobs in the specified account. Statistics are aggregated across all jobs that have ever existed in the account, from account creation to the last update time of the statistics. """ helps['batch job prep-release-status'] = """ @@ -102,6 +127,11 @@ short-summary: Adds a user account to the specified compute node. """ +helps['batch node user set'] = """ + type: command + short-summary: Updates the properties of a user account on the specified compute node. +""" + helps['batch node'] = """ type: group short-summary: Commands to manage your Batch compute nodes. @@ -109,12 +139,12 @@ helps['batch node remote-login-settings'] = """ type: group - short-summary: The remote login settings for a Batch compute node. + short-summary: Commands to manage the remote login settings for a Batch compute node. """ helps['batch node remote-desktop'] = """ type: group - short-summary: The remote desktop protocol for a Batch compute node. + short-summary: Commands to manage the remote desktop protocol for a Batch compute node. """ helps['batch node scheduling'] = """ @@ -129,27 +159,32 @@ helps['batch pool os'] = """ type: group - short-summary: Commands to manage operationg system of your Batch pools. + short-summary: Commands to manage the operating system of your Batch pools. """ helps['batch pool autoscale'] = """ type: group - short-summary: Commands to manage autoscale of your Batch pools. + short-summary: Commands to manage automatic scaling of your Batch pools. """ helps['batch pool all-stats'] = """ type: group - short-summary: Commands to manage all the pools under your Batch account. + short-summary: Commands to manage statistics of all pools under your Batch account. +""" + +helps['batch pool all-stats show'] = """ + type: command + short-summary: Gets lifetime summary statistics for all of the pools in the specified account. Statistics are aggregated across all pools that have ever existed in the account, from account creation to the last update time of the statistics. """ helps['batch pool usage-metrics'] = """ type: group - short-summary: Commands to manage usage metrics of your Batch pools'. + short-summary: Commands to manage usage metrics of your Batch pools. """ helps['batch pool node-agent-skus'] = """ type: group - short-summary: Commands to manage node agent skus of IaaS pools'. + short-summary: Commands to manage node agent skus of pools using a Virtual Machine Configuration. """ helps['batch task'] = """ @@ -179,12 +214,12 @@ helps['batch pool set'] = """ type: command - short-summary: Patch the properties of the specified Batch pool. + short-summary: Updates the properties of the specified pool. Properties that are not specified remain unchanged. """ helps['batch pool reset'] = """ type: command - short-summary: Update the properties of the specified Batch pool. + short-summary: Updates the properties of the specified pool. All updatable properties are replaced with the values specified or cleared if unspecified. """ helps['batch pool resize'] = """ diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py index b75d145b371..ab15ad1bbf6 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py @@ -25,17 +25,21 @@ # PARAMETER REGISTRATIONS -register_cli_argument('batch', 'resource_group_name', resource_group_name_type, completer=None, validator=None) +register_cli_argument('batch', 'resource_group_name', resource_group_name_type, help='Name of the resource group', completer=None, validator=None) register_cli_argument('batch account', 'account_name', batch_name_type, options_list=('--name', '-n')) -register_cli_argument('batch account create', 'location', location_type) -register_cli_argument('batch account create', 'tags', tags_type) +register_cli_argument('batch account create', 'location', location_type, help='The region in which to create the account.') +register_cli_argument('batch account create', 'tags', tags_type, help="Space separated tags in 'key[=value]' format.") register_extra_cli_argument('batch account create', 'storage_account', help='The storage account name or resource id to be used for auto storage account.', validator=storage_account_id) register_cli_argument('batch account set', 'tags', tags_type) register_extra_cli_argument('batch account set', 'storage_account', help='The storage account name or resource id to be used for auto storage account.', validator=storage_account_id) register_cli_argument('batch account keys renew', 'key_name', **enum_choice_list(AccountKeyType)) -register_cli_argument('batch application', 'account_name', batch_name_type, options_list=('--name', '-n'), validator=application_enabled) +register_cli_argument('batch application set', 'application_id', options_list=('--application-id',), help="The ID of the application.") +register_cli_argument('batch application set', 'allow_updates', options_list=('--allow_updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") +register_cli_argument('batch application create', 'allow_updates', options_list=('--allow_updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") register_cli_argument('batch application package create', 'package_file', type=file_type, help='The path of the application package in zip format', completer=FilesCompleter()) -register_cli_argument('batch location quotas show', 'location_name', location_type) +register_cli_argument('batch application package create', 'application_id', options_list=('--application-id',), help="The ID of the application.") +register_cli_argument('batch application package create', 'version', options_list=('--version',), help="The version of the application.") +register_cli_argument('batch location quotas show', 'location_name', location_type, help='The region from which to display the Batch service quotas.') for command in ['list', 'show', 'create', 'set', 'delete', 'package']: register_cli_argument('batch application {}'.format(command), 'account_name', batch_name_type, options_list=('--name', '-n'), validator=application_enabled) diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py index a470af6113f..8824c036423 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py @@ -234,7 +234,7 @@ def validate_pool_settings(ns, parser): paas_sizes = ['small', 'medium', 'large', 'extralarge'] if ns.vm_size and ns.vm_size.lower() in paas_sizes and not ns.os_family: - message = ("The selected VM size in incompatible with Virtual Machine Configuration. " - "Please swap for the IaaS equivalent: Standard_A1 (small), Standard_A2 " + message = ("The selected VM size is incompatible with Virtual Machine Configuration. " + "Please swap for the equivalent: Standard_A1 (small), Standard_A2 " "(medium), Standard_A3 (large), or Standard_A4 (extra large).") raise ValueError(message) diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/commands.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/commands.py index 3102f6c1eae..b179b1cb158 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/commands.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/commands.py @@ -66,7 +66,7 @@ cli_batch_data_plane_command('batch pool usage-metrics list', data_path.format('pool', 'PoolOperations.list_pool_usage_metrics'), pool_client_factory) cli_batch_data_plane_command('batch pool all-stats show', data_path.format('pool', 'PoolOperations.get_all_pools_lifetime_statistics'), pool_client_factory) -cli_batch_data_plane_command('batch pool create', data_path.format('pool', 'PoolOperations.add'), pool_client_factory, validator=validate_pool_settings) +cli_batch_data_plane_command('batch pool create', data_path.format('pool', 'PoolOperations.add'), pool_client_factory, validator=validate_pool_settings, ignore=['pool.cloud_service_configuration.current_os_version']) cli_batch_data_plane_command('batch pool list', data_path.format('pool', 'PoolOperations.list'), pool_client_factory) cli_batch_data_plane_command('batch pool delete', data_path.format('pool', 'PoolOperations.delete'), pool_client_factory) cli_batch_data_plane_command('batch pool show', data_path.format('pool', 'PoolOperations.get'), pool_client_factory) @@ -125,7 +125,7 @@ cli_batch_data_plane_command('batch node scheduling disable', data_path.format('compute_node', 'ComputeNodeOperations.disable_scheduling'), compute_node_client_factory) cli_batch_data_plane_command('batch node scheduling enable', data_path.format('compute_node', 'ComputeNodeOperations.enable_scheduling'), compute_node_client_factory) cli_batch_data_plane_command('batch node remote-login-settings show', data_path.format('compute_node', 'ComputeNodeOperations.get_remote_login_settings'), compute_node_client_factory) -cli_batch_data_plane_command('batch node remote-desktop show', data_path.format('compute_node', 'ComputeNodeOperations.get_remote_desktop'), compute_node_client_factory) +cli_batch_data_plane_command('batch node remote-desktop download', data_path.format('compute_node', 'ComputeNodeOperations.get_remote_desktop'), compute_node_client_factory) cli_batch_data_plane_command('batch node file delete', data_path.format('file', 'FileOperations.delete_from_compute_node'), file_client_factory) cli_batch_data_plane_command('batch node file download', data_path.format('file', 'FileOperations.get_from_compute_node'), file_client_factory) From daaf5637481d8ad1b26591a9ce04c19a6d7aef55 Mon Sep 17 00:00:00 2001 From: annatisch Date: Fri, 27 Jan 2017 13:37:51 -0800 Subject: [PATCH 3/6] More feedback fixes --- .../cli/command_modules/batch/_command_type.py | 13 +++++++++++-- .../azure/cli/command_modules/batch/_validators.py | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py index 83b4483b609..2746365b75e 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py @@ -650,12 +650,16 @@ def _flatten_object(self, path, param_model, conflict_names=[]): # pylint: disa # We only expose a list arg if there's a validator for it # This will fail for 2D arrays - though Batch doesn't have any yet inner_type = details['type'][1:-1] - if inner_type in BASIC_TYPES: # TODO - continue + if inner_type in BASIC_TYPES: + options['help'] += " Space separated values." + self._resolve_conflict( + param_attr, param_attr, path, options, + details['type'], required_attrs, conflict_names) else: inner_type = operations_name(inner_type) try: validator = getattr(validators, inner_type + "_format") + options['help'] += ' ' + validator.__doc__ options['type'] = validator self._resolve_conflict( param_attr, param_attr, path, options, @@ -665,6 +669,10 @@ def _flatten_object(self, path, param_model, conflict_names=[]): # pylint: disa else: attr_model = _load_model(details['type']) if not hasattr(attr_model, '_attribute_map'): # Must be an enum + values_index = options['help'].find(' Possible values include') + if values_index >= 0: + options['choices'] = options['help'][values_index + 25:].split(', ') + options['help'] = options['help'][0:values_index] self._resolve_conflict(param_attr, param_attr, path, options, details['type'], required_attrs, conflict_names) else: @@ -698,6 +706,7 @@ def _load_transformed_arguments(self, handler): " are ignored.".format(json_class, group_title(arg[0])) yield (param, CliCommandArgument(param, options_list=[arg_name(param)], + choices=["test_a", "test_b"], required=False, default=None, type=file_type, diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py index 8824c036423..94f92c2f0a3 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py @@ -37,7 +37,7 @@ def duration_format(value): def metadata_item_format(value): - """Validate listed metadata arguments""" + """Space separated values in 'key=value' format.""" try: data_name, data_value = value.split('=') except ValueError: @@ -49,7 +49,7 @@ def metadata_item_format(value): def environment_setting_format(value): - """Validate listed enviroment settings arguments""" + """Space separated values in 'key=value' format.""" try: env_name, env_value = value.split('=') except ValueError: @@ -61,7 +61,7 @@ def environment_setting_format(value): def application_package_reference_format(value): - """Validate listed application package reference arguments""" + """Space separated application IDs with optional version in 'id[#version]' format.""" app_reference = value.split('#', 1) package = {'application_id': app_reference[0]} try: @@ -72,7 +72,7 @@ def application_package_reference_format(value): def certificate_reference_format(value): - """Validate listed certificate reference arguments""" + """Space separated certificate thumbprints.""" cert = {'thumbprint': value, 'thumbprint_algorithm': 'sha1'} return cert From d3f6b7adae92dd7b310e925d5056f6de618a687a Mon Sep 17 00:00:00 2001 From: annatisch Date: Fri, 27 Jan 2017 14:08:20 -0800 Subject: [PATCH 4/6] pep fixes --- .../command_modules/batch/_command_type.py | 1 - .../cli/command_modules/batch/_params.py | 10 ++++----- .../cli/command_modules/batch/_validators.py | 22 +++++++++---------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py index 2746365b75e..f88d8c8caa2 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py @@ -706,7 +706,6 @@ def _load_transformed_arguments(self, handler): " are ignored.".format(json_class, group_title(arg[0])) yield (param, CliCommandArgument(param, options_list=[arg_name(param)], - choices=["test_a", "test_b"], required=False, default=None, type=file_type, diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py index ab15ad1bbf6..7e2c241412f 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py @@ -33,12 +33,12 @@ register_cli_argument('batch account set', 'tags', tags_type) register_extra_cli_argument('batch account set', 'storage_account', help='The storage account name or resource id to be used for auto storage account.', validator=storage_account_id) register_cli_argument('batch account keys renew', 'key_name', **enum_choice_list(AccountKeyType)) -register_cli_argument('batch application set', 'application_id', options_list=('--application-id',), help="The ID of the application.") -register_cli_argument('batch application set', 'allow_updates', options_list=('--allow_updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") -register_cli_argument('batch application create', 'allow_updates', options_list=('--allow_updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") +register_cli_argument('batch application set', 'application_id', options_list=('--application-id',), help="The ID of the application.") +register_cli_argument('batch application set', 'allow_updates', options_list=('--allow_updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") +register_cli_argument('batch application create', 'allow_updates', options_list=('--allow_updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") register_cli_argument('batch application package create', 'package_file', type=file_type, help='The path of the application package in zip format', completer=FilesCompleter()) -register_cli_argument('batch application package create', 'application_id', options_list=('--application-id',), help="The ID of the application.") -register_cli_argument('batch application package create', 'version', options_list=('--version',), help="The version of the application.") +register_cli_argument('batch application package create', 'application_id', options_list=('--application-id',), help="The ID of the application.") +register_cli_argument('batch application package create', 'version', options_list=('--version',), help="The version of the application.") register_cli_argument('batch location quotas show', 'location_name', location_type, help='The region from which to display the Batch service quotas.') for command in ['list', 'show', 'create', 'set', 'delete', 'package']: diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py index 94f92c2f0a3..97ed538c75f 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_validators.py @@ -90,18 +90,16 @@ def storage_account_id(namespace): from azure.mgmt.storage import StorageManagementClient from azure.cli.core.commands.client_factory import get_mgmt_service_client - if (namespace.storage_account - and not - ('/providers/Microsoft.ClassicStorage/storageAccounts/' in namespace.storage_account - or - '/providers/Microsoft.Storage/storageAccounts/' in namespace.storage_account)): - storage_client = get_mgmt_service_client(StorageManagementClient) - acc = storage_client.storage_accounts.get_properties(namespace.resource_group_name, - namespace.storage_account) - if not acc: - raise ValueError("Batch account named '{}' not found in the resource group '{}'.". - format(namespace.storage_account, namespace.resource_group_name)) - namespace.storage_account = acc.id # pylint: disable=no-member + if (namespace.storage_account and not + ('/providers/Microsoft.ClassicStorage/storageAccounts/' in namespace.storage_account or + '/providers/Microsoft.Storage/storageAccounts/' in namespace.storage_account)): + storage_client = get_mgmt_service_client(StorageManagementClient) + acc = storage_client.storage_accounts.get_properties(namespace.resource_group_name, + namespace.storage_account) + if not acc: + raise ValueError("Batch account named '{}' not found in the resource group '{}'.". + format(namespace.storage_account, namespace.resource_group_name)) + namespace.storage_account = acc.id # pylint: disable=no-member def application_enabled(namespace): From d856a89b2d2388d05de00bc3640a8a84cbf843ac Mon Sep 17 00:00:00 2001 From: annatisch Date: Fri, 27 Jan 2017 14:20:34 -0800 Subject: [PATCH 5/6] fixed underscore --- .../azure/cli/command_modules/batch/_params.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py index 7e2c241412f..b287b5bd99d 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py @@ -34,8 +34,8 @@ register_extra_cli_argument('batch account set', 'storage_account', help='The storage account name or resource id to be used for auto storage account.', validator=storage_account_id) register_cli_argument('batch account keys renew', 'key_name', **enum_choice_list(AccountKeyType)) register_cli_argument('batch application set', 'application_id', options_list=('--application-id',), help="The ID of the application.") -register_cli_argument('batch application set', 'allow_updates', options_list=('--allow_updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") -register_cli_argument('batch application create', 'allow_updates', options_list=('--allow_updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") +register_cli_argument('batch application set', 'allow_updates', options_list=('--allow-updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") +register_cli_argument('batch application create', 'allow_updates', options_list=('--allow-updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") register_cli_argument('batch application package create', 'package_file', type=file_type, help='The path of the application package in zip format', completer=FilesCompleter()) register_cli_argument('batch application package create', 'application_id', options_list=('--application-id',), help="The ID of the application.") register_cli_argument('batch application package create', 'version', options_list=('--version',), help="The version of the application.") From 94a8a070fe4e7f5d6d0d95dc9f25efebca05ef78 Mon Sep 17 00:00:00 2001 From: annatisch Date: Fri, 27 Jan 2017 14:48:46 -0800 Subject: [PATCH 6/6] More touch ups --- .../azure/cli/command_modules/batch/_command_type.py | 12 +++++------- .../azure/cli/command_modules/batch/_help.py | 2 +- .../azure/cli/command_modules/batch/_params.py | 10 +++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py index f88d8c8caa2..28fa63ff6ae 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_command_type.py @@ -23,9 +23,6 @@ extract_args_from_signature) -# TODO: Enum choice lists - - _CLASS_NAME = re.compile(r"<(.*?)>") # Strip model name from class docstring _UNDERSCORE_CASE = re.compile('(?!^)([A-Z]+)') # Convert from CamelCase to underscore_case FLATTEN = 3 # The level of complex object namespace to flatten. @@ -671,7 +668,8 @@ def _flatten_object(self, path, param_model, conflict_names=[]): # pylint: disa if not hasattr(attr_model, '_attribute_map'): # Must be an enum values_index = options['help'].find(' Possible values include') if values_index >= 0: - options['choices'] = options['help'][values_index + 25:].split(', ') + choices = options['help'][values_index + 25:].split(', ') + options['choices'] = [c for c in choices if c != "'unmapped'"] options['help'] = options['help'][0:values_index] self._resolve_conflict(param_attr, param_attr, path, options, details['type'], required_attrs, conflict_names) @@ -746,15 +744,15 @@ def cli_batch_data_plane_command(name, operation, client_factory, transform=None group_name = 'Batch Account' command.cmd.add_argument('account_name', '--account-name', required=False, default=None, validator=validators.validate_client_parameters, arg_group=group_name, - help='Batch account name. Or set by environment variable: ' + help='Batch account name. Alternatively, set by environment variable: ' 'AZURE_BATCH_ACCOUNT') command.cmd.add_argument('account_key', '--account-key', required=False, default=None, arg_group=group_name, help='Batch account key. Must be used in conjunction with Batch ' - 'account name and endpoint. Or set by environment variable: ' + 'account name and endpoint. Alternatively, set by environment variable: ' 'AZURE_BATCH_ACCESS_KEY') command.cmd.add_argument('account_endpoint', '--account-endpoint', required=False, default=None, arg_group=group_name, - help='Batch service endpoint. Or set by environment variable: ' + help='Batch service endpoint. Alternatively, set by environment variable: ' 'AZURE_BATCH_ENDPOINT') command_table[command.cmd.name] = command.cmd diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py index c177fc04a8c..3c75c9dae3f 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_help.py @@ -214,7 +214,7 @@ helps['batch pool set'] = """ type: command - short-summary: Updates the properties of the specified pool. Properties that are not specified remain unchanged. + short-summary: Updates the properties of the specified pool. Properties that are not specified remain unchanged. """ helps['batch pool reset'] = """ diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py index b287b5bd99d..417fab5270c 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/_params.py @@ -29,9 +29,9 @@ register_cli_argument('batch account', 'account_name', batch_name_type, options_list=('--name', '-n')) register_cli_argument('batch account create', 'location', location_type, help='The region in which to create the account.') register_cli_argument('batch account create', 'tags', tags_type, help="Space separated tags in 'key[=value]' format.") -register_extra_cli_argument('batch account create', 'storage_account', help='The storage account name or resource id to be used for auto storage account.', validator=storage_account_id) +register_extra_cli_argument('batch account create', 'storage_account', help='The storage account name or resource id to be used for auto storage.', validator=storage_account_id) register_cli_argument('batch account set', 'tags', tags_type) -register_extra_cli_argument('batch account set', 'storage_account', help='The storage account name or resource id to be used for auto storage account.', validator=storage_account_id) +register_extra_cli_argument('batch account set', 'storage_account', help='The storage account name or resource id to be used for auto storage.', validator=storage_account_id) register_cli_argument('batch account keys renew', 'key_name', **enum_choice_list(AccountKeyType)) register_cli_argument('batch application set', 'application_id', options_list=('--application-id',), help="The ID of the application.") register_cli_argument('batch application set', 'allow_updates', options_list=('--allow-updates',), action="store_true", help="A value indicating whether packages within the application may be overwritten using the same version string. True if flag present.") @@ -76,8 +76,8 @@ for item in ['batch certificate delete', 'batch certificate create', 'batch pool resize', 'batch pool reset', 'batch job list', 'batch task create']: register_extra_cli_argument(item, 'account_name', arg_group='Batch Account', validator=validate_client_parameters, - help='The Batch account name. Or set by environment variable: AZURE_BATCH_ACCOUNT') + help='The Batch account name. Alternatively, set by environment variable: AZURE_BATCH_ACCOUNT') register_extra_cli_argument(item, 'account_key', arg_group='Batch Account', - help='The Batch account key. Or set by environment variable: AZURE_BATCH_ACCESS_KEY') + help='The Batch account key. Alternatively, set by environment variable: AZURE_BATCH_ACCESS_KEY') register_extra_cli_argument(item, 'account_endpoint', arg_group='Batch Account', - help='Batch service endpoint. Or set by environment variable: AZURE_BATCH_ENDPOINT') + help='Batch service endpoint. Alternatively, set by environment variable: AZURE_BATCH_ENDPOINT')