use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class AddVmCommand method addVmDynamic.
private void addVmDynamic() {
VmDynamic vmDynamic = new VmDynamic();
vmDynamic.setId(getVmId());
vmDynamic.setStatus(VMStatus.Down);
vmDynamic.setVmHost("");
vmDynamic.setIp("");
vmDynamic.setFqdn("");
vmDynamic.setLastStopTime(new Date());
vmDynamicDao.save(vmDynamic);
getCompensationContext().snapshotNewEntity(vmDynamic);
}
use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class AddVmTemplateCommand method executeCommand.
@Override
protected void executeCommand() {
// relevant only if template created from vm
if (isVmInDb) {
VmDynamic vmDynamic = vmDynamicDao.get(getVmId());
if (!isVmStatusValid(vmDynamic.getStatus())) {
throw new EngineException(EngineError.IRS_IMAGE_STATUS_ILLEGAL);
}
vmHandler.lockVm(vmDynamic, getCompensationContext());
}
setActionReturnValue(Guid.Empty);
// set template id as base for new templates
if (!isTemplateVersion()) {
getParameters().setBaseTemplateId(getVmTemplateId());
if (StringUtils.isEmpty(getParameters().getTemplateVersionName())) {
getParameters().setTemplateVersionName(BASE_TEMPLATE_VERSION_NAME);
}
} else {
// template version name should be the same as the base template name
setVmTemplateName(getBaseTemplate().getName());
String jobId = updateVmsJobHashMap.remove(getParameters().getBaseTemplateId());
if (!StringUtils.isEmpty(jobId)) {
log.info("Cancelling current running update for vms for base template id '{}'", getParameters().getBaseTemplateId());
try {
updateVmsJobMap.remove(getParameters().getBaseTemplateId()).cancel(true);
} catch (Exception e) {
log.warn("Failed deleting job '{}' at cancelRecoveryJob", jobId);
}
}
}
TransactionSupport.executeInNewTransaction(() -> {
addVmTemplateToDb();
getCompensationContext().stateChanged();
return null;
});
final Map<Guid, Guid> srcDeviceIdToTargetDeviceIdMapping = addAllTemplateDisks();
srcDeviceIdToTargetDeviceIdMapping.forEach((oldImageId, newImageId) -> addTemplateDiskVmElement(newImageId, oldImageId));
TransactionSupport.executeInNewTransaction(() -> {
addPermission();
addVmInterfaces(srcDeviceIdToTargetDeviceIdMapping);
Set<GraphicsType> graphicsToSkip = getParameters().getGraphicsDevices().keySet();
if (isVmInDb) {
getVmDeviceUtils().copyVmDevices(getVmId(), getVmTemplateId(), srcDeviceIdToTargetDeviceIdMapping, getParameters().isSoundDeviceEnabled(), getParameters().isConsoleEnabled(), getParameters().isVirtioScsiEnabled(), getVmDeviceUtils().hasMemoryBalloon(getVmId()), graphicsToSkip, false, getEffectiveCompatibilityVersion());
} else {
// for instance type and new template without a VM
getVmDeviceUtils().copyVmDevices(VmTemplateHandler.BLANK_VM_TEMPLATE_ID, getVmTemplateId(), srcDeviceIdToTargetDeviceIdMapping, getParameters().isSoundDeviceEnabled(), getParameters().isConsoleEnabled(), getParameters().isVirtioScsiEnabled(), Boolean.TRUE.equals(getParameters().isBalloonEnabled()), graphicsToSkip, false, getEffectiveCompatibilityVersion());
}
updateWatchdog(getVmTemplateId());
updateRngDevice(getVmTemplateId());
addGraphicsDevice();
setSucceeded(true);
return null;
});
if (getParameters().getTemplateType() != VmEntityType.INSTANCE_TYPE) {
vmHandler.warnMemorySizeLegal(getVmTemplate(), getVm().getCompatibilityVersion());
}
// means that there are no asynchronous tasks to execute and that we can
// end the command synchronously
pendingAsyncTasks = !getReturnValue().getVdsmTaskIdList().isEmpty() || !commandCoordinatorUtil.getChildCommandIds(getCommandId()).isEmpty();
if (!pendingAsyncTasks) {
endSuccessfullySynchronous();
}
}
use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class ImportVmCommandBase method createVmDynamic.
protected VmDynamic createVmDynamic() {
VmDynamic vmDynamic = new VmDynamic();
vmDynamic.setId(getVmId());
vmDynamic.setStatus(VMStatus.ImageLocked);
vmDynamic.setVmHost("");
vmDynamic.setIp("");
vmDynamic.setFqdn("");
vmDynamic.setLastStopTime(new Date());
vmDynamic.setAppList(getParameters().getVm().getAppList());
return vmDynamic;
}
use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class ImportVmCommandBase method addVmDynamic.
private void addVmDynamic() {
VmDynamic tempVar = createVmDynamic();
vmDynamicDao.save(tempVar);
getCompensationContext().snapshotNewEntity(tempVar);
}
use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class ImportVmFromExternalProviderCommand method createVmDynamic.
@Override
protected VmDynamic createVmDynamic() {
VmDynamic vmDynamic = super.createVmDynamic();
vmDynamic.setStatus(VMStatus.Down);
return vmDynamic;
}
Aggregations