def list_wl_recovery_points(cmd, client, resource_group_name, vault_name, item, start_date=None, end_date=None, extended_info=None, use_secondary_region=None): # Get container and item URIs container_uri = cust_help.get_protection_container_uri_from_id(item.id) item_uri = cust_help.get_protected_item_uri_from_id(item.id) query_end_date, query_start_date = cust_help.get_query_dates(end_date, start_date) if query_end_date and query_start_date: cust_help.is_range_valid(query_start_date, query_end_date) filter_string = cust_help.get_filter_string({ 'startDate': query_start_date, 'endDate': query_end_date}) if cmd.name.split()[2] == 'show-log-chain' or extended_info is not None: filter_string = cust_help.get_filter_string({ 'restorePointQueryType': 'Log', 'startDate': query_start_date, 'endDate': query_end_date, 'extendedInfo': extended_info}) if use_secondary_region: client = recovery_points_crr_cf(cmd.cli_ctx) # Get recovery points recovery_points = client.list(vault_name, resource_group_name, fabric_name, container_uri, item_uri, filter_string) paged_recovery_points = cust_help.get_list_from_paged_response(recovery_points) return paged_recovery_points
def show_recovery_point(cmd, client, resource_group_name, vault_name, container_name, item_name, name, workload_type=None, backup_management_type=None, use_secondary_region=None): items_client = backup_protected_items_cf(cmd.cli_ctx) item = show_item(cmd, items_client, resource_group_name, vault_name, container_name, item_name, backup_management_type, workload_type, use_secondary_region) custom_help.validate_item(item) if isinstance(item, list): raise CLIError( "Multiple items found. Please give native names instead.") # Get container and item URIs container_uri = custom_help.get_protection_container_uri_from_id(item.id) item_uri = custom_help.get_protected_item_uri_from_id(item.id) container_type = custom_help.validate_and_extract_container_type( container_name, backup_management_type) if use_secondary_region: if container_type and container_type.lower() == "azurestorage": raise InvalidArgumentValueError(""" --use-secondary-region flag is not supported for --backup-management-type AzureStorage. Please either remove the flag or query for any other backup-management-type. """) client = recovery_points_crr_cf(cmd.cli_ctx) recovery_points = client.list(vault_name, resource_group_name, fabric_name, container_uri, item_uri, None) paged_rps = custom_help.get_list_from_paged_response(recovery_points) filtered_rps = [ rp for rp in paged_rps if rp.name.lower() == name.lower() ] recovery_point = custom_help.get_none_one_or_many(filtered_rps) if recovery_point is None: raise InvalidArgumentValueError( "The recovery point provided does not exist. Please provide valid RP." ) return recovery_point try: response = client.get(vault_name, resource_group_name, fabric_name, container_uri, item_uri, name) except Exception as ex: errorMessage = str(ex) raise InvalidArgumentValueError( "Specified recovery point can not be fetched - \n" + errorMessage) return response
def _get_log_time_range(cmd, resource_group_name, vault_name, item, use_secondary_region): container_uri = cust_help.get_protection_container_uri_from_id(item.id) item_uri = cust_help.get_protected_item_uri_from_id(item.id) filter_string = cust_help.get_filter_string({ 'restorePointQueryType': 'Log'}) client = recovery_points_cf(cmd.cli_ctx) if use_secondary_region: client = recovery_points_crr_cf(cmd.cli_ctx) # Get recovery points recovery_points = client.list(vault_name, resource_group_name, fabric_name, container_uri, item_uri, filter_string) paged_recovery_points = cust_help.get_none_one_or_many(cust_help.get_list_from_paged_response(recovery_points)) _check_none_and_many(paged_recovery_points, "Log time range") return paged_recovery_points.properties.time_ranges
def list_wl_recovery_points(cmd, client, resource_group_name, vault_name, item, start_date=None, end_date=None, extended_info=None, is_ready_for_move=None, target_tier=None, use_secondary_region=None, tier=None, recommended_for_archive=None): if recommended_for_archive is not None: raise ArgumentUsageError("""--recommended-for-archive is supported by AzureIaasVM backup management type only.""") # Get container and item URIs container_uri = cust_help.get_protection_container_uri_from_id(item.id) item_uri = cust_help.get_protected_item_uri_from_id(item.id) query_end_date, query_start_date = cust_help.get_query_dates(end_date, start_date) if query_end_date and query_start_date: cust_help.is_range_valid(query_start_date, query_end_date) filter_string = cust_help.get_filter_string({ 'startDate': query_start_date, 'endDate': query_end_date}) if cmd.name.split()[2] == 'show-log-chain' or extended_info is not None: filter_string = cust_help.get_filter_string({ 'restorePointQueryType': 'Log', 'startDate': query_start_date, 'endDate': query_end_date, 'extendedInfo': extended_info}) if use_secondary_region: client = recovery_points_crr_cf(cmd.cli_ctx) # Get recovery points recovery_points = client.list(vault_name, resource_group_name, fabric_name, container_uri, item_uri, filter_string) paged_recovery_points = cust_help.get_list_from_paged_response(recovery_points) common.fetch_tier(paged_recovery_points) if use_secondary_region: paged_recovery_points = [item for item in paged_recovery_points if item.properties.recovery_point_tier_details is None or (item.properties.recovery_point_tier_details is not None and item.tier_type != 'VaultArchive')] recovery_point_list = common.check_rp_move_readiness(paged_recovery_points, target_tier, is_ready_for_move) recovery_point_list = common.filter_rp_based_on_tier(recovery_point_list, tier) return recovery_point_list