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

[BACKUP] Added Archive Support for Azure CLI #18535

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
baed726
Code done!
Jun 15, 2021
09514b0
Modified code1
Jun 16, 2021
c432deb
Archive tests added.
Jun 22, 2021
c0c2bdc
help_for_move, linter and az file changed
Jun 23, 2021
92403b3
New line added in az and test_backup_commands
Jun 23, 2021
d74f791
ran backup archive
Jun 23, 2021
8b3cc79
Commented test_backup_archive for debugging
Jun 23, 2021
d311f55
Changed recordings
Jun 23, 2021
f4ab05c
Adding archive recording back
Jun 23, 2021
f3ed600
Added archive recording, and couple others
Jun 23, 2021
3b4d08e
ran all four failed tests locally
Jun 23, 2021
ebe7981
Merge pull request #1 from akshayneema/shreyanshbranch
ShreyanshJoshi Jun 23, 2021
9f26c18
akshay_review_changes
Jun 25, 2021
ab64d08
Merge branch 'user/t-shjoshi/Archive_support_CLI' of https://github.c…
Jun 25, 2021
61d07e8
Corrected a error in help-text of move command
Jun 25, 2021
aa56130
Corrected a small error in test_workload_commands.
Jun 25, 2021
18455d8
More changes after review.
Jun 25, 2021
955214e
Additional changes
Jun 25, 2021
a58f8e7
Changed help text of move in help.py
Jun 25, 2021
e4ba30a
Made changes for use-secondary-region parameter
Jun 25, 2021
f8691ef
Resolved conflicts
Jun 28, 2021
c5d028c
Changed recordings
Jun 28, 2021
7931c71
Re-ran the 3 failing tests
Jun 28, 2021
a88b2fb
Further modifications to those 3 recordings
Jun 28, 2021
8812a07
Tweaked archive code for use_secondary_region
Jun 28, 2021
5805645
Changes suggested by Xing Zhou
Jun 29, 2021
c5c56da
Additional change after review
Jun 29, 2021
9acee32
Update src/azure-cli/azure/cli/command_modules/backup/_help.py
ShreyanshJoshi Jun 29, 2021
b36ce08
Update src/azure-cli/azure/cli/command_modules/backup/custom_afs.py
ShreyanshJoshi Jun 29, 2021
3eb73c5
Update src/azure-cli/azure/cli/command_modules/backup/custom_afs.py
ShreyanshJoshi Jun 29, 2021
b636e7a
Final changes suggested by Xing Zhou
Jun 29, 2021
127a6e0
Final changes suggested by Xing Zhou
Jun 29, 2021
ea42811
Minor change
Jun 29, 2021
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
13 changes: 8 additions & 5 deletions src/azure-cli/azure/cli/command_modules/backup/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,12 @@ def _should_use_original_storage_account(recovery_point, restore_to_staging_stor
def _get_trigger_restore_properties(rp_name, vault_location, storage_account_id,
source_resource_id, target_rg_id,
use_original_storage_account, restore_disk_lun_list,
rehydration_duration, rehydration_priority, tier_type):
rehydration_duration, rehydration_priority, rp_list):
tier = None
if rp_list[0].properties.recovery_point_tier_details is not None:
tier = rp_list[0].tier_type

if tier_type == 'VaultArchive':
if tier == 'VaultArchive':
rehyd_duration = 'P' + str(rehydration_duration) + 'D'
rehydration_info = RecoveryPointRehydrationInfo(rehydration_retention_duration=rehyd_duration,
rehydration_priority=rehydration_priority)
Expand Down Expand Up @@ -680,7 +683,8 @@ def restore_disks(cmd, client, resource_group_name, vault_name, container_name,
rp_list = [recovery_point]
common.fetch_tier(rp_list)

if(rp_list[0].tier_type == 'VaultArchive' and rehydration_priority is None):
if (rp_list[0].properties.recovery_point_tier_details is not None and rp_list[0].tier_type == 'VaultArchive' and
rehydration_priority is None):
raise InvalidArgumentValueError("""The selected recovery point is in archive tier, provide additional
parameters of rehydration duration and rehydration priority.""")

Expand Down Expand Up @@ -738,8 +742,7 @@ def restore_disks(cmd, client, resource_group_name, vault_name, container_name,
trigger_restore_properties = _get_trigger_restore_properties(rp_name, vault_location, _storage_account_id,
_source_resource_id, target_rg_id,
use_original_storage_account, restore_disk_lun_list,
rehydration_duration, rehydration_priority,
rp_list[0].tier_type)
rehydration_duration, rehydration_priority, rp_list)
ShreyanshJoshi marked this conversation as resolved.
Show resolved Hide resolved
trigger_restore_request = RestoreRequestResource(properties=trigger_restore_properties)

if use_secondary_region:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from azure.cli.command_modules.backup._client_factory import protection_containers_cf, protectable_containers_cf, \
protection_policies_cf, backup_protection_containers_cf, backup_protectable_items_cf, \
resources_cf, backup_protected_items_cf
from azure.cli.core.azclierror import InvalidArgumentValueError
from azure.cli.core.azclierror import InvalidArgumentValueError, ArgumentUsageError

fabric_name = "Azure"
backup_management_type = "AzureStorage"
Expand Down Expand Up @@ -220,11 +220,11 @@ def list_recovery_points(cmd, client, resource_group_name, vault_name, item, sta
""")

if is_ready_for_move is not None or target_tier is not None or tier is not None:
raise InvalidArgumentValueError("""Invalid argument has been passed. --is-ready-for-move true, --target-tier
raise ArgumentUsageError("""Invalid argument has been passed. --is-ready-for-move true, --target-tier
and --tier flags are not supported for --backup-management-type AzureStorage.""")

if recommended_for_archive is not None:
raise InvalidArgumentValueError("""--recommended-for-archive is supported by AzureIaasVM backup management
raise ArgumentUsageError("""--recommended-for-archive is supported by AzureIaasVM backup management
type only.""")

if cmd.name.split()[2] == 'show-log-chain':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from azure.cli.command_modules.backup._client_factory import protection_policies_cf, backup_protected_items_cf, \
backup_protection_containers_cf, backup_protectable_items_cf
from azure.cli.core.azclierror import ValidationError, RequiredArgumentMissingError, InvalidArgumentValueError, \
MutuallyExclusiveArgumentError
MutuallyExclusiveArgumentError, ArgumentUsageError
# pylint: disable=import-error

fabric_name = "Azure"
Expand Down Expand Up @@ -150,7 +150,7 @@ def move_recovery_points(cmd, resource_group_name, vault_name, container_name, i
return custom_wl.move_wl_recovery_points(cmd, resource_group_name, vault_name, item, rp_name,
source_tier, destination_tier)

raise InvalidArgumentValueError('This command is not supported for --backup-management-type AzureStorage.')
raise ArgumentUsageError('This command is not supported for --backup-management-type AzureStorage.')


def backup_now(cmd, client, resource_group_name, vault_name, item_name, retain_until=None, container_name=None,
Expand Down
9 changes: 5 additions & 4 deletions src/azure-cli/azure/cli/command_modules/backup/custom_wl.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import azure.cli.command_modules.backup.custom_help as cust_help
import azure.cli.command_modules.backup.custom_common as common
from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError, ValidationError, \
ResourceNotFoundError
ResourceNotFoundError, ArgumentUsageError


fabric_name = "Azure"
Expand Down Expand Up @@ -328,7 +328,7 @@ def list_wl_recovery_points(cmd, client, resource_group_name, vault_name, item,
tier=None, recommended_for_archive=None):

if recommended_for_archive is not None:
raise InvalidArgumentValueError("""--recommended-for-archive is supported by AzureIaasVM backup management
raise ArgumentUsageError("""--recommended-for-archive is supported by AzureIaasVM backup management
type only.""")

# Get container and item URIs
Expand Down Expand Up @@ -589,11 +589,12 @@ def restore_azure_wl(cmd, client, resource_group_name, vault_name, recovery_conf
rp_list = [recovery_point]
common.fetch_tier(rp_list)

if rp_list[0].tier_type == 'VaultArchive' and rehydration_priority is None:
if (rp_list[0].properties.recovery_point_tier_details is not None and rp_list[0].tier_type == 'VaultArchive' and
rehydration_priority is None):
raise InvalidArgumentValueError("""The selected recovery point is in archive tier, provide additional
parameters of rehydration duration and rehydration priority.""")

if rp_list[0].tier_type == 'VaultArchive':
if rp_list[0].properties.recovery_point_tier_details is not None and rp_list[0].tier_type == 'VaultArchive':
# Construct trigger restore request object
trigger_restore_properties = _get_restore_request_instance(item_type, log_point_in_time, rehydration_priority)

Expand Down