use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class VmManagementCommandBase method validatePinningAndMigration.
boolean validatePinningAndMigration() {
final boolean cpuPinMigrationEnabled = Boolean.TRUE.equals(Config.<Boolean>getValue(ConfigValues.CpuPinMigrationEnabled));
VmStatic vmStaticData = getParameters().getVmStaticData();
if (!cpuPinMigrationEnabled && (vmStaticData.getMigrationSupport() == MigrationSupport.MIGRATABLE || vmStaticData.getMigrationSupport() == MigrationSupport.IMPLICITLY_NON_MIGRATABLE) && StringUtils.isNotEmpty(getParameters().getVm().getCpuPinning())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_CANNOT_BE_PINNED_TO_CPU_AND_MIGRATABLE);
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class UpdateClusterCommand method updateVms.
private boolean updateVms() {
for (VmStatic vm : vmsLockedForUpdate) {
VmManagementParametersBase updateParams = new VmManagementParametersBase(vm);
/*
Locking by UpdateVmCommand is disabled since VMs are already locked in #getExclusiveLocks method.
This logic relies on assumption that UpdateVmCommand locks exactly only updated VM.
*/
updateParams.setLockProperties(LockProperties.create(LockProperties.Scope.None));
updateParams.setClusterLevelChangeFromVersion(oldCluster.getCompatibilityVersion());
upgradeGraphicsDevices(vm, updateParams);
updateResumeBehavior(vm);
updateRngDeviceIfNecessary(vm.getId(), vm.getCustomCompatibilityVersion(), updateParams);
ActionReturnValue result = runInternalAction(ActionType.UpdateVm, updateParams, cloneContextAndDetachFromParent());
if (!result.getSucceeded()) {
List<String> params = new ArrayList<>();
params.add("$action Update");
params.add("$type VM");
params.add(parseErrorMessage(result.getValidationMessages()));
List<String> messages = Backend.getInstance().getErrorsTranslator().translateErrorText(params);
failedUpgradeEntities.put(vm.getName(), getFailedMessage(messages));
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class AddVmCommand method updateVmObject.
/**
* This method override vm values with the instance type values
* in case instance type is selected for this vm
*/
private void updateVmObject() {
updateParametersVmFromInstanceType();
// set vm interface source id to be the instance type, vm interface are taken from it
if (getInstanceType() != null) {
vmInterfacesSourceId = getInstanceTypeId();
}
VmStatic vmStatic = getParameters().getVmStaticData();
ImageType imageType = getImageType();
if (imageType != null) {
vmStatic.setOsId(imageType.getOsId());
vmStatic.setIsoPath(imageType.getIsoPath());
vmStatic.setInitrdUrl(imageType.getInitrdUrl());
vmStatic.setKernelUrl(imageType.getKernelUrl());
vmStatic.setKernelParams(imageType.getKernelParams());
// set vm disks source to be the image type, vm disks are taken from it
vmDisksSource = (VmTemplate) imageType;
}
// Choose a proper default OS according to the cluster architecture
if (getParameters().getVmStaticData().getOsId() == OsRepository.AUTO_SELECT_OS) {
if (getCluster().getArchitecture() != ArchitectureType.undefined) {
Integer defaultOs = osRepository.getDefaultOSes().get(getCluster().getArchitecture());
getParameters().getVmStaticData().setOsId(defaultOs);
}
}
vmHandler.autoSelectUsbPolicy(getParameters().getVmStaticData());
// Choose a proper default display type according to the cluster architecture
vmHandler.autoSelectDefaultDisplayType(vmDevicesSourceId, getParameters().getVmStaticData(), getCluster(), getParameters().getGraphicsDevices());
// If not set by user, choose proper graphics device according to the cluster architecture
vmHandler.autoSelectGraphicsDevice(vmDevicesSourceId, getParameters().getVmStaticData(), getCluster(), getParameters().getGraphicsDevices(), getEffectiveCompatibilityVersion());
}
use of org.ovirt.engine.core.common.businessentities.VmStatic 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());
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class AddUnmanagedVmsCommand method convertVm.
// Visible for testing
protected void convertVm(int defaultOsId, DisplayType defaultDisplayType, long fetchTime, Map<String, Object> vmInfo) {
Guid vmId = Guid.createGuidFromString((String) vmInfo.get(VdsProperties.vm_guid));
String vmNameOnHost = (String) vmInfo.get(VdsProperties.vm_name);
if (isHostedEngineVm(vmId, vmNameOnHost)) {
// its a hosted engine VM -> import it
importHostedEngineVm(vmInfo);
return;
}
VmStatic vmStatic = new VmStatic();
vmStatic.setId(vmId);
vmStatic.setCreationDate(new Date());
vmStatic.setClusterId(getClusterId());
vmStatic.setName(String.format(EXTERNAL_VM_NAME_FORMAT, vmNameOnHost));
vmStatic.setOrigin(OriginType.EXTERNAL);
vmStatic.setNumOfSockets(VdsBrokerObjectsBuilder.parseIntVdsProperty(vmInfo.get(VdsProperties.num_of_cpus)));
vmStatic.setMemSizeMb(VdsBrokerObjectsBuilder.parseIntVdsProperty(vmInfo.get(VdsProperties.mem_size_mb)));
// VMs started before engine 3.6 may not have 'maxMemory' set
final int maxMemorySize = vmInfo.get(VdsProperties.maxMemSize) != null ? VdsBrokerObjectsBuilder.parseIntVdsProperty(vmInfo.get(VdsProperties.maxMemSize)) : vmStatic.getMemSizeMb();
vmStatic.setMaxMemorySizeMb(maxMemorySize);
vmStatic.setSingleQxlPci(false);
setOsId(vmStatic, (String) vmInfo.get(VdsProperties.guest_os), defaultOsId);
setDisplayType(vmStatic, (String) vmInfo.get(VdsProperties.displayType), defaultDisplayType);
addExternallyManagedVm(vmStatic);
addDevices(vmInfo, fetchTime);
log.info("Importing VM '{}' as '{}', as it is running on the on Host, but does not exist in the engine.", vmNameOnHost, vmStatic.getName());
}
Aggregations