Hello community, here is the log from the commit of package azure-cli-storage for openSUSE:Factory checked in at 2018-10-15 10:44:10 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/azure-cli-storage (Old) and /work/SRC/openSUSE:Factory/.azure-cli-storage.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "azure-cli-storage" Mon Oct 15 10:44:10 2018 rev:4 rq:641106 version:2.2.1 Changes: -------- --- /work/SRC/openSUSE:Factory/azure-cli-storage/azure-cli-storage.changes 2018-05-13 16:03:29.273784234 +0200 +++ /work/SRC/openSUSE:Factory/.azure-cli-storage.new/azure-cli-storage.changes 2018-10-15 10:44:22.859330004 +0200 @@ -1,0 +2,9 @@ +Wed Sep 19 09:26:22 UTC 2018 - John Paul Adrian Glaubitz <[email protected]> + +- New upstream release + + Version 2.2.1 + + For detailed information about changes see the + HISTORY.txt file provided with this package +- Update Requires from setup.py + +------------------------------------------------------------------- Old: ---- azure-cli-storage-2.0.31.tar.gz New: ---- azure-cli-storage-2.2.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ azure-cli-storage.spec ++++++ --- /var/tmp/diff_new_pack.H16FRd/_old 2018-10-15 10:44:23.323329508 +0200 +++ /var/tmp/diff_new_pack.H16FRd/_new 2018-10-15 10:44:23.323329508 +0200 @@ -12,12 +12,12 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: azure-cli-storage -Version: 2.0.31 +Version: 2.2.1 Release: 0 Summary: Microsoft Azure CLI 'storage' Command Module License: MIT @@ -34,8 +34,8 @@ Requires: azure-cli-command-modules-nspkg Requires: azure-cli-core Requires: azure-cli-nspkg -Requires: python3-azure-mgmt-storage >= 1.5.0 -Requires: python3-azure-multiapi-storage >= 0.2.0 +Requires: python3-azure-mgmt-storage >= 2.0.0 +Requires: python3-azure-multiapi-storage >= 0.2.2 Requires: python3-azure-nspkg Conflicts: azure-cli < 2.0.0 ++++++ azure-cli-storage-2.0.31.tar.gz -> azure-cli-storage-2.2.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/HISTORY.rst new/azure-cli-storage-2.2.1/HISTORY.rst --- old/azure-cli-storage-2.0.31/HISTORY.rst 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/HISTORY.rst 2018-08-23 01:07:58.000000000 +0200 @@ -2,6 +2,52 @@ Release History =============== +2.2.1 ++++++ +* `storage share policy show`: exception handling to exit with code 3 upon a missing resource for consistency. + +2.2.0 ++++++ +* BREAKING CHANGE: `storage account show-usage` now requires `--location` parameter and will list by region. +* Make '--resource-group' parameter optional for 'storage account' commands. +* Remove 'Failed precondition' warnings for individual failures in batch commands for single aggregated message. +* blob/file delete-batch commands no longer output array of nulls. +* blob download/upload/delete-batch commands will read sas-token from container url + +2.1.1 ++++++ +* Allows download of large files using a single connection. +* Converted 'show' commands that were missed from failing with exit code 3 upon a missing resource. + +2.1.0 ++++++ +* BREAKING CHANGE: 'show' commands log error message and fail with exit code of 3 upon a missing resource. +* Added `pageRanges` property to `storage blob show` output that will be populated for page blobs. + +2.0.36 +++++++ +* Minor fixes + +2.0.35 +++++++ +* Changed table output for `storage blob download` to be more readable. + +2.0.34 +++++++ +* Added extra mimetypes for json and javascript to be inferred from file extensions. + +2.0.33 +++++++ +* Added completer for `--account-name` argument. +* Fixed problem with `storage entity query`. + +2.0.32 +++++++ +* Allow destination sas-token to apply to source for blob copy if source sas and account key are unspecified. +* Expose --socket-timeout for blob uploads and downloads. +* Treat blob names that start with path separators as relative paths. +* `storage blob copy` Allow --source-sas with starting query char, '?' +* `storage entity query` Fix --marker to accept list of key=values. 2.0.31 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/PKG-INFO new/azure-cli-storage-2.2.1/PKG-INFO --- old/azure-cli-storage-2.0.31/PKG-INFO 2018-04-06 19:33:45.000000000 +0200 +++ new/azure-cli-storage-2.2.1/PKG-INFO 2018-08-23 01:09:25.000000000 +0200 @@ -1,12 +1,11 @@ Metadata-Version: 1.1 Name: azure-cli-storage -Version: 2.0.31 +Version: 2.2.1 Summary: Microsoft Azure Command-Line Tools Storage Command Module Home-page: https://github.com/Azure/azure-cli Author: Microsoft Corporation Author-email: [email protected] License: MIT -Description-Content-Type: UNKNOWN Description: Microsoft Azure CLI 'storage' Command Module ============================================ @@ -20,6 +19,52 @@ Release History =============== + 2.2.1 + +++++ + * `storage share policy show`: exception handling to exit with code 3 upon a missing resource for consistency. + + 2.2.0 + +++++ + * BREAKING CHANGE: `storage account show-usage` now requires `--location` parameter and will list by region. + * Make '--resource-group' parameter optional for 'storage account' commands. + * Remove 'Failed precondition' warnings for individual failures in batch commands for single aggregated message. + * blob/file delete-batch commands no longer output array of nulls. + * blob download/upload/delete-batch commands will read sas-token from container url + + 2.1.1 + +++++ + * Allows download of large files using a single connection. + * Converted 'show' commands that were missed from failing with exit code 3 upon a missing resource. + + 2.1.0 + +++++ + * BREAKING CHANGE: 'show' commands log error message and fail with exit code of 3 upon a missing resource. + * Added `pageRanges` property to `storage blob show` output that will be populated for page blobs. + + 2.0.36 + ++++++ + * Minor fixes + + 2.0.35 + ++++++ + * Changed table output for `storage blob download` to be more readable. + + 2.0.34 + ++++++ + * Added extra mimetypes for json and javascript to be inferred from file extensions. + + 2.0.33 + ++++++ + * Added completer for `--account-name` argument. + * Fixed problem with `storage entity query`. + + 2.0.32 + ++++++ + * Allow destination sas-token to apply to source for blob copy if source sas and account key are unspecified. + * Expose --socket-timeout for blob uploads and downloads. + * Treat blob names that start with path separators as relative paths. + * `storage blob copy` Allow --source-sas with starting query char, '?' + * `storage entity query` Fix --marker to accept list of key=values. 2.0.31 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/__init__.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/__init__.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/__init__.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/__init__.py 2018-08-23 01:07:58.000000000 +0200 @@ -140,23 +140,9 @@ command_name = self.custom_command(name, method_name, **kwargs) self._register_data_plane_account_arguments(command_name) - def get_handler_suppress_404(self): - - # pylint: disable=inconsistent-return-statements - def handler(ex): - from azure.cli.core.profiles import get_sdk - - t_error = get_sdk(self.command_loader.cli_ctx, - ResourceType.DATA_STORAGE, - 'common._error#AzureMissingResourceHttpError') - if isinstance(ex, t_error): - return None - raise ex - - return handler - def _register_data_plane_account_arguments(self, command_name): """ Add parameters required to create a storage client """ + from azure.cli.core.commands.parameters import get_resource_name_completion_list from azure.cli.command_modules.storage._validators import validate_client_parameters command = self.command_loader.command_table.get(command_name, None) if not command: @@ -165,6 +151,7 @@ group_name = 'Storage Account' command.add_argument('account_name', '--account-name', required=False, default=None, arg_group=group_name, + completer=get_resource_name_completion_list('Microsoft.Storage/storageAccounts'), help='Storage account name. Related environment variable: AZURE_STORAGE_ACCOUNT. Must be ' 'used in conjunction with either storage account key or a SAS token. If neither are ' 'present, the command will try to query the storage account key using the ' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/_client_factory.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/_client_factory.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/_client_factory.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/_client_factory.py 2018-08-23 01:07:58.000000000 +0200 @@ -19,14 +19,18 @@ """ -def get_storage_data_service_client(cli_ctx, service, name=None, key=None, connection_string=None, sas_token=None): +def get_storage_data_service_client(cli_ctx, service, name=None, key=None, connection_string=None, sas_token=None, + socket_timeout=None): return get_data_service_client(cli_ctx, service, name, key, connection_string, sas_token, + socket_timeout=socket_timeout, endpoint_suffix=cli_ctx.cloud.suffixes.storage_endpoint) -def generic_data_service_factory(cli_ctx, service, name=None, key=None, connection_string=None, sas_token=None): +def generic_data_service_factory(cli_ctx, service, name=None, key=None, connection_string=None, sas_token=None, + socket_timeout=None): try: - return get_storage_data_service_client(cli_ctx, service, name, key, connection_string, sas_token) + return get_storage_data_service_client(cli_ctx, service, name, key, connection_string, sas_token, + socket_timeout) except ValueError as val_exception: _ERROR_STORAGE_MISSING_INFO = get_sdk(cli_ctx, ResourceType.DATA_STORAGE, 'common._error#_ERROR_STORAGE_MISSING_INFO') @@ -65,7 +69,8 @@ return generic_data_service_factory(cli_ctx, blob_service, kwargs.pop('account_name', None), kwargs.pop('account_key', None), connection_string=kwargs.pop('connection_string', None), - sas_token=kwargs.pop('sas_token', None)) + sas_token=kwargs.pop('sas_token', None), + socket_timeout=kwargs.pop('socket_timeout', None)) def table_data_service_factory(cli_ctx, kwargs): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/_help.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/_help.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/_help.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/_help.py 2018-08-23 01:07:58.000000000 +0200 @@ -1,3 +1,4 @@ +# coding=utf-8 # -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -477,6 +478,15 @@ helps['storage entity query'] = """ type: command short-summary: List entities which satisfy a query. + parameters: + - name: --marker + type: list + short-summary: Space-separated list of key=value pairs. Must contain a nextpartitionkey and a nextrowkey. + long-summary: This value can be retrieved from the + next_marker field of a previous generator object if max_results was + specified and that generator has finished enumerating results. If + specified, this generator will begin returning results from the + point where the previous generator stopped. """ helps['storage file'] = """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/_params.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/_params.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/_params.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/_params.py 2018-08-23 01:07:58.000000000 +0200 @@ -10,9 +10,9 @@ from ._validators import (get_datetime_type, validate_metadata, get_permission_validator, get_permission_help_string, resource_type_type, services_type, validate_entity, validate_select, validate_blob_type, validate_included_datasets, validate_custom_domain, validate_container_public_access, - validate_table_payload_format, validate_key, add_progress_callback, + validate_table_payload_format, validate_key, add_progress_callback, process_resource_group, storage_account_key_options, process_file_download_namespace, process_metric_update_namespace, - get_char_options_validator, validate_bypass, validate_encryption_source) + get_char_options_validator, validate_bypass, validate_encryption_source, validate_marker) def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statements @@ -57,6 +57,8 @@ completer=get_storage_name_completion_list(t_queue_service, 'list_queues')) progress_type = CLIArgumentType(help='Include this flag to disable progress reporting for the command.', action='store_true', validator=add_progress_callback) + socket_timeout_type = CLIArgumentType(help='The socket timeout(secs), used by the service to regulate data flow.', + type=int) sas_help = 'The permissions the SAS grants. Allowed values: {}. Do not use if a stored access policy is ' \ 'referenced with --id that specifies this value. Can be combined.' @@ -82,9 +84,10 @@ c.argument('if_match') c.argument('if_none_match') - for item in ['delete', 'list', 'show', 'show-usage', 'update', 'keys']: + for item in ['delete', 'show', 'update', 'show-connection-string', 'keys', 'network-rule']: with self.argument_context('storage account {}'.format(item)) as c: c.argument('account_name', acct_name_type, options_list=['--name', '-n']) + c.argument('resource_group_name', required=False, validator=process_resource_group) with self.argument_context('storage account check-name') as c: c.argument('name', options_list=['--name', '-n']) @@ -135,7 +138,6 @@ help='Default action to apply when no rule matches.') with self.argument_context('storage account show-connection-string') as c: - c.argument('account_name', acct_name_type, options_list=['--name', '-n']) c.argument('protocol', help='The default endpoint protocol.', arg_type=get_enum_type(['http', 'https'])) c.argument('key_name', options_list=['--key'], help='The key to use.', arg_type=get_enum_type(list(storage_account_key_options.keys()))) @@ -152,10 +154,11 @@ with self.argument_context('storage account network-rule') as c: from ._validators import validate_subnet - c.argument('storage_account_name', acct_name_type, id_part=None) + c.argument('account_name', acct_name_type, id_part=None) c.argument('ip_address', help='IPv4 address or CIDR range.') c.argument('subnet', help='Name or ID of subnet. If name is supplied, `--vnet-name` must be supplied.') c.argument('vnet_name', help='Name of a virtual network.', validator=validate_subnet) + c.argument('action', help='The action of virtual network rule.') with self.argument_context('storage account generate-sas') as c: t_account_permissions = self.get_sdk('common.models#AccountPermissions') @@ -164,7 +167,7 @@ c.argument('resource_types', type=resource_type_type(self)) c.argument('expiry', type=get_datetime_type(True)) c.argument('start', type=get_datetime_type(True)) - c.argument('account_name', acct_name_type, options_list=('--account-name',)) + c.argument('account_name', acct_name_type, options_list=['--account-name']) c.argument('permission', options_list=('--permissions',), help='The permissions the SAS grants. Allowed values: {}. Can be combined.'.format( get_permission_help_string(t_account_permissions)), @@ -198,7 +201,9 @@ with self.argument_context('storage blob list') as c: c.argument('include', validator=validate_included_datasets) - c.argument('num_results', type=int) + c.argument('num_results', type=int, + help='Specifies the maximum number of blobs to return. Must be in range [1,5000]. ' + 'If this parameter is not provided, all blobs will be returned.') c.ignore('marker') # https://github.com/Azure/azure-cli/issues/3745 with self.argument_context('storage blob generate-sas') as c: @@ -249,6 +254,7 @@ arg_type=get_enum_type(get_blob_types())) c.argument('validate_content', action='store_true', min_api='2016-05-31') c.extra('no_progress', progress_type) + c.extra('socket_timeout', socket_timeout_type) # TODO: Remove once #807 is complete. Smart Create Generation requires this parameter. # register_extra_cli_argument('storage blob upload', '_subscription_id', options_list=('--subscription',), # help=argparse.SUPPRESS) @@ -258,19 +264,20 @@ with self.argument_context('storage blob upload-batch') as c: from .sdkutil import get_blob_types - from ._validators import process_blob_upload_batch_parameters t_blob_content_settings = self.get_sdk('blob.models#ContentSettings') c.register_content_settings_argument(t_blob_content_settings, update=False, arg_group='Content Control') c.ignore('source_files', 'destination_container_name') - c.argument('source', options_list=('--source', '-s'), validator=process_blob_upload_batch_parameters) + c.argument('source', options_list=('--source', '-s')) c.argument('destination', options_list=('--destination', '-d')) - c.argument('max_connections', type=int) + c.argument('max_connections', type=int, + help='Maximum number of parallel connections to use when the blob size exceeds 64MB.') c.argument('maxsize_condition', arg_group='Content Control') c.argument('validate_content', action='store_true', min_api='2016-05-31', arg_group='Content Control') c.argument('blob_type', options_list=('--type', '-t'), arg_type=get_enum_type(get_blob_types())) c.extra('no_progress', progress_type) + c.extra('socket_timeout', socket_timeout_type) with self.argument_context('storage blob download') as c: c.argument('file_path', options_list=('--file', '-f'), type=file_type, completer=FilesCompleter()) @@ -279,26 +286,27 @@ c.argument('end_range', type=int) c.argument('validate_content', action='store_true', min_api='2016-05-31') c.extra('no_progress', progress_type) + c.extra('socket_timeout', socket_timeout_type) with self.argument_context('storage blob download-batch') as c: - from azure.cli.command_modules.storage._validators import process_blob_download_batch_parameters - c.ignore('source_container_name') c.argument('destination', options_list=('--destination', '-d')) - c.argument('source', options_list=('--source', '-s'), validator=process_blob_download_batch_parameters) + c.argument('source', options_list=('--source', '-s')) c.extra('no_progress', progress_type) - c.argument('max_connections', type=int) + c.extra('socket_timeout', socket_timeout_type) + c.argument('max_connections', type=int, + help='Maximum number of parallel connections to use when the blob size exceeds 64MB.') with self.argument_context('storage blob delete') as c: from .sdkutil import get_delete_blob_snapshot_type_names c.argument('delete_snapshots', arg_type=get_enum_type(get_delete_blob_snapshot_type_names())) with self.argument_context('storage blob delete-batch') as c: - from azure.cli.command_modules.storage._validators import process_blob_batch_source_parameters - c.ignore('source_container_name') - c.argument('source', options_list=('--source', '-s'), validator=process_blob_batch_source_parameters) - c.argument('delete_snapshots', arg_type=get_enum_type(get_delete_blob_snapshot_type_names())) + c.argument('source', options_list=('--source', '-s')) + c.argument('delete_snapshots', arg_type=get_enum_type(get_delete_blob_snapshot_type_names()), + help='Required if the blob has associated snapshots.') + c.argument('lease_id', help='Required if the blob has an active lease.') with self.argument_context('storage blob lease') as c: c.argument('lease_duration', type=int) @@ -322,8 +330,7 @@ c.register_source_uri_arguments(validator=validate_source_uri) with self.argument_context('storage blob copy start-batch', arg_group='Copy Source') as c: - from azure.cli.command_modules.storage._validators import (get_source_file_or_blob_service_client, - process_blob_copy_batch_namespace) + from azure.cli.command_modules.storage._validators import get_source_file_or_blob_service_client c.argument('source_client', ignore_type, validator=get_source_file_or_blob_service_client) @@ -333,7 +340,6 @@ c.argument('source_sas') c.argument('source_container') c.argument('source_share') - c.argument('prefix', validator=process_blob_copy_batch_namespace) with self.argument_context('storage blob incremental-copy start') as c: from azure.cli.command_modules.storage._validators import process_blob_source_uri @@ -688,3 +694,4 @@ c.argument('accept', default='minimal', validator=validate_table_payload_format, arg_type=get_enum_type(['none', 'minimal', 'full']), help='Specifies how much metadata to include in the response payload.') + c.argument('marker', validator=validate_marker, nargs='+') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/_validators.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/_validators.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/_validators.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/_validators.py 2018-08-23 01:07:58.000000000 +0200 @@ -23,28 +23,34 @@ # pylint: disable=inconsistent-return-statements def _query_account_key(cli_ctx, account_name): """Query the storage account key. This is used when the customer doesn't offer account key but name.""" + rg, scf = _query_account_rg(cli_ctx, account_name) + t_storage_account_keys = get_sdk( + cli_ctx, ResourceType.MGMT_STORAGE, 'models.storage_account_keys#StorageAccountKeys') + + if t_storage_account_keys: + return scf.storage_accounts.list_keys(rg, account_name).key1 + # of type: models.storage_account_list_keys_result#StorageAccountListKeysResult + return scf.storage_accounts.list_keys(rg, account_name).keys[0].value # pylint: disable=no-member + + +def _query_account_rg(cli_ctx, account_name): + """Query the storage account's resource group, which the mgmt sdk requires.""" scf = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_STORAGE) acc = next((x for x in scf.storage_accounts.list() if x.name == account_name), None) if acc: from msrestazure.tools import parse_resource_id - rg = parse_resource_id(acc.id)['resource_group'] - - t_storage_account_keys, t_storage_account_list_keys_results = get_sdk( - cli_ctx, - ResourceType.MGMT_STORAGE, - 'models.storage_account_keys#StorageAccountKeys', - 'models.storage_account_list_keys_result#StorageAccountListKeysResult') - - if t_storage_account_keys: - return scf.storage_accounts.list_keys(rg, account_name).key1 - elif t_storage_account_list_keys_results: - return scf.storage_accounts.list_keys(rg, account_name).keys[0].value # pylint: disable=no-member - else: - raise ValueError("Storage account '{}' not found.".format(account_name)) + return parse_resource_id(acc.id)['resource_group'], scf + raise ValueError("Storage account '{}' not found.".format(account_name)) # region PARAMETER VALIDATORS +def process_resource_group(cmd, namespace): + """Processes the resource group parameter from the account name""" + if namespace.account_name and not namespace.resource_group_name: + namespace.resource_group_name = _query_account_rg(cmd.cli_ctx, namespace.account_name)[0] + + def validate_table_payload_format(cmd, namespace): t_table_payload = get_table_data_type(cmd.cli_ctx, 'table', 'TablePayloadFormat') if namespace.accept: @@ -203,12 +209,12 @@ # source credential clues source_account_name = ns.pop('source_account_name', None) source_account_key = ns.pop('source_account_key', None) - sas = ns.pop('source_sas', None) + source_sas = ns.pop('source_sas', None) # source in the form of an uri uri = ns.get('copy_source', None) if uri: - if any([container, blob, sas, snapshot, share, path, source_account_name, + if any([container, blob, source_sas, snapshot, share, path, source_account_name, source_account_key]): raise ValueError(usage_string.format('Unused parameters are given in addition to the ' 'source URI')) @@ -228,48 +234,41 @@ validate_client_parameters(cmd, namespace) # must run first to resolve storage account + if not source_account_name: + if source_account_key: + raise ValueError(usage_string.format('Source account key is given but account name is not')) + # assume that user intends to copy blob in the same account + source_account_name = ns.get('account_name', None) + # determine if the copy will happen in the same storage account same_account = False - if not source_account_name and source_account_key: - raise ValueError(usage_string.format('Source account key is given but account name is not')) - elif not source_account_name and not source_account_key: - # neither source account name or key is given, assume that user intends to copy blob in - # the same account - same_account = True - source_account_name = ns.get('account_name', None) - source_account_key = ns.get('account_key', None) - elif source_account_name and not source_account_key: + + if not source_account_key and not source_sas: if source_account_name == ns.get('account_name', None): - # the source account name is same as the destination account name same_account = True source_account_key = ns.get('account_key', None) + source_sas = ns.get('sas_token', None) else: - # the source account is different from destination account but the key is missing - # try to query one. + # the source account is different from destination account but the key is missing try to query one. try: source_account_key = _query_account_key(cmd.cli_ctx, source_account_name) except ValueError: raise ValueError('Source storage account {} not found.'.format(source_account_name)) - # else: both source account name and key are given by user - if not source_account_name: - raise ValueError(usage_string.format('Storage account name not found')) - - if not sas: - # generate a sas token even in the same account when the source and destination are not the - # same kind. + # Both source account name and either key or sas (or both) are now available + if not source_sas: + # generate a sas token even in the same account when the source and destination are not the same kind. if valid_file_source and (ns.get('container_name', None) or not same_account): import os dir_name, file_name = os.path.split(path) if path else (None, '') - sas = create_short_lived_file_sas(cmd, source_account_name, source_account_key, share, - dir_name, file_name) + source_sas = create_short_lived_file_sas(cmd, source_account_name, source_account_key, share, + dir_name, file_name) elif valid_blob_source and (ns.get('share_name', None) or not same_account): - sas = create_short_lived_blob_sas(cmd, source_account_name, source_account_key, container, - blob) + source_sas = create_short_lived_blob_sas(cmd, source_account_name, source_account_key, container, blob) query_params = [] - if sas: - query_params.append(sas) + if source_sas: + query_params.append(source_sas.lstrip('?')) if snapshot: query_params.append('snapshot={}'.format(snapshot)) @@ -442,6 +441,29 @@ namespace.entity = values +def validate_marker(namespace): + """ Converts a list of key value pairs into a dictionary. Ensures that required + nextrowkey and nextpartitionkey are included. """ + if not namespace.marker: + return + marker = dict(x.split('=', 1) for x in namespace.marker) + expected_keys = {'nextrowkey', 'nextpartitionkey'} + + for key in marker: + new_key = key.lower() + if new_key in expected_keys: + expected_keys.remove(key.lower()) + val = marker[key] + del marker[key] + marker[new_key] = val + if expected_keys: + import argparse + raise argparse.ArgumentError( + None, 'incorrect usage: marker requires: {}'.format(' '.join(expected_keys))) + + namespace.marker = marker + + def get_file_path_validator(default_file_param=None): """ Creates a namespace validator that splits out 'path' into 'directory_name' and 'file_name'. Allows another path-type parameter to be named which can supply a default filename. """ @@ -654,7 +676,7 @@ del namespace.no_progress -def process_blob_download_batch_parameters(namespace, cmd): +def process_blob_download_batch_parameters(cmd, namespace): """Process the parameters for storage blob download command""" import os @@ -663,24 +685,10 @@ raise ValueError('incorrect usage: destination must be an existing directory') # 2. try to extract account name and container name from source string - process_blob_batch_source_parameters(cmd, namespace) + _process_blob_batch_container_parameters(cmd, namespace) - -def process_blob_batch_source_parameters(cmd, namespace): - """Process the parameters for storage blob download command""" - - # try to extract account name and container name from source string - from .storage_url_helpers import StorageResourceIdentifier - identifier = StorageResourceIdentifier(cmd.cli_ctx.cloud, namespace.source) - - if not identifier.is_url(): - namespace.source_container_name = namespace.source - elif identifier.blob: - raise ValueError('incorrect usage: source should be either container URL or name') - else: - namespace.source_container_name = identifier.container - if namespace.account_name is None: - namespace.account_name = identifier.account_name + # 3. Call validators + add_progress_callback(cmd, namespace) def process_blob_upload_batch_parameters(cmd, namespace): @@ -688,40 +696,11 @@ import os # 1. quick check - if not os.path.exists(namespace.source): - raise ValueError('incorrect usage: source {} does not exist'.format(namespace.source)) - - if not os.path.isdir(namespace.source): - raise ValueError('incorrect usage: source must be a directory') + if not os.path.exists(namespace.source) or not os.path.isdir(namespace.source): + raise ValueError('incorrect usage: source must be an existing directory') # 2. try to extract account name and container name from destination string - from .storage_url_helpers import StorageResourceIdentifier - identifier = StorageResourceIdentifier(cmd.cli_ctx.cloud, namespace.destination) - - if not identifier.is_url(): - namespace.destination_container_name = namespace.destination - elif identifier.blob is not None: - raise ValueError('incorrect usage: destination cannot be a blob url') - else: - namespace.destination_container_name = identifier.container - - if namespace.account_name: - if namespace.account_name != identifier.account_name: - raise ValueError( - 'The given storage account name is not consistent with the account name in the destination URI') - else: - namespace.account_name = identifier.account_name - - if not (namespace.account_key or namespace.sas_token or namespace.connection_string): - validate_client_parameters(cmd, namespace) - - # it is possible the account name be overwritten by the connection string - if namespace.account_name != identifier.account_name: - raise ValueError( - 'The given storage account name is not consistent with the account name in the destination URI') - - if not (namespace.account_key or namespace.sas_token or namespace.connection_string): - raise ValueError('Missing storage account credential information.') + _process_blob_batch_container_parameters(cmd, namespace, source=False) # 3. collect the files to be uploaded namespace.source = os.path.realpath(namespace.source) @@ -743,10 +722,48 @@ else: namespace.blob_type = 'block' + # 5. call other validators + validate_metadata(namespace) + t_blob_content_settings = cmd.loader.get_sdk('blob.models#ContentSettings') + get_content_setting_validator(t_blob_content_settings, update=False)(cmd, namespace) + add_progress_callback(cmd, namespace) + + +def process_blob_delete_batch_parameters(cmd, namespace): + _process_blob_batch_container_parameters(cmd, namespace) + + +def _process_blob_batch_container_parameters(cmd, namespace, source=True): + """Process the container parameters for storage blob batch commands before populating args from environment.""" + if source: + container_arg, container_name_arg = 'source', 'source_container_name' + else: + # destination + container_arg, container_name_arg = 'destination', 'destination_container_name' + + # try to extract account name and container name from source string + from .storage_url_helpers import StorageResourceIdentifier + container_arg_val = getattr(namespace, container_arg) # either a url or name + identifier = StorageResourceIdentifier(cmd.cli_ctx.cloud, container_arg_val) + + if not identifier.is_url(): + setattr(namespace, container_name_arg, container_arg_val) + elif identifier.blob: + raise ValueError('incorrect usage: {} should be either a container URL or name'.format(container_arg)) + else: + setattr(namespace, container_name_arg, identifier.container) + if namespace.account_name is None: + namespace.account_name = identifier.account_name + elif namespace.account_name != identifier.account_name: + raise ValueError('The given storage account name is not consistent with the ' + 'account name in the destination URL') + + # if no sas-token is given and the container url contains one, use it + if not namespace.sas_token and identifier.sas_token: + namespace.sas_token = identifier.sas_token -def process_blob_copy_batch_namespace(namespace): - if namespace.prefix is None and not namespace.recursive: - raise ValueError('incorrect usage: --recursive | --pattern PATTERN') + # Finally, grab missing storage connection parameters from environment variables + validate_client_parameters(cmd, namespace) def process_file_upload_batch_parameters(cmd, namespace): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/commands.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/commands.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/commands.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/commands.py 2018-08-23 01:07:58.000000000 +0200 @@ -10,6 +10,7 @@ multi_service_properties_factory) from azure.cli.command_modules.storage.sdkutil import cosmosdb_table_exists from azure.cli.core.commands import CliCommandType +from azure.cli.core.commands.arm import show_exception_handler from azure.cli.core.profiles import ResourceType @@ -44,15 +45,18 @@ g.command('check-name', 'check_name_availability') g.custom_command('create', 'create_storage_account', min_api='2016-01-01') g.command('delete', 'delete', confirmation=True) - g.command('show', 'get_properties', exception_handler=g.get_handler_suppress_404()) + g.show_command('show', 'get_properties') g.custom_command('list', 'list_storage_accounts') - g.custom_command('show-usage', 'show_storage_account_usage') + g.custom_command('show-usage', 'show_storage_account_usage', min_api='2018-03-01-preview') + g.custom_command('show-usage', 'show_storage_account_usage_no_location', max_api='2016-01-01') g.custom_command('show-connection-string', 'show_storage_account_connection_string') g.generic_update_command('update', getter_name='get_properties', setter_name='update', custom_func_name='update_storage_account', min_api='2016-12-01') g.command('keys renew', 'regenerate_key', transform=lambda x: getattr(x, 'keys', x)) g.command('keys list', 'list_keys', transform=lambda x: getattr(x, 'keys', x)) - g.storage_command('generate-sas', 'generate_shared_access_signature', command_type=cloud_data_plane_sdk) + + with self.command_group('storage account', cloud_data_plane_sdk) as g: + g.storage_command('generate-sas', 'generate_shared_access_signature') with self.command_group('storage account network-rule', storage_account_sdk, custom_command_type=storage_account_custom_type, @@ -66,14 +70,14 @@ g.storage_command('update', 'set_logging') g.storage_command('show', 'get_logging', table_transformer=transform_logging_list_output, - exception_handler=g.get_handler_suppress_404()) + exception_handler=show_exception_handler) with self.command_group('storage metrics', get_custom_sdk('metrics', multi_service_properties_factory)) as g: from ._transformers import transform_metrics_list_output g.storage_command('update', 'set_metrics') g.storage_command('show', 'get_metrics', table_transformer=transform_metrics_list_output, - exception_handler=g.get_handler_suppress_404()) + exception_handler=show_exception_handler) block_blob_sdk = CliCommandType( operations_tmpl='azure.multiapi.storage.blob.blockblobservice#BlockBlobService.{}', @@ -90,15 +94,15 @@ from ._format import transform_boolean_for_table, transform_blob_output from ._transformers import (transform_storage_list_output, transform_url, create_boolean_result_output_transformer) + from ._validators import (process_blob_download_batch_parameters, process_blob_delete_batch_parameters, + process_blob_upload_batch_parameters) g.storage_command('list', 'list_blobs', transform=transform_storage_list_output, table_transformer=transform_blob_output) - g.storage_command('download', 'get_blob_to_path') + g.storage_command('download', 'get_blob_to_path', table_transformer=transform_blob_output) g.storage_command('generate-sas', 'generate_blob_shared_access_signature') g.storage_command('url', 'make_blob_url', transform=transform_url) g.storage_command('snapshot', 'snapshot_blob') - g.storage_command('show', 'get_blob_properties', table_transformer=transform_blob_output, - exception_handler=g.get_handler_suppress_404()) g.storage_command('update', 'set_blob_properties') g.storage_command('exists', 'exists', transform=create_boolean_result_output_transformer('exists')) g.storage_command('delete', 'delete_blob', transform=create_boolean_result_output_transformer('deleted'), @@ -109,11 +113,18 @@ g.storage_custom_command('set-tier', 'set_blob_tier') g.storage_custom_command('upload', 'upload_blob', doc_string_source='blob#BlockBlobService.create_blob_from_path') - g.storage_custom_command('upload-batch', 'storage_blob_upload_batch') - g.storage_custom_command('download-batch', 'storage_blob_download_batch') - g.storage_custom_command('delete-batch', 'storage_blob_delete_batch') + g.storage_custom_command('upload-batch', 'storage_blob_upload_batch', + validator=process_blob_upload_batch_parameters) + g.storage_custom_command('download-batch', 'storage_blob_download_batch', + validator=process_blob_download_batch_parameters) + g.storage_custom_command('delete-batch', 'storage_blob_delete_batch', + validator=process_blob_delete_batch_parameters) + g.storage_custom_command('show', 'show_blob', table_transformer=transform_blob_output, + client_factory=page_blob_service_factory, + doc_string_source='blob#PageBlobService.get_blob_properties', + exception_handler=show_exception_handler) - g.storage_command('metadata show', 'get_blob_metadata', exception_handler=g.get_handler_suppress_404()) + g.storage_command('metadata show', 'get_blob_metadata', exception_handler=show_exception_handler) g.storage_command('metadata update', 'set_blob_metadata') g.storage_command('lease acquire', 'acquire_blob_lease') @@ -145,11 +156,11 @@ custom_command_type=get_custom_sdk('blob', blob_data_service_factory)) as g: g.storage_command('show', 'get_blob_service_properties', transform=lambda x: getattr(x, 'delete_retention_policy', x), - exception_handler=g.get_handler_suppress_404()) + exception_handler=show_exception_handler) g.storage_custom_command('update', 'set_delete_policy') with self.command_group('storage blob service-properties', command_type=base_blob_sdk) as g: - g.storage_command('show', 'get_blob_service_properties', exception_handler=g.get_handler_suppress_404()) + g.storage_command('show', 'get_blob_service_properties', exception_handler=show_exception_handler) with self.command_group('storage container', command_type=block_blob_sdk, custom_command_type=get_custom_sdk('acl', blob_data_service_factory)) as g: @@ -164,7 +175,7 @@ g.storage_command('delete', 'delete_container', transform=create_boolean_result_output_transformer('deleted'), table_transformer=transform_boolean_for_table) g.storage_command('show', 'get_container_properties', table_transformer=transform_container_show, - exception_handler=g.get_handler_suppress_404()) + exception_handler=show_exception_handler) g.storage_command('create', 'create_container', transform=create_boolean_result_output_transformer('created'), table_transformer=transform_boolean_for_table) g.storage_command('generate-sas', 'generate_container_shared_access_signature') @@ -173,7 +184,7 @@ g.storage_command('set-permission', 'set_container_acl') g.storage_command('show-permission', 'get_container_acl', transform=transform_container_permission_output) g.storage_command('metadata update', 'set_container_metadata') - g.storage_command('metadata show', 'get_container_metadata', exception_handler=g.get_handler_suppress_404()) + g.storage_command('metadata show', 'get_container_metadata', exception_handler=show_exception_handler) g.storage_command('lease acquire', 'acquire_container_lease') g.storage_command('lease renew', 'renew_container_lease') @@ -184,7 +195,7 @@ g.storage_custom_command('policy create', 'create_acl_policy') g.storage_custom_command('policy delete', 'delete_acl_policy') g.storage_custom_command('policy update', 'set_acl_policy', min_api='2017-04-17') - g.storage_custom_command('policy show', 'get_acl_policy', exception_handler=g.get_handler_suppress_404()) + g.storage_custom_command('policy show', 'get_acl_policy', exception_handler=show_exception_handler) g.storage_custom_command('policy list', 'list_acl_policies', table_transformer=transform_acl_list_output) file_sdk = CliCommandType( @@ -203,17 +214,17 @@ table_transformer=transform_boolean_for_table) g.storage_command('generate-sas', 'generate_share_shared_access_signature') g.storage_command('stats', 'get_share_stats') - g.storage_command('show', 'get_share_properties', exception_handler=g.get_handler_suppress_404()) + g.storage_command('show', 'get_share_properties', exception_handler=show_exception_handler) g.storage_command('update', 'set_share_properties') g.storage_command('snapshot', 'snapshot_share', min_api='2017-04-17') g.storage_command('exists', 'exists', transform=create_boolean_result_output_transformer('exists')) - g.storage_command('metadata show', 'get_share_metadata', exception_handler=g.get_handler_suppress_404()) + g.storage_command('metadata show', 'get_share_metadata', exception_handler=show_exception_handler) g.storage_command('metadata update', 'set_share_metadata') g.storage_custom_command('policy create', 'create_acl_policy') g.storage_custom_command('policy delete', 'delete_acl_policy') - g.storage_custom_command('policy show', 'get_acl_policy') + g.storage_custom_command('policy show', 'get_acl_policy', exception_handler=show_exception_handler) g.storage_custom_command('policy list', 'list_acl_policies', table_transformer=transform_acl_list_output) g.storage_custom_command('policy update', 'set_acl_policy') @@ -226,9 +237,9 @@ g.storage_command('delete', 'delete_directory', transform=create_boolean_result_output_transformer('deleted'), table_transformer=transform_boolean_for_table) g.storage_command('show', 'get_directory_properties', table_transformer=transform_file_output, - exception_handler=g.get_handler_suppress_404()) + exception_handler=show_exception_handler) g.storage_command('exists', 'exists', transform=create_boolean_result_output_transformer('exists')) - g.storage_command('metadata show', 'get_directory_metadata', exception_handler=g.get_handler_suppress_404()) + g.storage_command('metadata show', 'get_directory_metadata', exception_handler=show_exception_handler) g.storage_command('metadata update', 'set_directory_metadata') g.storage_custom_command('list', 'list_share_directories', transform=transform_file_directory_result(self.cli_ctx), @@ -248,12 +259,12 @@ g.storage_command('url', 'make_file_url', transform=transform_url) g.storage_command('generate-sas', 'generate_file_shared_access_signature') g.storage_command('show', 'get_file_properties', table_transformer=transform_file_output, - exception_handler=g.get_handler_suppress_404()) + exception_handler=show_exception_handler) g.storage_command('update', 'set_file_properties') g.storage_command('exists', 'exists', transform=create_boolean_result_output_transformer('exists')) g.storage_command('download', 'get_file_to_path') g.storage_command('upload', 'create_file_from_path') - g.storage_command('metadata show', 'get_file_metadata', exception_handler=g.get_handler_suppress_404()) + g.storage_command('metadata show', 'get_file_metadata', exception_handler=show_exception_handler) g.storage_command('metadata update', 'set_file_metadata') g.storage_command('copy start', 'copy_file') g.storage_command('copy cancel', 'abort_copy_file') @@ -287,12 +298,12 @@ g.storage_command('stats', 'get_queue_service_stats', min_api='2016-05-31') g.storage_command('exists', 'exists', transform=create_boolean_result_output_transformer('exists')) - g.storage_command('metadata show', 'get_queue_metadata', exception_handler=g.get_handler_suppress_404()) + g.storage_command('metadata show', 'get_queue_metadata', exception_handler=show_exception_handler) g.storage_command('metadata update', 'set_queue_metadata') g.storage_custom_command('policy create', 'create_acl_policy') g.storage_custom_command('policy delete', 'delete_acl_policy') - g.storage_custom_command('policy show', 'get_acl_policy', exception_handler=g.get_handler_suppress_404()) + g.storage_custom_command('policy show', 'get_acl_policy', exception_handler=show_exception_handler) g.storage_custom_command('policy list', 'list_acl_policies', table_transformer=transform_acl_list_output) g.storage_custom_command('policy update', 'set_acl_policy') @@ -333,7 +344,7 @@ g.storage_custom_command('policy create', 'create_acl_policy') g.storage_custom_command('policy delete', 'delete_acl_policy') - g.storage_custom_command('policy show', 'get_acl_policy', exception_handler=g.get_handler_suppress_404()) + g.storage_custom_command('policy show', 'get_acl_policy', exception_handler=show_exception_handler) g.storage_custom_command('policy list', 'list_acl_policies', table_transformer=transform_acl_list_output) g.storage_custom_command('policy update', 'set_acl_policy') @@ -348,5 +359,5 @@ g.storage_command('delete', 'delete_entity', transform=create_boolean_result_output_transformer('deleted'), table_transformer=transform_boolean_for_table) g.storage_command('show', 'get_entity', table_transformer=transform_entity_show, - exception_handler=g.get_handler_suppress_404()) + exception_handler=show_exception_handler) g.storage_custom_command('insert', 'insert_table_entity') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/operations/account.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/operations/account.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/operations/account.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/operations/account.py 2018-08-23 01:07:58.000000000 +0200 @@ -74,7 +74,12 @@ return {'connectionString': connection_string} -def show_storage_account_usage(cmd): +def show_storage_account_usage(cmd, location): + scf = storage_client_factory(cmd.cli_ctx) + return next((x for x in scf.usages.list_by_location(location) if x.name.value == 'StorageAccounts'), None) # pylint: disable=no-member + + +def show_storage_account_usage_no_location(cmd): scf = storage_client_factory(cmd.cli_ctx) return next((x for x in scf.usage.list() if x.name.value == 'StorageAccounts'), None) # pylint: disable=no-member @@ -135,17 +140,17 @@ return params -def list_network_rules(client, resource_group_name, storage_account_name): - sa = client.get_properties(resource_group_name, storage_account_name) +def list_network_rules(client, resource_group_name, account_name): + sa = client.get_properties(resource_group_name, account_name) rules = sa.network_rule_set delattr(rules, 'bypass') delattr(rules, 'default_action') return rules -def add_network_rule(cmd, client, resource_group_name, storage_account_name, action='Allow', subnet=None, +def add_network_rule(cmd, client, resource_group_name, account_name, action='Allow', subnet=None, vnet_name=None, ip_address=None): # pylint: disable=unused-argument - sa = client.get_properties(resource_group_name, storage_account_name) + sa = client.get_properties(resource_group_name, account_name) rules = sa.network_rule_set if subnet: from msrestazure.tools import is_valid_resource_id @@ -164,12 +169,12 @@ StorageAccountUpdateParameters = cmd.get_models('StorageAccountUpdateParameters') params = StorageAccountUpdateParameters(network_rule_set=rules) - return client.update(resource_group_name, storage_account_name, params) + return client.update(resource_group_name, account_name, params) -def remove_network_rule(cmd, client, resource_group_name, storage_account_name, ip_address=None, subnet=None, +def remove_network_rule(cmd, client, resource_group_name, account_name, ip_address=None, subnet=None, vnet_name=None): # pylint: disable=unused-argument - sa = client.get_properties(resource_group_name, storage_account_name) + sa = client.get_properties(resource_group_name, account_name) rules = sa.network_rule_set if subnet: rules.virtual_network_rules = [x for x in rules.virtual_network_rules @@ -179,4 +184,4 @@ StorageAccountUpdateParameters = cmd.get_models('StorageAccountUpdateParameters') params = StorageAccountUpdateParameters(network_rule_set=rules) - return client.update(resource_group_name, storage_account_name, params) + return client.update(resource_group_name, account_name, params) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/operations/blob.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/operations/blob.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/operations/blob.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/operations/blob.py 2018-08-23 01:07:58.000000000 +0200 @@ -113,9 +113,9 @@ def storage_blob_download_batch(client, source, destination, source_container_name, pattern=None, dryrun=False, progress_callback=None, max_connections=2): - def _download_blob(blob_service, container, destination_folder, blob_name): + def _download_blob(blob_service, container, destination_folder, normalized_blob_name, blob_name): # TODO: try catch IO exception - destination_path = os.path.join(destination_folder, blob_name) + destination_path = os.path.join(destination_folder, normalized_blob_name) destination_folder = os.path.dirname(destination_path) if not os.path.exists(destination_folder): mkdir_p(destination_folder) @@ -124,7 +124,17 @@ progress_callback=progress_callback) return blob.name - source_blobs = list(collect_blobs(client, source_container_name, pattern)) + source_blobs = collect_blobs(client, source_container_name, pattern) + blobs_to_download = {} + for blob_name in source_blobs: + # remove starting path seperator and normalize + normalized_blob_name = normalize_blob_file_path(None, blob_name) + if normalized_blob_name in blobs_to_download: + from knack.util import CLIError + raise CLIError('Multiple blobs with download path: `{}`. As a solution, use the `--pattern` parameter ' + 'to select for a subset of blobs to download OR utilize the `storage blob download` ' + 'command instead to download individual blobs.'.format(normalized_blob_name)) + blobs_to_download[normalized_blob_name] = blob_name if dryrun: logger = get_logger(__name__) @@ -137,7 +147,8 @@ logger.warning(' - %s', b) return [] - return list(_download_blob(client, source_container_name, destination, blob) for blob in source_blobs) + return list(_download_blob(client, source_container_name, destination, blob_normed, blobs_to_download[blob_normed]) + for blob_normed in blobs_to_download) def storage_blob_upload_batch(cmd, client, source, destination, pattern=None, # pylint: disable=too-many-locals @@ -189,6 +200,9 @@ if include: results.append(_create_return_result(dst, guessed_content_settings, result)) + num_failures = len(source_files) - len(results) + if num_failures: + logger.warning('%s of %s files not uploaded due to "Failed Precondition"', num_failures, len(source_files)) return results @@ -272,6 +286,25 @@ return type_func[blob_type]() +def show_blob(cmd, client, container_name, blob_name, snapshot=None, lease_id=None, + if_modified_since=None, if_unmodified_since=None, if_match=None, + if_none_match=None, timeout=None): + blob = client.get_blob_properties( + container_name, blob_name, snapshot=snapshot, lease_id=lease_id, + if_modified_since=if_modified_since, if_unmodified_since=if_unmodified_since, if_match=if_match, + if_none_match=if_none_match, timeout=timeout) + + page_ranges = None + if blob.properties.blob_type == cmd.get_models('blob.models#_BlobTypes').PageBlob: + page_ranges = client.get_page_ranges( + container_name, blob_name, snapshot=snapshot, lease_id=lease_id, if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, if_match=if_match, if_none_match=if_none_match, timeout=timeout) + + blob.properties.page_ranges = page_ranges + + return blob + + def storage_blob_delete_batch(client, source, source_container_name, pattern=None, lease_id=None, delete_snapshots=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None, dryrun=False): @@ -290,10 +323,10 @@ } return client.delete_blob(**delete_blob_args) + logger = get_logger(__name__) source_blobs = list(collect_blobs(client, source_container_name, pattern)) if dryrun: - logger = get_logger(__name__) logger.warning('delete action: from %s', source) logger.warning(' pattern %s', pattern) logger.warning(' container %s', source_container_name) @@ -303,7 +336,10 @@ logger.warning(' - %s', blob) return [] - return [result for include, result in (_delete_blob(blob) for blob in source_blobs) if include] + results = [result for include, result in (_delete_blob(blob) for blob in source_blobs) if include] + num_failures = len(source_blobs) - len(results) + if num_failures: + logger.warning('%s of %s blobs not deleted due to "Failed Precondition"', num_failures, len(source_blobs)) def _copy_blob_to_blob_container(blob_service, source_blob_service, destination_container, destination_path, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/operations/file.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/operations/file.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/operations/file.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/operations/file.py 2018-08-23 01:07:58.000000000 +0200 @@ -221,7 +221,8 @@ logger.warning(' - %s/%s', f[0], f[1]) return [] - return [delete_action(f) for f in source_files] + for f in source_files: + delete_action(f) def _create_file_and_directory_from_blob(file_service, blob_service, share, container, sas, blob_name, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/operations/table.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/operations/table.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/operations/table.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/operations/table.py 2018-08-23 01:07:58.000000000 +0200 @@ -11,6 +11,5 @@ return client.insert_or_merge_entity(table_name, entity, timeout) elif if_exists == 'replace': return client.insert_or_replace_entity(table_name, entity, timeout) - else: - from knack.util import CLIError - raise CLIError("Unrecognized value '{}' for --if-exists".format(if_exists)) + from knack.util import CLIError + raise CLIError("Unrecognized value '{}' for --if-exists".format(if_exists)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/util.py new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/util.py --- old/azure-cli-storage-2.0.31/azure/cli/command_modules/storage/util.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure/cli/command_modules/storage/util.py 2018-08-23 01:07:58.000000000 +0200 @@ -177,6 +177,8 @@ return original import mimetypes + mimetypes.add_type('application/json', '.json') + mimetypes.add_type('application/javascript', '.js') content_type, _ = mimetypes.guess_type(file_path) return settings_class( @@ -221,8 +223,5 @@ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304 if ex.status_code not in [304, 412]: raise - from knack.log import get_logger - logger = get_logger(__name__) - logger.warning('Failed precondition') return False, None return wrapper diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure_cli_storage.egg-info/PKG-INFO new/azure-cli-storage-2.2.1/azure_cli_storage.egg-info/PKG-INFO --- old/azure-cli-storage-2.0.31/azure_cli_storage.egg-info/PKG-INFO 2018-04-06 19:33:45.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure_cli_storage.egg-info/PKG-INFO 2018-08-23 01:09:25.000000000 +0200 @@ -1,12 +1,11 @@ Metadata-Version: 1.1 Name: azure-cli-storage -Version: 2.0.31 +Version: 2.2.1 Summary: Microsoft Azure Command-Line Tools Storage Command Module Home-page: https://github.com/Azure/azure-cli Author: Microsoft Corporation Author-email: [email protected] License: MIT -Description-Content-Type: UNKNOWN Description: Microsoft Azure CLI 'storage' Command Module ============================================ @@ -20,6 +19,52 @@ Release History =============== + 2.2.1 + +++++ + * `storage share policy show`: exception handling to exit with code 3 upon a missing resource for consistency. + + 2.2.0 + +++++ + * BREAKING CHANGE: `storage account show-usage` now requires `--location` parameter and will list by region. + * Make '--resource-group' parameter optional for 'storage account' commands. + * Remove 'Failed precondition' warnings for individual failures in batch commands for single aggregated message. + * blob/file delete-batch commands no longer output array of nulls. + * blob download/upload/delete-batch commands will read sas-token from container url + + 2.1.1 + +++++ + * Allows download of large files using a single connection. + * Converted 'show' commands that were missed from failing with exit code 3 upon a missing resource. + + 2.1.0 + +++++ + * BREAKING CHANGE: 'show' commands log error message and fail with exit code of 3 upon a missing resource. + * Added `pageRanges` property to `storage blob show` output that will be populated for page blobs. + + 2.0.36 + ++++++ + * Minor fixes + + 2.0.35 + ++++++ + * Changed table output for `storage blob download` to be more readable. + + 2.0.34 + ++++++ + * Added extra mimetypes for json and javascript to be inferred from file extensions. + + 2.0.33 + ++++++ + * Added completer for `--account-name` argument. + * Fixed problem with `storage entity query`. + + 2.0.32 + ++++++ + * Allow destination sas-token to apply to source for blob copy if source sas and account key are unspecified. + * Expose --socket-timeout for blob uploads and downloads. + * Treat blob names that start with path separators as relative paths. + * `storage blob copy` Allow --source-sas with starting query char, '?' + * `storage entity query` Fix --marker to accept list of key=values. 2.0.31 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/azure_cli_storage.egg-info/requires.txt new/azure-cli-storage-2.2.1/azure_cli_storage.egg-info/requires.txt --- old/azure-cli-storage-2.0.31/azure_cli_storage.egg-info/requires.txt 2018-04-06 19:33:45.000000000 +0200 +++ new/azure-cli-storage-2.2.1/azure_cli_storage.egg-info/requires.txt 2018-08-23 01:09:25.000000000 +0200 @@ -1,3 +1,3 @@ -azure-multiapi-storage==0.2.0 -azure-mgmt-storage==1.5.0 +azure-multiapi-storage==0.2.2 +azure-mgmt-storage==2.0.0rc4 azure-cli-core diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-storage-2.0.31/setup.py new/azure-cli-storage-2.2.1/setup.py --- old/azure-cli-storage-2.0.31/setup.py 2018-04-06 19:33:14.000000000 +0200 +++ new/azure-cli-storage-2.2.1/setup.py 2018-08-23 01:07:58.000000000 +0200 @@ -14,7 +14,7 @@ logger.warn("Wheel is not available, disabling bdist_wheel hook") cmdclass = {} -VERSION = "2.0.31" +VERSION = "2.2.1" CLASSIFIERS = [ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -30,8 +30,8 @@ ] DEPENDENCIES = [ - 'azure-multiapi-storage==0.2.0', - 'azure-mgmt-storage==1.5.0', + 'azure-multiapi-storage==0.2.2', + 'azure-mgmt-storage==2.0.0rc4', 'azure-cli-core' ]
