Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -102,6 +103,16 @@ public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}

@Override
public Long getApiResourceId() {
return vmId;
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.VirtualMachine;
Comment thread
abh1sar marked this conversation as resolved.
}

@Override
public String getEventType() {
return EventTypes.EVENT_VM_BACKUP_OFFERING_ASSIGN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Backup;
return ApiCommandResourceType.VirtualMachine;
}

@Override
public Long getApiResourceId() {
return vmId;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
Expand Down Expand Up @@ -81,7 +82,7 @@ public class CreateBackupScheduleCmd extends BaseCmd {
@Parameter(name = ApiConstants.QUIESCE_VM,
type = CommandType.BOOLEAN,
required = false,
description = "Quiesce the instance before checkpointing the disks for backup. Applicable only to NAS backup provider. " +
description = "Quiesce the Instance before checkpointing the disks for backup. Applicable only to NAS backup provider. " +
"The filesystem is frozen before the backup starts and thawed immediately after. " +
"Requires the instance to have the QEMU Guest Agent installed and running.",
since = "4.21.0")
Expand Down Expand Up @@ -139,4 +140,14 @@ public void execute() throws ServerApiException {
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}

@Override
public Long getApiResourceId() {
return vmId;
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.VirtualMachine;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -99,6 +100,16 @@ public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}

@Override
public Long getApiResourceId() {
return vmId;
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.VirtualMachine;
}

@Override
public String getEventType() {
return EventTypes.EVENT_VM_BACKUP_OFFERING_REMOVE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -127,4 +128,14 @@ public String getEventType() {
public String getEventDescription() {
return "Restoring volume "+ volumeUuid + " from backup " + getResourceUuid(ApiConstants.BACKUP_ID) + " and attaching it to Instance " + getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID);
}

@Override
public Long getApiResourceId() {
return vmId;
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.VirtualMachine;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ public Pair<Boolean, Backup> takeBackup(final VirtualMachine vm, Boolean quiesce
} catch (AgentUnavailableException e) {
logger.error("Unable to contact backend control plane to initiate backup for VM {}", vm.getInstanceName());
backupVO.setStatus(Backup.Status.Failed);
backupDao.remove(backupVO.getId());
backupDao.update(backupVO.getId(), backupVO);
throw new CloudRuntimeException("Unable to contact backend control plane to initiate backup");
} catch (OperationTimedoutException e) {
logger.error("Operation to initiate backup timed out for VM {}", vm.getInstanceName());
backupVO.setStatus(Backup.Status.Failed);
backupDao.remove(backupVO.getId());
backupDao.update(backupVO.getId(), backupVO);
throw new CloudRuntimeException("Operation to initiate backup timed out, please try again");
}

Expand All @@ -249,12 +249,12 @@ public Pair<Boolean, Backup> takeBackup(final VirtualMachine vm, Boolean quiesce
} else {
logger.error("Failed to take backup for VM {}: {}", vm.getInstanceName(), answer != null ? answer.getDetails() : "No answer received");
if (answer.getNeedsCleanup()) {
logger.error("Backup cleanup failed for VM {}. Leaving the backup in Error state.", vm.getInstanceName());
logger.error("Backup cleanup failed for VM {}. Leaving the backup in Error state. Backup should be manually deleted to free up the space", vm.getInstanceName());
backupVO.setStatus(Backup.Status.Error);
backupDao.update(backupVO.getId(), backupVO);
} else {
backupVO.setStatus(Backup.Status.Failed);
backupDao.remove(backupVO.getId());
backupDao.update(backupVO.getId(), backupVO);
}
return new Pair<>(false, null);
}
Expand Down
Loading
Loading