use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class StopVmCommandBase method executeVmCommand.
@Override
protected void executeVmCommand() {
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VM, getVm().getId()));
suspendedVm = getVm().getStatus() == VMStatus.Suspended;
if (suspendedVm) {
endVmCommand();
setCommandShouldBeLogged(true);
} else {
super.executeVmCommand();
}
vmStaticDao.incrementDbGeneration(getVm().getId());
removeMemoryDisksIfNeeded(getActiveSnapshot());
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo 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);
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class AddVmTemplateCommand method init.
@Override
protected void init() {
if (Guid.isNullOrEmpty(getParameters().getVmTemplateId())) {
getParameters().setVmTemplateId(Guid.newGuid());
}
setVmTemplateId(getParameters().getVmTemplateId());
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VmTemplate, getVmTemplateId()));
setVmTemplateName(getParameters().getName());
VmStatic masterVm = getParameters().getMasterVm();
if (masterVm != null) {
setVmId(masterVm.getId());
setClusterId(masterVm.getClusterId());
// API backward compatibility
if (getVmDeviceUtils().shouldOverrideSoundDevice(masterVm, getMasterVmCompatibilityVersion(), getParameters().isSoundDeviceEnabled())) {
getParameters().setSoundDeviceEnabled(true);
}
if (getParameters().isSoundDeviceEnabled() == null) {
getParameters().setSoundDeviceEnabled(false);
}
if (getParameters().isConsoleEnabled() == null) {
getParameters().setConsoleEnabled(false);
}
vmHandler.updateDefaultTimeZone(masterVm);
vmHandler.autoSelectUsbPolicy(masterVm);
vmHandler.autoSelectDefaultDisplayType(getVmId(), masterVm, getCluster(), getParameters().getGraphicsDevices());
vmHandler.autoSelectGraphicsDevice(getVmId(), masterVm, getCluster(), getParameters().getGraphicsDevices(), getMasterVmCompatibilityVersion());
vmHandler.autoSelectResumeBehavior(masterVm, getCluster());
separateCustomProperties(masterVm);
}
if (getVm() != null) {
updateVmDevices();
images.addAll(getVmDisksFromDB());
setStoragePoolId(getVm().getStoragePoolId());
isVmInDb = true;
} else if (getCluster() != null && masterVm != null) {
VM vm = new VM(masterVm, new VmDynamic(), null);
vm.setClusterCompatibilityVersion(getCluster().getCompatibilityVersion());
setVm(vm);
setStoragePoolId(getCluster().getStoragePoolId());
}
updateDiskInfoDestinationMap();
generateTargetDiskIds();
getParameters().setUseCinderCommandCallback(!getCinderDisks().isEmpty());
}
Aggregations