Exemplo n.º 1
0
def _get_backup_request(workload_type, retain_until):
    if workload_type == WorkloadType.vm.value:
        trigger_backup_properties = IaasVMBackupRequest(
            recovery_point_expiry_time_in_utc=retain_until)
    trigger_backup_request = BackupRequestResource(
        properties=trigger_backup_properties)
    return trigger_backup_request
    def trigger_backup(self, container_name, protected_item_name):
        expiry_time = datetime.utcnow() + timedelta(days=2)

        backup_request = BackupRequestResource(properties=IaasVMBackupRequest(
            recovery_point_expiry_time_in_utc=expiry_time), )

        response = self.client.backups.trigger(self.vault_name,
                                               self.resource_group,
                                               self.fabric_name,
                                               container_name,
                                               protected_item_name,
                                               backup_request,
                                               raw=True)
        self._validate_operation_response(response)

        job_response = self._get_operation_response(
            container_name,
            protected_item_name,
            response,
            lambda operation_id: self.client.protected_item_operation_results.
            get(
                self.vault_name,
                self.resource_group,
                self.fabric_name,
                container_name,
                protected_item_name,
                operation_id,
                raw=True,
            ),
            lambda operation_id: self.client.protected_item_operation_statuses.
            get(
                self.vault_name,
                self.resource_group,
                self.fabric_name,
                container_name,
                protected_item_name,
                operation_id,
            ),
        )

        self.context.assertIsNotNone(job_response.job_id)
        return job_response.job_id