2017-02-07 19:18:16 +03:00
|
|
|
# Copyright (c) Microsoft Corporation
|
|
|
|
#
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# MIT License
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
# copy of this software and associated documentation files (the "Software"),
|
|
|
|
# to deal in the Software without restriction, including without limitation
|
|
|
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
# and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
# Software is furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
# DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
# compat imports
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
from builtins import ( # noqa
|
|
|
|
bytes, dict, int, list, object, range, ascii, chr, hex, input,
|
|
|
|
next, oct, open, pow, round, super, filter, map, zip)
|
|
|
|
# stdlib imports
|
|
|
|
import json
|
|
|
|
import logging
|
|
|
|
try:
|
|
|
|
import pathlib2 as pathlib
|
2017-02-22 21:08:54 +03:00
|
|
|
except ImportError: # noqa
|
2017-02-07 19:18:16 +03:00
|
|
|
import pathlib
|
|
|
|
# non-stdlib imports
|
|
|
|
import click
|
|
|
|
import ruamel.yaml
|
|
|
|
# blobxfer library imports
|
|
|
|
import blobxfer.api
|
|
|
|
import blobxfer.util
|
|
|
|
# local imports
|
2017-06-01 07:01:37 +03:00
|
|
|
try:
|
2017-08-30 00:47:20 +03:00
|
|
|
import cli.settings as settings
|
2017-06-01 07:01:37 +03:00
|
|
|
except (SystemError, ImportError): # noqa
|
2017-08-30 00:47:20 +03:00
|
|
|
try:
|
|
|
|
from . import settings
|
|
|
|
except (SystemError, ImportError): # noqa
|
|
|
|
# for local testing
|
|
|
|
import settings
|
2017-02-07 19:18:16 +03:00
|
|
|
|
|
|
|
# create logger
|
|
|
|
logger = logging.getLogger('blobxfer')
|
|
|
|
# global defines
|
|
|
|
_CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
|
|
|
|
|
|
|
|
|
|
|
class CliContext(object):
|
|
|
|
"""CliContext class: holds context for CLI commands"""
|
|
|
|
def __init__(self):
|
|
|
|
"""Ctor for CliContext"""
|
2017-09-12 05:14:13 +03:00
|
|
|
self.config = None
|
2017-02-07 19:18:16 +03:00
|
|
|
self.cli_options = {}
|
2017-02-15 01:57:29 +03:00
|
|
|
self.credentials = None
|
|
|
|
self.general_options = None
|
2017-10-05 19:19:57 +03:00
|
|
|
self.show_config = False
|
2017-02-07 19:18:16 +03:00
|
|
|
|
2017-06-02 18:16:46 +03:00
|
|
|
def initialize(self, action):
|
|
|
|
# type: (CliContext, settings.TransferAction) -> None
|
2017-02-07 19:18:16 +03:00
|
|
|
"""Initialize context
|
|
|
|
:param CliContext self: this
|
2017-06-02 18:16:46 +03:00
|
|
|
:param settings.TransferAction action: transfer action
|
2017-02-07 19:18:16 +03:00
|
|
|
"""
|
|
|
|
self._init_config()
|
2017-06-02 18:16:46 +03:00
|
|
|
self.general_options = settings.create_general_options(
|
|
|
|
self.config, action)
|
2017-04-11 00:40:03 +03:00
|
|
|
self.credentials = settings.create_azure_storage_credentials(
|
|
|
|
self.config, self.general_options)
|
2017-02-07 19:18:16 +03:00
|
|
|
|
|
|
|
def _read_yaml_file(self, yaml_file):
|
|
|
|
# type: (CliContext, pathlib.Path) -> None
|
|
|
|
"""Read a yaml file into self.config
|
|
|
|
:param CliContext self: this
|
|
|
|
:param pathlib.Path yaml_file: yaml file to load
|
|
|
|
"""
|
|
|
|
with yaml_file.open('r') as f:
|
|
|
|
if self.config is None:
|
|
|
|
self.config = ruamel.yaml.load(
|
|
|
|
f, Loader=ruamel.yaml.RoundTripLoader)
|
|
|
|
else:
|
|
|
|
self.config = blobxfer.util.merge_dict(
|
2017-06-01 23:55:54 +03:00
|
|
|
ruamel.yaml.load(f, Loader=ruamel.yaml.RoundTripLoader),
|
|
|
|
self.config)
|
2017-02-07 19:18:16 +03:00
|
|
|
|
|
|
|
def _init_config(self):
|
|
|
|
# type: (CliContext) -> None
|
|
|
|
"""Initializes configuration of the context
|
|
|
|
:param CliContext self: this
|
|
|
|
"""
|
|
|
|
# load yaml config file into memory
|
2017-06-01 23:55:54 +03:00
|
|
|
if blobxfer.util.is_not_empty(self.cli_options['yaml_config']):
|
|
|
|
yaml_config = pathlib.Path(self.cli_options['yaml_config'])
|
|
|
|
self._read_yaml_file(yaml_config)
|
2017-10-03 04:09:02 +03:00
|
|
|
if self.config is None:
|
|
|
|
self.config = {}
|
2017-10-13 01:04:20 +03:00
|
|
|
# merge "global" cli options with config
|
|
|
|
settings.merge_global_settings(self.config, self.cli_options)
|
2017-04-08 00:38:57 +03:00
|
|
|
# set log file if specified
|
2017-10-13 17:21:11 +03:00
|
|
|
logfile = self.config['options'].get('log_file', None)
|
|
|
|
blobxfer.util.setup_logger(logger, logfile)
|
2017-10-05 19:19:57 +03:00
|
|
|
# set verbose logging
|
2017-05-30 22:59:39 +03:00
|
|
|
if self.config['options'].get('verbose', False):
|
2017-04-08 00:38:57 +03:00
|
|
|
blobxfer.util.set_verbose_logger_handlers()
|
2017-10-13 17:21:11 +03:00
|
|
|
# set azure storage logging level
|
2017-10-05 18:08:36 +03:00
|
|
|
azstorage_logger = logging.getLogger('azure.storage')
|
2017-10-13 17:21:11 +03:00
|
|
|
if self.config['options'].get('enable_azure_storage_logger', False):
|
|
|
|
blobxfer.util.setup_logger(azstorage_logger, logfile)
|
|
|
|
azstorage_logger.setLevel(logging.INFO)
|
|
|
|
else:
|
|
|
|
# disable azure storage logging: setting logger level to CRITICAL
|
|
|
|
# effectively disables logging from azure storage
|
|
|
|
azstorage_logger.setLevel(logging.CRITICAL)
|
2017-10-13 01:04:20 +03:00
|
|
|
# output mixed config
|
2017-10-05 19:19:57 +03:00
|
|
|
if self.show_config:
|
2017-10-13 01:04:20 +03:00
|
|
|
logger.debug('config: \n{}'.format(
|
|
|
|
json.dumps(self.config, indent=4)))
|
|
|
|
logger.debug('cli config: \n{}'.format(
|
|
|
|
json.dumps(
|
|
|
|
self.cli_options[self.cli_options['_action']],
|
|
|
|
indent=4, sort_keys=True)))
|
2017-10-05 19:19:57 +03:00
|
|
|
del self.show_config
|
2017-02-07 19:18:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
# create a pass decorator for shared context between commands
|
|
|
|
pass_cli_context = click.make_pass_decorator(CliContext, ensure=True)
|
|
|
|
|
|
|
|
|
2017-06-01 23:55:54 +03:00
|
|
|
def _config_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['yaml_config'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--config',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-06-01 23:55:54 +03:00
|
|
|
help='YAML configuration file',
|
|
|
|
envvar='BLOBXFER_CONFIG_FILE',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-24 01:57:01 +03:00
|
|
|
def _crypto_processes_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['crypto_processes'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--crypto-processes',
|
|
|
|
expose_value=False,
|
|
|
|
type=int,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-05-25 19:01:57 +03:00
|
|
|
help='Concurrent crypto processes (download only)',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _disk_threads_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['disk_threads'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--disk-threads',
|
|
|
|
expose_value=False,
|
|
|
|
type=int,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-05-25 19:01:57 +03:00
|
|
|
help='Concurrent disk threads',
|
2017-02-24 01:57:01 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-10-13 17:21:11 +03:00
|
|
|
def _enable_azure_storage_logger_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['enable_azure_storage_logger'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--enable-azure-storage-logger',
|
|
|
|
expose_value=False,
|
|
|
|
is_flag=True,
|
|
|
|
default=False,
|
|
|
|
help='Enable Azure Storage logger output [False]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-04-08 00:38:57 +03:00
|
|
|
def _log_file_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['log_file'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--log-file',
|
|
|
|
expose_value=False,
|
|
|
|
default=None,
|
2017-06-02 18:16:46 +03:00
|
|
|
help='Log to file specified; this must be specified for progress '
|
|
|
|
'bar to show',
|
2017-04-08 00:38:57 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-10-26 19:09:20 +03:00
|
|
|
def _max_retries_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['max_retries'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--max-retries',
|
|
|
|
expose_value=False,
|
|
|
|
type=int,
|
|
|
|
default=None,
|
|
|
|
help='Maximum number of retries for a request; negative values are '
|
|
|
|
'unlimited [10]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-24 01:57:01 +03:00
|
|
|
def _md5_processes_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['md5_processes'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--md5-processes',
|
|
|
|
expose_value=False,
|
|
|
|
type=int,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-24 01:57:01 +03:00
|
|
|
help='Concurrent MD5 processes',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def _progress_bar_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['progress_bar'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--progress-bar/--no-progress-bar',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-06-02 18:16:46 +03:00
|
|
|
help='Display progress bar instead of console logs; log file must '
|
|
|
|
'be specified [True]',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-10-25 02:52:56 +03:00
|
|
|
def _proxy_host_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['proxy_host'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--proxy-host',
|
|
|
|
expose_value=False,
|
|
|
|
default=None,
|
|
|
|
help='Proxy host in the format of IP:Port',
|
|
|
|
envvar='BLOBXFER_PROXY_HOST',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _proxy_password_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['proxy_password'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--proxy-password',
|
|
|
|
expose_value=False,
|
|
|
|
default=None,
|
|
|
|
help='Proxy password',
|
|
|
|
envvar='BLOBXFER_PROXY_PASSWORD',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _proxy_username_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['proxy_username'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--proxy-username',
|
|
|
|
expose_value=False,
|
|
|
|
default=None,
|
|
|
|
help='Proxy username',
|
|
|
|
envvar='BLOBXFER_PROXY_USERNAME',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-03-01 00:27:20 +03:00
|
|
|
def _resume_file_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['resume_file'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--resume-file',
|
|
|
|
expose_value=False,
|
|
|
|
default=None,
|
|
|
|
help='Save or use resume file specified',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-10-05 19:19:57 +03:00
|
|
|
def _show_config_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.show_config = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--show-config',
|
|
|
|
expose_value=False,
|
|
|
|
is_flag=True,
|
|
|
|
help='Show configuration',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def _timeout_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['timeout'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--timeout',
|
|
|
|
expose_value=False,
|
2017-08-28 20:23:15 +03:00
|
|
|
type=float,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-08-28 20:23:15 +03:00
|
|
|
help='Timeout, in seconds, applied to both connect and read '
|
|
|
|
'operations',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-24 01:57:01 +03:00
|
|
|
def _transfer_threads_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['transfer_threads'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--transfer-threads',
|
|
|
|
expose_value=False,
|
|
|
|
type=int,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-24 01:57:01 +03:00
|
|
|
help='Concurrent transfer threads',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def _verbose_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['verbose'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'-v', '--verbose',
|
|
|
|
expose_value=False,
|
|
|
|
is_flag=True,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Verbose output',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2018-04-16 18:55:20 +03:00
|
|
|
def _quiet_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['quiet'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'-q', '--quiet',
|
|
|
|
expose_value=False,
|
|
|
|
is_flag=True,
|
|
|
|
default=None,
|
|
|
|
help='Quiet mode',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-06-01 23:55:54 +03:00
|
|
|
def _local_resource_option(f):
|
2017-02-07 19:18:16 +03:00
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
2017-06-01 23:55:54 +03:00
|
|
|
clictx.cli_options['local_resource'] = value
|
2017-02-07 19:18:16 +03:00
|
|
|
return value
|
2017-06-01 23:55:54 +03:00
|
|
|
return click.option(
|
2017-06-02 18:16:46 +03:00
|
|
|
'--local-path',
|
2017-06-01 23:55:54 +03:00
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-06-02 18:16:46 +03:00
|
|
|
help='Local path; use - for stdin',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-06-02 18:16:46 +03:00
|
|
|
def _storage_account_option(f):
|
2017-02-07 19:18:16 +03:00
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['storage_account'] = value
|
|
|
|
return value
|
2017-06-01 23:55:54 +03:00
|
|
|
return click.option(
|
2017-06-02 18:16:46 +03:00
|
|
|
'--storage-account',
|
2017-06-01 23:55:54 +03:00
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-06-01 23:55:54 +03:00
|
|
|
help='Storage account name',
|
2017-06-02 18:16:46 +03:00
|
|
|
envvar='BLOBXFER_STORAGE_ACCOUNT',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-06-01 23:55:54 +03:00
|
|
|
def _remote_path_option(f):
|
2017-02-07 19:18:16 +03:00
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['remote_path'] = value
|
|
|
|
return value
|
2017-06-01 23:55:54 +03:00
|
|
|
return click.option(
|
|
|
|
'--remote-path',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-06-01 23:55:54 +03:00
|
|
|
help='Remote path on Azure Storage',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-06-01 23:55:54 +03:00
|
|
|
def common_options(f):
|
|
|
|
f = _verbose_option(f)
|
|
|
|
f = _transfer_threads_option(f)
|
|
|
|
f = _timeout_option(f)
|
2017-10-05 19:19:57 +03:00
|
|
|
f = _show_config_option(f)
|
2017-06-01 23:55:54 +03:00
|
|
|
f = _resume_file_option(f)
|
2018-04-16 18:55:20 +03:00
|
|
|
f = _quiet_option(f)
|
2017-10-25 02:52:56 +03:00
|
|
|
f = _proxy_username_option(f)
|
|
|
|
f = _proxy_password_option(f)
|
|
|
|
f = _proxy_host_option(f)
|
2017-06-01 23:55:54 +03:00
|
|
|
f = _progress_bar_option(f)
|
|
|
|
f = _md5_processes_option(f)
|
2017-10-26 19:09:20 +03:00
|
|
|
f = _max_retries_option(f)
|
2017-06-01 23:55:54 +03:00
|
|
|
f = _log_file_option(f)
|
2017-10-13 17:21:11 +03:00
|
|
|
f = _enable_azure_storage_logger_option(f)
|
2017-06-01 23:55:54 +03:00
|
|
|
f = _disk_threads_option(f)
|
|
|
|
f = _crypto_processes_option(f)
|
|
|
|
f = _config_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
return f
|
|
|
|
|
|
|
|
|
2017-06-01 23:55:54 +03:00
|
|
|
def upload_download_options(f):
|
|
|
|
f = _remote_path_option(f)
|
2017-06-02 18:16:46 +03:00
|
|
|
f = _storage_account_option(f)
|
2017-06-01 23:55:54 +03:00
|
|
|
f = _local_resource_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
return f
|
|
|
|
|
|
|
|
|
|
|
|
def _access_key_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['access_key'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
2017-06-01 23:55:54 +03:00
|
|
|
'--storage-account-key',
|
2017-02-07 19:18:16 +03:00
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Storage account access key',
|
2017-06-01 23:55:54 +03:00
|
|
|
envvar='BLOBXFER_STORAGE_ACCOUNT_KEY',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2018-01-18 18:51:32 +03:00
|
|
|
def _access_tier_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['access_tier'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--access-tier',
|
|
|
|
expose_value=False,
|
|
|
|
default=None,
|
|
|
|
help='Access tier to apply to target (block blob only)',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def _chunk_size_bytes_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['chunk_size_bytes'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--chunk-size-bytes',
|
|
|
|
expose_value=False,
|
|
|
|
type=int,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-05-23 06:26:52 +03:00
|
|
|
help='Block or chunk size in bytes; set to 0 for auto-select '
|
|
|
|
'on upload [0]',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _delete_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['delete'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--delete',
|
|
|
|
expose_value=False,
|
|
|
|
is_flag=True,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Delete extraneous files on target [False]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-05-20 01:01:49 +03:00
|
|
|
def _distribution_mode(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
2017-08-15 19:46:10 +03:00
|
|
|
clictx.cli_options['distribution_mode'] = value
|
2017-05-20 01:01:49 +03:00
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--distribution-mode',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-05-20 01:01:49 +03:00
|
|
|
help='Vectored IO distribution mode: disabled, replica, '
|
|
|
|
'stripe [disabled]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def _endpoint_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['endpoint'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--endpoint',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Azure Storage endpoint [core.windows.net]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _exclude_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['exclude'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--exclude',
|
|
|
|
expose_value=False,
|
2017-05-18 18:18:14 +03:00
|
|
|
multiple=True,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Exclude pattern',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _file_attributes(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['file_attributes'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
2017-05-23 06:26:52 +03:00
|
|
|
'--file-attributes/--no-file-attributes',
|
2017-02-07 19:18:16 +03:00
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Store or restore file attributes [False]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _file_md5_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['file_md5'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--file-md5/--no-file-md5',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-04-11 00:40:03 +03:00
|
|
|
help='Compute file MD5 [False]',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _include_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['include'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--include',
|
|
|
|
expose_value=False,
|
2017-05-18 18:18:14 +03:00
|
|
|
multiple=True,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Include pattern',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _mode_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['mode'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--mode',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Transfer mode: auto, append, block, file, page [auto]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-05-20 01:01:49 +03:00
|
|
|
def _one_shot_bytes_option(f):
|
2017-05-17 01:05:58 +03:00
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
2017-05-20 01:01:49 +03:00
|
|
|
clictx.cli_options['one_shot_bytes'] = value
|
2017-05-17 01:05:58 +03:00
|
|
|
return value
|
|
|
|
return click.option(
|
2017-05-20 01:01:49 +03:00
|
|
|
'--one-shot-bytes',
|
2017-05-17 01:05:58 +03:00
|
|
|
expose_value=False,
|
2017-05-20 01:01:49 +03:00
|
|
|
type=int,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-05-20 01:01:49 +03:00
|
|
|
help='File sizes less than or equal to the specified byte threshold '
|
|
|
|
'will be uploaded as one-shot for block blobs; the valid range that '
|
|
|
|
'can be specified is 0 to 256MiB [0]',
|
2017-05-17 01:05:58 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def _overwrite_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['overwrite'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--overwrite/--no-overwrite',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-05-30 18:55:36 +03:00
|
|
|
help='Overwrite destination if exists. For append blobs, '
|
|
|
|
'--no-overwrite will append to any existing blob. [True]',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _recursive_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['recursive'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--recursive/--no-recursive',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Recursive [True]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-05-17 01:05:58 +03:00
|
|
|
def _rename_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['rename'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--rename',
|
|
|
|
expose_value=False,
|
|
|
|
is_flag=True,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-10-03 04:09:02 +03:00
|
|
|
help='Rename to specified destination for a single object. '
|
|
|
|
'Automatically enabled with stdin source. [False]',
|
2017-05-17 01:05:58 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def _rsa_private_key_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['rsa_private_key'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--rsa-private-key',
|
|
|
|
expose_value=False,
|
|
|
|
default=None,
|
2017-06-01 23:55:54 +03:00
|
|
|
help='RSA private key PEM file',
|
2017-02-07 19:18:16 +03:00
|
|
|
envvar='BLOBXFER_RSA_PRIVATE_KEY',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _rsa_private_key_passphrase_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['rsa_private_key_passphrase'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--rsa-private-key-passphrase',
|
|
|
|
expose_value=False,
|
|
|
|
default=None,
|
|
|
|
help='RSA private key passphrase',
|
|
|
|
envvar='BLOBXFER_RSA_PRIVATE_KEY_PASSPHRASE',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _rsa_public_key_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['rsa_public_key'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--rsa-public-key',
|
|
|
|
expose_value=False,
|
|
|
|
default=None,
|
2017-06-01 23:55:54 +03:00
|
|
|
help='RSA public key PEM file',
|
2017-02-07 19:18:16 +03:00
|
|
|
envvar='BLOBXFER_RSA_PUBLIC_KEY',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _sas_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['sas'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--sas',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Shared access signature',
|
|
|
|
envvar='BLOBXFER_SAS',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _skip_on_filesize_match_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['skip_on_filesize_match'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--skip-on-filesize-match',
|
|
|
|
expose_value=False,
|
|
|
|
is_flag=True,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Skip on equivalent file size [False]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _skip_on_lmt_ge_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['skip_on_lmt_ge'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--skip-on-lmt-ge',
|
|
|
|
expose_value=False,
|
|
|
|
is_flag=True,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Skip on last modified time greater than or equal to [False]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _skip_on_md5_match_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['skip_on_md5_match'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--skip-on-md5-match',
|
|
|
|
expose_value=False,
|
|
|
|
is_flag=True,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Skip on MD5 match [False]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-09-01 05:25:14 +03:00
|
|
|
def _stdin_as_page_blob_size_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['stdin_as_page_blob_size'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--stdin-as-page-blob-size',
|
|
|
|
expose_value=False,
|
|
|
|
type=int,
|
|
|
|
default=None,
|
|
|
|
help='Size of page blob with input from stdin [0]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def _strip_components_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['strip_components'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--strip-components',
|
|
|
|
expose_value=False,
|
|
|
|
type=int,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
|
|
|
help='Strip leading file path components on upload [0]',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-05-20 01:01:49 +03:00
|
|
|
def _stripe_chunk_size_bytes_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['stripe_chunk_size_bytes'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--stripe-chunk-size-bytes',
|
|
|
|
expose_value=False,
|
|
|
|
type=int,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-05-20 01:01:49 +03:00
|
|
|
help='Vectored IO stripe width in bytes [1073741824]',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def _sync_copy_dest_access_key_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['sync_copy_dest_access_key'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
2017-06-01 23:55:54 +03:00
|
|
|
'--sync-copy-dest-storage-account-key',
|
2017-02-07 19:18:16 +03:00
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Storage account access key for synccopy destination',
|
2017-06-01 23:55:54 +03:00
|
|
|
envvar='BLOBXFER_SYNC_COPY_DEST_STORAGE_ACCOUNT_KEY',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-07-10 18:46:26 +03:00
|
|
|
def _sync_copy_dest_mode_option(f):
|
2017-06-01 23:55:54 +03:00
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
2017-07-10 18:46:26 +03:00
|
|
|
clictx.cli_options['sync_copy_dest_mode'] = value
|
2017-06-01 23:55:54 +03:00
|
|
|
return value
|
|
|
|
return click.option(
|
2017-07-10 18:46:26 +03:00
|
|
|
'--sync-copy-dest-mode',
|
2017-06-01 23:55:54 +03:00
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-07-10 18:46:26 +03:00
|
|
|
help='Mode for synccopy destination',
|
2017-06-01 23:55:54 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _sync_copy_dest_remote_path_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['sync_copy_dest_remote_path'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--sync-copy-dest-remote-path',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-06-01 23:55:54 +03:00
|
|
|
help='Remote path on Azure Storage for synccopy destination',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
|
|
|
def _sync_copy_dest_sas_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['sync_copy_dest_sas'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--sync-copy-dest-sas',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-02-07 19:18:16 +03:00
|
|
|
help='Shared access signature for synccopy destination',
|
2017-06-01 23:55:54 +03:00
|
|
|
envvar='BLOBXFER_SYNC_COPY_DEST_SAS',
|
2017-02-07 19:18:16 +03:00
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-07-10 18:46:26 +03:00
|
|
|
def _sync_copy_dest_storage_account_option(f):
|
|
|
|
def callback(ctx, param, value):
|
|
|
|
clictx = ctx.ensure_object(CliContext)
|
|
|
|
clictx.cli_options['sync_copy_dest_storage_account'] = value
|
|
|
|
return value
|
|
|
|
return click.option(
|
|
|
|
'--sync-copy-dest-storage-account',
|
|
|
|
expose_value=False,
|
2017-08-15 19:46:10 +03:00
|
|
|
default=None,
|
2017-07-10 18:46:26 +03:00
|
|
|
help='Storage account name for synccopy destination',
|
|
|
|
envvar='BLOBXFER_SYNC_COPY_DEST_STORAGE_ACCOUNT',
|
|
|
|
callback=callback)(f)
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
def upload_options(f):
|
2017-05-17 01:05:58 +03:00
|
|
|
f = _stripe_chunk_size_bytes_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _strip_components_option(f)
|
2017-09-01 05:25:14 +03:00
|
|
|
f = _stdin_as_page_blob_size_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _skip_on_md5_match_option(f)
|
|
|
|
f = _skip_on_lmt_ge_option(f)
|
|
|
|
f = _skip_on_filesize_match_option(f)
|
|
|
|
f = _sas_option(f)
|
|
|
|
f = _rsa_public_key_option(f)
|
|
|
|
f = _rsa_private_key_passphrase_option(f)
|
|
|
|
f = _rsa_private_key_option(f)
|
2017-05-17 01:05:58 +03:00
|
|
|
f = _rename_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _recursive_option(f)
|
|
|
|
f = _overwrite_option(f)
|
2017-05-20 01:01:49 +03:00
|
|
|
f = _one_shot_bytes_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _mode_option(f)
|
|
|
|
f = _include_option(f)
|
|
|
|
f = _file_md5_option(f)
|
|
|
|
f = _file_attributes(f)
|
|
|
|
f = _exclude_option(f)
|
|
|
|
f = _endpoint_option(f)
|
2017-05-20 01:01:49 +03:00
|
|
|
f = _distribution_mode(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _delete_option(f)
|
|
|
|
f = _chunk_size_bytes_option(f)
|
2018-01-18 18:51:32 +03:00
|
|
|
f = _access_tier_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _access_key_option(f)
|
|
|
|
return f
|
|
|
|
|
|
|
|
|
|
|
|
def download_options(f):
|
|
|
|
f = _skip_on_md5_match_option(f)
|
|
|
|
f = _skip_on_lmt_ge_option(f)
|
|
|
|
f = _skip_on_filesize_match_option(f)
|
|
|
|
f = _sas_option(f)
|
|
|
|
f = _rsa_private_key_passphrase_option(f)
|
|
|
|
f = _rsa_private_key_option(f)
|
2017-05-17 01:05:58 +03:00
|
|
|
f = _rename_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _recursive_option(f)
|
|
|
|
f = _overwrite_option(f)
|
|
|
|
f = _mode_option(f)
|
|
|
|
f = _include_option(f)
|
|
|
|
f = _file_md5_option(f)
|
|
|
|
f = _file_attributes(f)
|
|
|
|
f = _exclude_option(f)
|
|
|
|
f = _endpoint_option(f)
|
|
|
|
f = _delete_option(f)
|
2017-02-24 10:47:16 +03:00
|
|
|
f = _chunk_size_bytes_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _access_key_option(f)
|
|
|
|
return f
|
|
|
|
|
|
|
|
|
|
|
|
def sync_copy_options(f):
|
2017-06-02 18:16:46 +03:00
|
|
|
f = _sync_copy_dest_storage_account_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _sync_copy_dest_sas_option(f)
|
2017-06-01 23:55:54 +03:00
|
|
|
f = _sync_copy_dest_remote_path_option(f)
|
2017-07-10 18:46:26 +03:00
|
|
|
f = _sync_copy_dest_mode_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _sync_copy_dest_access_key_option(f)
|
2017-06-02 18:16:46 +03:00
|
|
|
f = _storage_account_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _skip_on_md5_match_option(f)
|
|
|
|
f = _skip_on_lmt_ge_option(f)
|
|
|
|
f = _skip_on_filesize_match_option(f)
|
|
|
|
f = _sas_option(f)
|
2017-06-01 23:55:54 +03:00
|
|
|
f = _remote_path_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _overwrite_option(f)
|
|
|
|
f = _mode_option(f)
|
|
|
|
f = _include_option(f)
|
|
|
|
f = _exclude_option(f)
|
|
|
|
f = _endpoint_option(f)
|
2017-02-24 10:47:16 +03:00
|
|
|
f = _chunk_size_bytes_option(f)
|
2018-01-18 18:51:32 +03:00
|
|
|
f = _access_tier_option(f)
|
2017-02-07 19:18:16 +03:00
|
|
|
f = _access_key_option(f)
|
|
|
|
return f
|
|
|
|
|
|
|
|
|
|
|
|
@click.group(context_settings=_CONTEXT_SETTINGS)
|
|
|
|
@click.version_option(version=blobxfer.__version__)
|
|
|
|
@click.pass_context
|
|
|
|
def cli(ctx):
|
2017-06-09 05:47:42 +03:00
|
|
|
"""blobxfer: Azure Storage transfer tool"""
|
2017-02-07 19:18:16 +03:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command('download')
|
2017-06-01 23:55:54 +03:00
|
|
|
@upload_download_options
|
2017-02-07 19:18:16 +03:00
|
|
|
@download_options
|
|
|
|
@common_options
|
|
|
|
@pass_cli_context
|
2017-06-01 23:55:54 +03:00
|
|
|
def download(ctx):
|
2017-02-07 19:18:16 +03:00
|
|
|
"""Download blobs or files from Azure Storage"""
|
2017-06-01 23:55:54 +03:00
|
|
|
settings.add_cli_options(ctx.cli_options, settings.TransferAction.Download)
|
2017-06-02 18:16:46 +03:00
|
|
|
ctx.initialize(settings.TransferAction.Download)
|
2017-08-15 19:46:10 +03:00
|
|
|
specs = settings.create_download_specifications(
|
|
|
|
ctx.cli_options, ctx.config)
|
|
|
|
del ctx.cli_options
|
2017-02-15 01:57:29 +03:00
|
|
|
for spec in specs:
|
2017-02-22 08:20:16 +03:00
|
|
|
blobxfer.api.Downloader(
|
|
|
|
ctx.general_options, ctx.credentials, spec
|
|
|
|
).start()
|
2017-02-07 19:18:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
@cli.command('synccopy')
|
|
|
|
@sync_copy_options
|
|
|
|
@common_options
|
|
|
|
@pass_cli_context
|
2017-06-01 23:55:54 +03:00
|
|
|
def synccopy(ctx):
|
2017-08-29 19:19:10 +03:00
|
|
|
"""Synchronously copy blobs or files between Azure Storage accounts"""
|
2017-06-01 23:55:54 +03:00
|
|
|
settings.add_cli_options(ctx.cli_options, settings.TransferAction.Synccopy)
|
2017-06-02 18:16:46 +03:00
|
|
|
ctx.initialize(settings.TransferAction.Synccopy)
|
2017-08-15 19:46:10 +03:00
|
|
|
specs = settings.create_synccopy_specifications(
|
|
|
|
ctx.cli_options, ctx.config)
|
|
|
|
del ctx.cli_options
|
2017-06-09 05:47:42 +03:00
|
|
|
for spec in specs:
|
|
|
|
blobxfer.api.SyncCopy(
|
|
|
|
ctx.general_options, ctx.credentials, spec
|
|
|
|
).start()
|
2017-02-07 19:18:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
@cli.command('upload')
|
2017-06-01 23:55:54 +03:00
|
|
|
@upload_download_options
|
2017-02-07 19:18:16 +03:00
|
|
|
@upload_options
|
|
|
|
@common_options
|
|
|
|
@pass_cli_context
|
2017-06-01 23:55:54 +03:00
|
|
|
def upload(ctx):
|
2017-02-07 19:18:16 +03:00
|
|
|
"""Upload files to Azure Storage"""
|
2017-06-01 23:55:54 +03:00
|
|
|
settings.add_cli_options(ctx.cli_options, settings.TransferAction.Upload)
|
2017-06-02 18:16:46 +03:00
|
|
|
ctx.initialize(settings.TransferAction.Upload)
|
2017-08-15 19:46:10 +03:00
|
|
|
specs = settings.create_upload_specifications(
|
|
|
|
ctx.cli_options, ctx.config)
|
|
|
|
del ctx.cli_options
|
2017-05-30 22:59:39 +03:00
|
|
|
for spec in specs:
|
|
|
|
blobxfer.api.Uploader(
|
|
|
|
ctx.general_options, ctx.credentials, spec
|
|
|
|
).start()
|
|
|
|
|
|
|
|
|
2017-02-07 19:18:16 +03:00
|
|
|
if __name__ == '__main__':
|
|
|
|
cli()
|