Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/storage/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,9 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('content_type', arg_group='Additional Flags', help="Specify content type of the file. ")
c.argument('follow_symlinks', arg_group='Additional Flags', action='store_true',
help='Follow symbolic links when uploading from local file system.')
c.argument('cap_mbps', arg_group='Additional Flags', help="Caps the transfer rate, in megabits per second. "
"Moment-by-moment throughput might vary slightly from the cap. "
"If this option is set to zero, or it is omitted, the throughput isn't capped. ")
Comment on lines +967 to +969
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a validator to check if it's valid number? At least it needs to be a number.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

azcopy already has a validator to check, do we need to check it again?


with self.argument_context('storage blob copy') as c:
for item in ['destination', 'source']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('content_type', arg_group='Additional Flags', help="Specify content type of the file. ")
c.argument('follow_symlinks', arg_group='Additional Flags', action='store_true',
help='Follow symbolic links when uploading from local file system.')
c.argument('cap_mbps', arg_group='Additional Flags', help="Cap the transfer rate, in megabits per second. "
"Moment-by-moment throughput might vary slightly from the cap. "
"If this option is set to zero, or it is omitted, the throughput isn't capped. ")

with self.argument_context('storage blob copy') as c:
for item in ['destination', 'source']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# pylint: disable=too-many-statements, too-many-locals, unused-argument
def storage_copy(source, destination, put_md5=None, recursive=None, blob_type=None,
preserve_s2s_access_tier=None, content_type=None, follow_symlinks=None,
exclude_pattern=None, include_pattern=None, exclude_path=None, include_path=None, **kwargs):
exclude_pattern=None, include_pattern=None, exclude_path=None, include_path=None,
cap_mbps=None, **kwargs):

azcopy = AzCopy()
flags = []
Expand All @@ -33,6 +34,8 @@ def storage_copy(source, destination, put_md5=None, recursive=None, blob_type=No
flags.append('--content-type=' + content_type)
if follow_symlinks is not None:
flags.append('--follow-symlinks=true')
if cap_mbps is not None:
flags.append('--cap-mbps=' + cap_mbps)
azcopy.copy(source, destination, flags=flags)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def test_storage_azcopy_file_url(self, resource_group, storage_account_info, tes

import os
# Upload a single file
self.cmd('storage copy -s "{}" -d "{}"'
self.cmd('storage copy -s "{}" -d "{}" --cap-mbps 1.0'
.format(os.path.join(test_dir, 'readme'), share_url))
self.cmd('storage file list -s {} --account-name {}'
.format(share, storage_account), checks=JMESPathCheck('length(@)', 1))
Expand Down Expand Up @@ -699,7 +699,7 @@ def test_storage_azcopy_file_account(self, resource_group, storage_account_info,

import os
# Upload a single file
self.cmd('storage copy --source-local-path "{}" --destination-account-name {} --destination-share {}'
self.cmd('storage copy --source-local-path "{}" --destination-account-name {} --destination-share {} --cap-mbps 1.0'
.format(os.path.join(test_dir, 'readme'), storage_account, share))
self.cmd('storage file list -s {} --account-name {}'
.format(share, storage_account), checks=JMESPathCheck('length(@)', 1))
Expand Down