-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[KeyVault] Add --no-wait for command az keyvault security-domain download and --target-operation for command az keyvault security-domain wait
#17263
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
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
435a1ad
Merge branch 'release' into dev
houk-ms f0be844
Merge remote-tracking branch 'origin/dev' into dev
houk-ms 0b9d92c
Merge remote-tracking branch 'origin/dev' into dev
houk-ms 5b775d0
Merge remote-tracking branch 'origin/dev' into dev
houk-ms 22fffd0
Merge remote-tracking branch 'origin/dev' into dev
houk-ms c1205ff
Merge remote-tracking branch 'origin/dev' into dev
houk-ms 000d07e
Merge remote-tracking branch 'origin/dev' into dev
houk-ms 96553de
Merge remote-tracking branch 'origin/dev' into dev
houk-ms f9ad8d5
Merge remote-tracking branch 'origin/dev' into dev
houk-ms c17cd75
security-domain sync to async support
houk-ms 2fce0ba
security-domain download async
houk-ms 8a042c1
fix polling bug
houk-ms 0d9c337
raise error when file operation fails
houk-ms d6e55fa
Merge remote-tracking branch 'origin/dev' into security-domain
houk-ms f186f43
support --id to specify url and fix test
houk-ms 15cd31b
wait before polling
houk-ms 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
support --id to specify url and fix test
- Loading branch information
commit f186f43aee9fec2791c0a2845b90d1387261f241
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2173,11 +2173,11 @@ def full_restore(cmd, client, token, folder_to_restore, storage_resource_uri=Non | |
|
|
||
| # region security domain | ||
| def security_domain_init_recovery(client, hsm_name, sd_exchange_key, | ||
| identifier=None): # pylint: disable=unused-argument | ||
| identifier=None, vault_base_url=None): # pylint: disable=unused-argument | ||
| if os.path.exists(sd_exchange_key): | ||
| raise CLIError("File named '{}' already exists.".format(sd_exchange_key)) | ||
|
|
||
| ret = client.transfer_key(vault_base_url=hsm_name) | ||
| ret = client.transfer_key(vault_base_url=hsm_name or vault_base_url) | ||
| exchange_key = json.loads(json.loads(ret)['transfer_key']) | ||
|
|
||
| def get_x5c_as_pem(): | ||
|
|
@@ -2204,17 +2204,18 @@ def get_x5c_as_pem(): | |
| raise ex | ||
|
|
||
|
|
||
| def _wait_security_domain_operation(client, hsm_name, target_operation='upload', identifier=None): # pylint: disable=unused-argument | ||
| def _wait_security_domain_operation(client, hsm_name, target_operation='upload', | ||
| identifier=None, vault_base_url=None): # pylint: disable=unused-argument | ||
| retries = 0 | ||
| max_retries = 30 | ||
| wait_second = 5 | ||
| while retries < max_retries: | ||
| try: | ||
| ret = None | ||
| if target_operation == 'upload': | ||
| ret = client.upload_pending(vault_base_url=hsm_name) | ||
| ret = client.upload_pending(vault_base_url=hsm_name or vault_base_url) | ||
| elif target_operation == 'download': | ||
| ret = client.download_pending(vault_base_url=hsm_name) | ||
| ret = client.download_pending(vault_base_url=hsm_name or vault_base_url) | ||
|
|
||
| # v7.2-preview and v7.2 will change the upload operation from Sync to Async | ||
| # due to service defects, it returns 'Succeeded' before the change and 'Success' after the change | ||
|
|
@@ -2319,7 +2320,7 @@ def _security_domain_gen_blob(sd_exchange_key, share_arrays, enc_data, required) | |
|
|
||
|
|
||
| def security_domain_upload(cmd, client, hsm_name, sd_file, sd_exchange_key, sd_wrapping_keys, passwords=None, | ||
| identifier=None, no_wait=False): # pylint: disable=unused-argument | ||
| identifier=None, vault_base_url=None, no_wait=False): # pylint: disable=unused-argument | ||
| resource_paths = [sd_file, sd_exchange_key] | ||
| for p in resource_paths: | ||
| if not os.path.exists(p): | ||
|
|
@@ -2358,12 +2359,12 @@ def security_domain_upload(cmd, client, hsm_name, sd_file, sd_exchange_key, sd_w | |
| ) | ||
| SecurityDomainObject = cmd.get_models('SecurityDomainObject', resource_type=ResourceType.DATA_PRIVATE_KEYVAULT) | ||
| security_domain = SecurityDomainObject(value=restore_blob_value) | ||
| retval = client.upload(vault_base_url=hsm_name, security_domain=security_domain) | ||
| retval = client.upload(vault_base_url=hsm_name or vault_base_url, security_domain=security_domain) | ||
|
|
||
| if no_wait: | ||
| return retval | ||
|
|
||
| new_retval = _wait_security_domain_operation(client, hsm_name, 'upload') | ||
| new_retval = _wait_security_domain_operation(client, hsm_name, 'upload', vault_base_url=vault_base_url) | ||
| if new_retval: | ||
| return new_retval | ||
| return retval | ||
|
|
@@ -2430,7 +2431,7 @@ def _save_to_local_file(file_path, security_domain): | |
| ) | ||
|
|
||
| if not no_wait: | ||
| polling_ret = _wait_security_domain_operation(client, hsm_name, 'download') | ||
| polling_ret = _wait_security_domain_operation(client, hsm_name, 'download', vault_base_url=vault_base_url) | ||
| # Due to service defect, status could be 'Success' or 'Succeeded' when it succeeded | ||
| if polling_ret and getattr(polling_ret, 'status', None) != 'Failed': | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls lower/upper case then compare on string
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer we rely on service in avoid of risks in possible type convertion. |
||
| _save_to_local_file(security_domain_file, ret) | ||
|
|
||
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
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.
final command will be ?
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.
--target_operationdefaults touploadin avoid of breaking change. so either specifying--target-operationor not would work forupload.for
download, we have to specify--target-operation download