Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose --socket-timeout for blob uploads and downloads #6046

Merged
merged 5 commits into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ def _get_mgmt_service_client(cli_ctx,


def get_data_service_client(cli_ctx, service_type, account_name, account_key, connection_string=None,
sas_token=None, endpoint_suffix=None):
sas_token=None, socket_timeout=None, endpoint_suffix=None):
logger.debug('Getting data service client service_type=%s', service_type.__name__)
try:
client_kwargs = {'account_name': account_name,
'account_key': account_key,
'connection_string': connection_string,
'sas_token': sas_token}
if socket_timeout:
client_kwargs['socket_timeout'] = socket_timeout
if endpoint_suffix:
client_kwargs['endpoint_suffix'] = endpoint_suffix
client = service_type(**client_kwargs)
Expand Down
1 change: 1 addition & 0 deletions src/command_modules/azure-cli-storage/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release History
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.

2.0.31
++++++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -65,7 +69,8 @@ def blob_data_service_factory(cli_ctx, kwargs):
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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the unit? Second or millisecond?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

seconds, will add


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.'
Expand Down Expand Up @@ -249,6 +251,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
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)
Expand All @@ -271,6 +274,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
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())
Expand All @@ -279,6 +283,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
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
Expand All @@ -287,6 +292,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('destination', options_list=('--destination', '-d'))
c.argument('source', options_list=('--source', '-s'), validator=process_blob_download_batch_parameters)
c.extra('no_progress', progress_type)
c.extra('socket_timeout', socket_timeout_type)
c.argument('max_connections', type=int)

with self.argument_context('storage blob delete') as c:
Expand Down
Loading