use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ExportVmCommand method copyAllMemoryImages.
private void copyAllMemoryImages(Guid containerID) {
for (Snapshot snapshot : snapshotsWithMemory) {
// copy the memory dump image
DiskImage dumpImage = (DiskImage) diskDao.get(snapshot.getMemoryDiskId());
ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForMemoryDumpImage(containerID, dumpImage));
if (!vdcRetValue.getSucceeded()) {
throw new EngineException(vdcRetValue.getFault().getError(), "Failed during ExportVmCommand");
}
// TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
// copy the memory configuration (of the VM) image
// This volume is always of type 'sparse' and format 'cow' so no need to convert,
// and there're no snapshots for it so no reason to use copy collapse
DiskImage confImage = (DiskImage) diskDao.get(snapshot.getMetadataDiskId());
vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParameters(containerID, confImage));
if (!vdcRetValue.getSucceeded()) {
throw new EngineException(vdcRetValue.getFault().getError(), "Failed during ExportVmCommand");
}
// TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class LoginOnBehalfCommand method getDbUser.
private DbUser getDbUser() {
DbUser dbUser = null;
switch(getParameters().getQueryType()) {
case ByInternalId:
logInfo = String.format("for internal id %s", getParameters().getUserId());
dbUser = dbUserDao.get(getParameters().getUserId());
break;
case ByPrincipalName:
logInfo = String.format("for principal name: %s, authz name: %s", getParameters().getPrincipalName(), getParameters().getAuthzName());
dbUser = getDbUserForPrincipalName(getParameters().getPrincipalName(), getParameters().getAuthzName());
break;
case ByExternalId:
logInfo = String.format("for external id: %s, authz name: %s", getParameters().getExternalId(), getParameters().getAuthzName());
dbUser = dbUserDao.getByExternalId(getParameters().getAuthzName(), getParameters().getExternalId());
break;
}
if (dbUser == null) {
throw new EngineException(EngineError.PRINCIPAL_NOT_FOUND, "User not found in database");
}
return dbUser;
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class RunVmCommand method runVm.
protected void runVm() {
setActionReturnValue(VMStatus.Down);
if (getVdsToRunOn()) {
VMStatus status = null;
try {
acquireHostDevicesLock();
if (connectLunDisks(getVdsId()) && updateCinderDisksConnections()) {
if (!checkRequiredHostDevicesAvailability()) {
// (while the host-device lock wasn't being held) we need to bail here
throw new EngineException(EngineError.HOST_DEVICES_TAKEN_BY_OTHER_VM);
} else {
status = createVm();
ExecutionHandler.setAsyncJob(getExecutionContext(), true);
markHostDevicesAsUsed();
}
}
} catch (EngineException e) {
// re-throw it. otherwise, continue (the vm will be down and a re-run will be triggered)
switch(e.getErrorCode()) {
// should never get here with errorCode = 'Done' though
case Done:
case exist:
cleanupPassthroughVnics();
reportCompleted();
throw e;
// probably wrong xml format sent.
case VDS_NETWORK_ERROR:
case PROVIDER_FAILURE:
case HOST_DEVICES_TAKEN_BY_OTHER_VM:
runningFailed();
throw e;
default:
log.warn("Failed to run VM '{}': {}", getVmName(), e.getMessage());
}
} finally {
releaseHostDevicesLock();
freeLock();
}
setActionReturnValue(status);
if (status != null && (status.isRunning() || status == VMStatus.RestoringState)) {
setSucceeded(true);
} else {
// Try to rerun Vm on different vds no need to log the command because it is
// being logged inside the rerun
log.info("Trying to rerun VM '{}'", getVm().getName());
setCommandShouldBeLogged(false);
setSucceeded(true);
rerun();
}
} else {
runningFailed();
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class InitVdsOnUpCommand method refreshHostDeviceList.
private void refreshHostDeviceList() {
try {
CommandContext ctx = cloneContext();
ctx.getExecutionContext().setJobRequired(false);
runInternalAction(ActionType.RefreshHostDevices, new VdsActionParameters(getVdsId()), ctx);
} catch (EngineException e) {
log.error("Could not refresh host devices for host '{}'", getVds().getName());
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ReduceImageCommand method executeCommand.
@Override
protected void executeCommand() {
if (getStorageDomain().getStorageType().isFileDomain()) {
log.info("Reduce image isn't required for file based domains");
setSucceeded(true);
return;
}
if (!isReduceVolumeSupported()) {
log.info("Reduce image isn't supported in {}", getStoragePool().getCompatibilityVersion());
setSucceeded(true);
return;
}
if (!isInternalMerge()) {
log.info("Reduce image isn't supported for active image merge");
setSucceeded(true);
return;
}
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupId()));
boolean prepareImageSucceeded = false;
boolean reduceImageSucceeded = false;
if (!getParameters().isVmRunningOnSpm()) {
// The VM isn't running on the SPM but the reduce command is performed on the SPM, hence
// we have to prepare the image on the SPM
log.debug("Preparing image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId());
try {
prepareImage();
prepareImageSucceeded = true;
} catch (EngineException e) {
log.error("Failed to prepare image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId());
}
}
if (!getParameters().isVmRunningOnSpm() && !prepareImageSucceeded) {
// As we don't want to fail the live merge because of a failure to reduce the image, we still mark the
// command as succeeded.
setSucceeded(true);
return;
}
try {
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ReduceImage, creaeteReduceImageVDSCommandParameters());
if (vdsReturnValue.getSucceeded()) {
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
getTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId()));
reduceImageSucceeded = true;
}
} catch (EngineException e) {
log.error("Reducing image {}/{} failed", getParameters().getImageGroupId(), getParameters().getImageId());
}
if (prepareImageSucceeded && !reduceImageSucceeded) {
try {
teardownImage();
} catch (EngineException e) {
log.error("Failed to teardown image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId());
}
}
setSucceeded(true);
}
Aggregations