-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Storage] Upgrade Azcopy for storage copy/remove and blob sync #11874
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
368f1fa
upgrade azcopy version
Juliehzl a8991a1
update help
Juliehzl 6f5dc72
add azcopy version check
Juliehzl 9a2e199
update
Juliehzl 6251470
update test for remove
Juliehzl 744b999
update help
Juliehzl b6e0ed9
update hostpry
Juliehzl 782bc8d
update histpry
Juliehzl 14af5e8
remove check output
Juliehzl 9aa4b18
fix style
Juliehzl abdff03
add more flags for sync
Juliehzl 9bc4e76
update histpry
Juliehzl 429faa6
add flags to sync
Juliehzl 90c0db5
remove recursive parameters and add test for sync
Juliehzl 146918e
add examples and tests
Juliehzl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| from ..azcopy.util import AzCopy, client_auth_for_azcopy, login_auth_for_azcopy | ||
| from azure.cli.command_modules.storage._client_factory import blob_data_service_factory, file_data_service_factory | ||
|
|
||
| # pylint: disable=too-many-statements | ||
| # pylint: disable=too-many-statements, too-many-locals | ||
|
|
||
|
|
||
| def storage_copy(cmd, source=None, | ||
|
|
@@ -27,7 +27,8 @@ def storage_copy(cmd, source=None, | |
| destination_blob=None, | ||
| destination_share=None, | ||
| destination_file_path=None, | ||
| destination_local_path=None): | ||
| destination_local_path=None, | ||
| exclude_pattern=None, include_pattern=None, exclude_path=None, include_path=None): | ||
| def get_url_with_sas(source, account_name, container, blob, share, file_path, local_path): | ||
| import re | ||
| import os | ||
|
|
@@ -94,28 +95,48 @@ def get_url_with_sas(source, account_name, container, blob, share, file_path, lo | |
| flags.append('--blob-type=' + blob_type) | ||
| if preserve_s2s_access_tier is not None: | ||
| flags.append('--s2s-preserve-access-tier=' + str(preserve_s2s_access_tier)) | ||
|
|
||
| if include_pattern is not None: | ||
| flags.append('--include-pattern=' + include_pattern) | ||
| if exclude_pattern is not None: | ||
| flags.append('--exclude-pattern=' + exclude_pattern) | ||
| if include_path is not None: | ||
| flags.append('--include-path=' + include_path) | ||
| if exclude_pattern is not None: | ||
| flags.append('--exclude-path=' + exclude_path) | ||
| azcopy.copy(full_source, full_destination, flags=flags) | ||
|
|
||
|
|
||
| def storage_remove(cmd, client, service, target, exclude=None, include=None, recursive=None): | ||
| def storage_remove(cmd, client, service, target, recursive=None, exclude_pattern=None, include_pattern=None, | ||
| exclude_path=None, include_path=None): | ||
| if service == 'file': | ||
| azcopy = _azcopy_file_client(cmd, client) | ||
| else: | ||
| azcopy = _azcopy_blob_client(cmd, client) | ||
| flags = [] | ||
| if recursive is not None: | ||
| flags.append('--recursive') | ||
| if include is not None: | ||
|
||
| flags.append('--include=' + include) | ||
| if exclude is not None: | ||
| flags.append('--exclude=' + exclude) | ||
| if include_pattern is not None: | ||
| flags.append('--include-pattern=' + include_pattern) | ||
| if exclude_pattern is not None: | ||
| flags.append('--exclude-pattern=' + exclude_pattern) | ||
| if include_path is not None: | ||
| flags.append('--include-path=' + include_path) | ||
| if exclude_path is not None: | ||
| flags.append('--exclude-path=' + exclude_path) | ||
| azcopy.remove(_add_url_sas(target, azcopy.creds.sas_token), flags=flags) | ||
|
|
||
|
|
||
| def storage_blob_sync(cmd, client, source, destination): | ||
| def storage_blob_sync(cmd, client, source, destination, exclude_pattern=None, include_pattern=None, | ||
| exclude_path=None): | ||
| azcopy = _azcopy_blob_client(cmd, client) | ||
| azcopy.sync(source, _add_url_sas(destination, azcopy.creds.sas_token), flags=['--delete-destination', 'true']) | ||
| flags = ['--delete-destination=true'] | ||
| if include_pattern is not None: | ||
| flags.append('--include-pattern=' + include_pattern) | ||
| if exclude_pattern is not None: | ||
| flags.append('--exclude-pattern=' + exclude_pattern) | ||
| if exclude_path is not None: | ||
| flags.append('--exclude-path=' + exclude_path) | ||
| azcopy.sync(source, _add_url_sas(destination, azcopy.creds.sas_token), flags=flags) | ||
|
|
||
|
|
||
| def storage_run_command(cmd, command_args): | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although self.executable file not exist exception can be caught, it is better practise to check if the file exists here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked here https://github.com/Azure/azure-cli/pull/11874/files#diff-218741868927572140fea7e37a1eb4f3R35