use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildVmsDataFromExternalProvider.
public static VM buildVmsDataFromExternalProvider(Map<String, Object> struct) {
VmStatic vmStatic = buildVmStaticDataFromExternalProvider(struct);
if (vmStatic == null) {
return null;
}
VmDynamic vmDynamic = buildVMDynamicDataFromList(struct);
VM vm = new VM(vmStatic, vmDynamic, new VmStatistics());
for (DiskImage image : vm.getImages()) {
vm.getDiskMap().put(Guid.newGuid(), image);
}
try {
vm.setClusterArch(parseArchitecture(struct));
} catch (IllegalArgumentException ex) {
log.warn("Illegal architecture type: {}, replacing with x86_64", struct.get(VdsProperties.vm_arch));
vm.setClusterArch(ArchitectureType.x86_64);
} catch (NullPointerException ex) {
log.warn("null architecture type, replacing with x86_64, {}", vm);
vm.setClusterArch(ArchitectureType.x86_64);
}
return vm;
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class Cloner method cloneVmStatic.
private static VmStatic cloneVmStatic(VmStatic instance) {
VmStatic obj = new VmStatic();
obj.setFailBack(instance.isFailBack());
obj.setDefaultBootSequence(instance.getDefaultBootSequence());
obj.setVmType(instance.getVmType());
obj.setDefaultDisplayType(instance.getDefaultDisplayType());
obj.setPriority(instance.getPriority());
obj.setIsoPath(instance.getIsoPath());
obj.setOrigin(instance.getOrigin());
obj.setAutoStartup(instance.isAutoStartup());
obj.setCpuPerSocket(instance.getCpuPerSocket());
obj.setThreadsPerCpu(instance.getThreadsPerCpu());
obj.setCreationDate(instance.getCreationDate());
obj.setDedicatedVmForVdsList(instance.getDedicatedVmForVdsList());
obj.setDescription(instance.getDescription());
obj.setComment(instance.getComment());
obj.setCustomEmulatedMachine(instance.getCustomEmulatedMachine());
obj.setCustomCpuName(instance.getCustomCpuName());
obj.setCustomCompatibilityVersion(instance.getCustomCompatibilityVersion());
obj.setInitialized(instance.isInitialized());
obj.setStateless(instance.isStateless());
obj.setRunAndPause(instance.isRunAndPause());
obj.setMemSizeMb(instance.getMemSizeMb());
obj.setNiceLevel(instance.getNiceLevel());
obj.setNumOfMonitors(instance.getNumOfMonitors());
obj.setAllowConsoleReconnect(instance.isAllowConsoleReconnect());
obj.setNumOfSockets(instance.getNumOfSockets());
obj.setTimeZone(instance.getTimeZone());
obj.setUsbPolicy(instance.getUsbPolicy());
obj.setClusterId(instance.getClusterId());
obj.setId(instance.getId());
obj.setName(instance.getName());
obj.setVmtGuid(instance.getVmtGuid());
obj.setUseLatestVersion(instance.isUseLatestVersion());
obj.setSerialNumberPolicy(instance.getSerialNumberPolicy());
obj.setCustomSerialNumber(instance.getCustomSerialNumber());
obj.setBootMenuEnabled(instance.isBootMenuEnabled());
obj.setSpiceFileTransferEnabled(instance.isSpiceFileTransferEnabled());
obj.setSpiceCopyPasteEnabled(instance.isSpiceCopyPasteEnabled());
obj.setCpuProfileId(instance.getCpuProfileId());
obj.setAutoConverge(instance.getAutoConverge());
obj.setMigrateCompressed(instance.getMigrateCompressed());
obj.setPredefinedProperties(instance.getPredefinedProperties());
obj.setUserDefinedProperties(instance.getUserDefinedProperties());
obj.setCustomProperties(instance.getCustomProperties());
obj.setSmallIconId(instance.getSmallIconId());
obj.setLargeIconId(instance.getLargeIconId());
obj.setProviderId(instance.getProviderId());
obj.setLeaseStorageDomainId(instance.getLeaseStorageDomainId());
return obj;
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class DeactivateStorageDomainCommand method getVmsWithAttachedISO.
protected List<String> getVmsWithAttachedISO() {
List<VmStatic> vms = vmStaticDao.getAllByStoragePoolId(getStorageDomain().getStoragePoolId());
List<String> vmNames = new LinkedList<>();
for (VmStatic vmStatic : vms) {
VmDynamic vmDynamic = vmDynamicDao.get(vmStatic.getId());
if (vmDynamic.getStatus() != VMStatus.Down && !StringUtils.isEmpty(vmDynamic.getCurrentCd())) {
vmNames.add(vmStatic.getName());
}
}
return vmNames;
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class BackendVmsResource method cloneVmFromSnapshot.
private Response cloneVmFromSnapshot(org.ovirt.engine.core.common.businessentities.VM configVm, Vm vm, String snapshotId, HashMap<Guid, DiskImage> images) {
VmStatic staticVm = configVm.getStaticData();
Guid sourceSnapshotId = asGuid(snapshotId);
AddVmFromSnapshotParameters params = new AddVmFromSnapshotParameters(staticVm, sourceSnapshotId);
params.setDiskInfoDestinationMap(images);
params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
params.setVirtioScsiEnabled(vm.isSetVirtioScsi() && vm.getVirtioScsi().isSetEnabled() ? vm.getVirtioScsi().isEnabled() : null);
if (vm.isSetSoundcardEnabled()) {
params.setSoundDeviceEnabled(vm.isSoundcardEnabled());
} else {
params.setSoundDeviceEnabled(isVMDeviceTypeExist(configVm.getManagedVmDeviceMap(), VmDeviceGeneralType.SOUND));
}
params.setConsoleEnabled(vm.isSetConsole() && vm.getConsole().isSetEnabled() ? vm.getConsole().isEnabled() : !getConsoleDevicesForEntity(staticVm.getId()).isEmpty());
if (vm.isSetRngDevice()) {
params.setUpdateRngDevice(true);
params.setRngDevice(RngDeviceMapper.map(vm.getRngDevice(), null));
}
DisplayHelper.setGraphicsToParams(vm.getDisplay(), params);
return performCreate(ActionType.AddVmFromSnapshot, params, new QueryIdResolver<Guid>(QueryType.GetVmByVmId, IdQueryParameters.class));
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class ImportRepoImageCommand method createTemplate.
private Guid createTemplate() {
VmTemplate blankTemplate = vmTemplateDao.get(VmTemplateHandler.BLANK_VM_TEMPLATE_ID);
VmStatic masterVm = new VmStatic(blankTemplate);
DiskImage templateDiskImage = getParameters().getDiskImage();
String vmTemplateName = getParameters().getTemplateName();
AddVmTemplateParameters parameters = new AddVmTemplateParameters(masterVm, vmTemplateName, templateDiskImage.getDiskDescription());
// Setting the user from the parent command, as the session might already be invalid
parameters.setParametersCurrentUser(getParameters().getParametersCurrentUser());
// Setting the cluster ID, and other related properties derived from it
if (getParameters().getClusterId() != null) {
masterVm.setClusterId(getParameters().getClusterId());
Cluster vdsGroup = getCluster(masterVm.getClusterId());
masterVm.setOsId(osRepository.getDefaultOSes().get(vdsGroup.getArchitecture()));
DisplayType defaultDisplayType = osRepository.getGraphicsAndDisplays(masterVm.getOsId(), vdsGroup.getCompatibilityVersion()).get(0).getSecond();
masterVm.setDefaultDisplayType(defaultDisplayType);
}
parameters.setBalloonEnabled(true);
ActionReturnValue addVmTemplateReturnValue = Backend.getInstance().runInternalAction(ActionType.AddVmTemplate, parameters, ExecutionHandler.createDefaultContextForTasks(getContext()));
// No reason for this to return null, but checking just to make sure, and returning the created template, or null if failed
return addVmTemplateReturnValue.getActionReturnValue() != null ? (Guid) addVmTemplateReturnValue.getActionReturnValue() : null;
}
Aggregations