use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class CpuProfileHelper method setAndValidateCpuProfile.
public ValidationResult setAndValidateCpuProfile(VmBase vmBase, Guid userId) {
if (vmBase.getCpuProfileId() == null) {
return assignFirstCpuProfile(vmBase, userId);
}
Guid clusterId = vmBase.getClusterId();
if (clusterId == null) {
return new ValidationResult(EngineMessage.ACTION_TYPE_CPU_PROFILE_CLUSTER_NOT_PROVIDED);
}
CpuProfile fetchedCpuProfile = cpuProfileDao.get(vmBase.getCpuProfileId());
if (fetchedCpuProfile == null) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_CPU_PROFILE_NOT_FOUND);
}
if (!clusterId.equals(fetchedCpuProfile.getClusterId())) {
return new ValidationResult(EngineMessage.ACTION_TYPE_CPU_PROFILE_NOT_MATCH_CLUSTER);
}
if (!checkPermissions(vmBase.getCpuProfileId(), userId)) {
return new ValidationResult(EngineMessage.ACTION_TYPE_NO_PERMISSION_TO_ASSIGN_CPU_PROFILE, String.format("$cpuProfileId %s", vmBase.getCpuProfileId()), String.format("$cpuProfileName %s", fetchedCpuProfile.getName()));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainModel method buildImportVmParameters.
private List<ActionParametersBase> buildImportVmParameters() {
List<ActionParametersBase> prms = new ArrayList<>();
for (Object item : getItems()) {
VM vm = ((ImportVmData) item).getVm();
ImportVmParameters prm = new ImportVmParameters(vm, (Guid) getEntity(), Guid.Empty, getStoragePool().getId(), getCluster().getSelectedItem().getId());
if (getClusterQuota().getSelectedItem() != null && getClusterQuota().getIsAvailable()) {
prm.setQuotaId(getClusterQuota().getSelectedItem().getId());
}
CpuProfile cpuProfile = getCpuProfiles().getSelectedItem();
if (cpuProfile != null) {
prm.setCpuProfileId(cpuProfile.getId());
}
prm.setForceOverride(true);
prm.setCopyCollapse(((ImportVmData) item).getCollapseSnapshots().getEntity());
Map<Guid, Guid> map = new HashMap<>();
for (Map.Entry<Guid, Disk> entry : vm.getDiskMap().entrySet()) {
DiskImage disk = (DiskImage) entry.getValue();
map.put(disk.getId(), getDiskImportData(disk.getId()).getSelectedStorageDomain().getId());
disk.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(getDiskImportData(disk.getId()).getSelectedVolumeType(), getDiskImportData(disk.getId()).getSelectedStorageDomain().getStorageType()));
disk.setVolumeType(getDiskImportData(disk.getId()).getSelectedVolumeType());
if (getDiskImportData(disk.getId()).getSelectedQuota() != null) {
disk.setQuotaId(getDiskImportData(disk.getId()).getSelectedQuota().getId());
}
}
prm.setImageToDestinationDomainMap(map);
if (((ImportVmData) item).isExistsInSystem() || ((ImportVmData) item).getClone().getEntity()) {
prm.setImportAsNewEntity(true);
prm.setCopyCollapse(true);
}
prms.add(prm);
}
return prms;
}
use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class ImportVmFromExternalSourceModel method buildImportVmFromExternalProviderParameters.
private List<ActionParametersBase> buildImportVmFromExternalProviderParameters() {
List<ActionParametersBase> prms = new ArrayList<>();
for (Object item : getItems()) {
ImportVmData importVmData = (ImportVmData) item;
VM vm = importVmData.getVm();
ImportVmFromExternalProviderParameters prm = new ImportVmFromExternalProviderParameters(vm, getStorage().getSelectedItem().getId(), getStoragePool().getId(), getCluster().getSelectedItem().getId());
prm.setUrl(url);
prm.setUsername(username);
prm.setPassword(password);
prm.setProxyHostId(proxyHostId);
prm.setVirtioIsoName(getIso().getIsChangable() && getIso().getSelectedItem() != null ? getIso().getSelectedItem().getRepoImageId() : null);
prm.setExternalName(importVmData.getName());
if (getClusterQuota().getSelectedItem() != null && getClusterQuota().getIsAvailable()) {
prm.setQuotaId(getClusterQuota().getSelectedItem().getId());
}
CpuProfile cpuProfile = getCpuProfiles().getSelectedItem();
if (cpuProfile != null) {
prm.setCpuProfileId(cpuProfile.getId());
}
prm.setForceOverride(true);
prm.setCopyCollapse(importVmData.getCollapseSnapshots().getEntity());
for (Map.Entry<Guid, Disk> entry : vm.getDiskMap().entrySet()) {
DiskImage disk = (DiskImage) entry.getValue();
ImportDiskData importDiskData = getDiskImportData(disk.getDiskAlias());
disk.setVolumeType(getAllocation().getSelectedItem());
// virt-v2v which converts the image format as well
if (vm.getOrigin() != OriginType.KVM) {
disk.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(disk.getVolumeType(), getStorage().getSelectedItem().getStorageType()));
}
if (getDiskImportData(disk.getDiskAlias()).getSelectedQuota() != null) {
disk.setQuotaId(importDiskData.getSelectedQuota().getId());
}
}
updateNetworkInterfacesForVm(vm);
if (importVmData.isExistsInSystem() || importVmData.getClone().getEntity()) {
prm.setImportAsNewEntity(true);
prm.setCopyCollapse(true);
}
prms.add(prm);
}
return prms;
}
use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class ImportVmFromOvaModel method buildImportVmFromOvaParameters.
private List<ActionParametersBase> buildImportVmFromOvaParameters() {
ImportVmData importVmData = (ImportVmData) getItems().iterator().next();
VM vm = importVmData.getVm();
ImportVmFromOvaParameters prm = new ImportVmFromOvaParameters(vm, getStorage().getSelectedItem().getId(), getStoragePool().getId(), getCluster().getSelectedItem().getId());
prm.setOvaPath(ovaPath);
prm.setProxyHostId(hostId);
prm.setVirtioIsoName(getIso().getIsChangable() && getIso().getSelectedItem() != null ? getIso().getSelectedItem().getRepoImageId() : null);
prm.setExternalName(importVmData.getName());
if (getClusterQuota().getSelectedItem() != null && getClusterQuota().getIsAvailable()) {
prm.setQuotaId(getClusterQuota().getSelectedItem().getId());
}
CpuProfile cpuProfile = getCpuProfiles().getSelectedItem();
if (cpuProfile != null) {
prm.setCpuProfileId(cpuProfile.getId());
}
prm.setForceOverride(true);
prm.setCopyCollapse(importVmData.getCollapseSnapshots().getEntity());
for (Map.Entry<Guid, Disk> entry : vm.getDiskMap().entrySet()) {
DiskImage disk = (DiskImage) entry.getValue();
ImportDiskData importDiskData = getDiskImportData(disk.getDiskAlias());
disk.setVolumeType(getAllocation().getSelectedItem());
disk.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(disk.getVolumeType(), getStorage().getSelectedItem().getStorageType()));
if (getDiskImportData(disk.getDiskAlias()).getSelectedQuota() != null) {
disk.setQuotaId(importDiskData.getSelectedQuota().getId());
}
}
updateNetworkInterfacesForVm(vm);
if (importVmData.isExistsInSystem() || importVmData.getClone().getEntity()) {
prm.setImportAsNewEntity(true);
prm.setCopyCollapse(true);
}
return Collections.singletonList(prm);
}
use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class BaseVmListModelTest method setUpUnitVmModelExpectations.
protected void setUpUnitVmModelExpectations(UnitVmModel model) {
when(model.getVmType().getSelectedItem()).thenReturn(VM_TYPE);
VmTemplate template = new VmTemplate();
template.setId(TEMPLATE_GUID);
TemplateWithVersion templateWithVersion = mock(TemplateWithVersion.class);
when(templateWithVersion.getTemplateVersion()).thenReturn(template);
when(model.getTemplateWithVersion().getSelectedItem()).thenReturn(templateWithVersion);
when(model.getName().getEntity()).thenReturn(VM_NAME);
InstanceType instanceType = new VmTemplate();
instanceType.setId(INSTANCE_TYPE_ID);
when(model.getInstanceTypes().getSelectedItem()).thenReturn(instanceType);
when(model.getOSType().getSelectedItem()).thenReturn(OS_TYPE);
when(model.getNumOfMonitors().getSelectedItem()).thenReturn(NUM_OF_MONITORS);
when(model.getDescription().getEntity()).thenReturn(DESCRIPTION);
when(model.getComment().getEntity()).thenReturn(COMMENT);
when(model.getEmulatedMachine().getSelectedItem()).thenReturn(EMULATED_MACHINE);
when(model.getCustomCpu().getSelectedItem()).thenReturn(CUSTOM_CPU_NAME);
when(model.getMemSize().getEntity()).thenReturn(MEM_SIZE);
when(model.getMaxMemorySize().getEntity()).thenReturn(MAX_MEMORY_SIZE);
when(model.getMinAllocatedMemory().getEntity()).thenReturn(MIN_MEM);
when(model.getSelectedCluster().getId()).thenReturn(CLUSTER_ID);
ListModel<TimeZoneModel> timeZoneModelListModel = mockTimeZoneListModel();
when(model.getTimeZone()).thenReturn(timeZoneModelListModel);
when(model.getNumOfSockets().getSelectedItem()).thenReturn(NUM_OF_SOCKETS);
when(model.getCoresPerSocket().getSelectedItem()).thenReturn(CORES_PER_SOCKET);
when(model.getThreadsPerCore().getSelectedItem()).thenReturn(THREADS_PER_CORE);
SerialNumberPolicyModel serialNumberPolicyModel = mockSerialNumberPolicyModel();
when(model.getSerialNumberPolicy()).thenReturn(serialNumberPolicyModel);
when(model.getAllowConsoleReconnect().getEntity()).thenReturn(true);
when(model.getIsSingleQxlEnabled().getEntity()).thenReturn(true);
when(model.getTotalCPUCores().getEntity()).thenReturn(Integer.toString(TOTAL_CPU));
when(model.getUsbPolicy().getSelectedItem()).thenReturn(USB_POLICY);
when(model.getIsStateless().getEntity()).thenReturn(true);
when(model.getIsSmartcardEnabled().getEntity()).thenReturn(true);
when(model.getIsDeleteProtected().getEntity()).thenReturn(true);
when(model.extractSelectedSsoMethod()).thenReturn(SSO_METHOD);
when(model.getBootSequence()).thenReturn(BOOT_SEQUENCE);
ListModel<RepoImage> cdListModel = mockCdListModel();
when(model.getCdImage()).thenReturn(cdListModel);
when(model.getIsHighlyAvailable().getEntity()).thenReturn(true);
when(model.getInitrd_path().getEntity()).thenReturn(INITRD_PATH);
when(model.getKernel_path().getEntity()).thenReturn(KERNEL_PATH);
when(model.getKernel_parameters().getEntity()).thenReturn(KERNEL_PARAMS);
when(model.getCustomPropertySheet().serialize()).thenReturn(CUSTOM_PROPERTIES);
ListModel<Quota> quotaListModel = mockQuotaListModel();
when(model.getQuota()).thenReturn(quotaListModel);
when(model.getVncKeyboardLayout().getSelectedItem()).thenReturn(VNC_KEYBOARD_LAYOUT);
when(model.getDisplayType().getSelectedItem()).thenReturn(DISPLAY_TYPE);
EntityModel<Integer> priorityEntityModel = mockEntityModel(PRIORITY);
when(model.getPriority().getSelectedItem()).thenReturn(priorityEntityModel);
when(model.getIsRunAndPause().getEntity()).thenReturn(true);
VDS defaultHost = new VDS();
defaultHost.setId(HOST_ID);
when(model.getDefaultHost().getSelectedItem()).thenReturn(defaultHost);
when(model.getDefaultHost().getSelectedItems()).thenReturn(Collections.singletonList(defaultHost));
when(model.getIsAutoAssign().getEntity()).thenReturn(false);
when(model.getMigrationMode().getSelectedItem()).thenReturn(MIGRATION_SUPPORT);
when(model.getSelectedMigrationDowntime()).thenReturn(MIGRATION_DOWNTIME);
when(model.getBootMenuEnabled().getEntity()).thenReturn(true);
when(model.getSpiceFileTransferEnabled().getEntity()).thenReturn(true);
when(model.getSpiceCopyPasteEnabled().getEntity()).thenReturn(true);
ListModel<CpuProfile> cpuProfiles = mockCpuProfiles();
when(model.getCpuProfiles()).thenReturn(cpuProfiles);
when(model.getNumaNodeCount().getEntity()).thenReturn(0);
when(model.getNumaTuneMode().getSelectedItem()).thenReturn(NumaTuneMode.INTERLEAVE);
when(model.getAutoConverge().getSelectedItem()).thenReturn(true);
when(model.getMigrateCompressed().getSelectedItem()).thenReturn(true);
when(model.getIcon().getEntity()).thenReturn(new IconWithOsDefault(LARGE_ICON_DATA, LARGE_OS_DEFAULT_ICON_DATA, SMALL_ICON_ID, ValidationResult.ok()));
when(model.getIoThreadsEnabled().getEntity()).thenReturn(true);
when(model.getConsoleDisconnectAction().getSelectedItem()).thenReturn(ConsoleDisconnectAction.REBOOT);
when(model.getCustomCompatibilityVersion().getSelectedItem()).thenReturn(Version.v3_6);
when(model.getOverrideMigrationPolicy().getEntity()).thenReturn(false);
when(model.getLease().getSelectedItem()).thenReturn(null);
}
Aggregations