private static VmStatic cloneVmStatic(VmStatic instance) { VmStatic obj = new VmStatic(); 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.setBiosType(instance.getBiosType()); 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());
@Override public VmStatic mapRow(ResultSet rs, int rowNum) throws SQLException { final VmStatic entity = new VmStatic(); map(rs, entity); entity.setId(getGuidDefaultEmpty(rs, "vm_guid")); entity.setClusterId(getGuidDefaultEmpty(rs, "cluster_id")); entity.setName(rs.getString("vm_name")); entity.setVmtGuid(getGuidDefaultEmpty(rs, "vmt_guid")); entity.setInitialized(rs.getBoolean("is_initialized")); entity.setCpuPinning(rs.getString("cpu_pinning")); entity.setUseHostCpuFlags(rs.getBoolean("host_cpu_flags")); entity.setInstanceTypeId(Guid.createGuidFromString(rs.getString("instance_type_id"))); entity.setImageTypeId(Guid.createGuidFromString(rs.getString("image_type_id"))); entity.setOriginalTemplateName(rs.getString("original_template_name")); entity.setOriginalTemplateGuid(getGuid(rs, "original_template_id")); // if template_version_number is null it means use latest version entity.setUseLatestVersion(rs.getObject("template_version_number") == USE_LATEST_VERSION_NUMBER_INDICATOR); entity.setProviderId(getGuid(rs, "provider_id")); return entity; } }
@Override protected void updateExistingEntity() { existingEntity.setDescription("updated"); existingEntity.setCpuProfileId(FixturesTool.CPU_PROFILE_2); existingEntity.setProviderId(null); List<Guid> hostGuidsList = Arrays.asList(HOST_GUIDS); existingEntity.setDedicatedVmForVdsList(hostGuidsList); }
public static VmStatic map(VmTemplate entity, VmStatic template, Version version) { VmStatic staticVm = template != null ? template : new VmStatic(); staticVm.setId(Guid.Empty); staticVm.setVmtGuid(entity.getId()); staticVm.setClusterId(entity.getClusterId()); staticVm.setOsId(entity.getOsId()); staticVm.setNiceLevel(entity.getNiceLevel()); staticVm.setCpuShares(entity.getCpuShares()); staticVm.setStateless(entity.isStateless()); staticVm.setDeleteProtected(entity.isDeleteProtected()); staticVm.setSsoMethod(entity.getSsoMethod()); staticVm.setVmType(entity.getVmType()); staticVm.setIsoPath(entity.getIsoPath()); staticVm.setKernelUrl(entity.getKernelUrl()); staticVm.setKernelParams(entity.getKernelParams()); staticVm.setInitrdUrl(entity.getInitrdUrl()); staticVm.setTimeZone(entity.getTimeZone()); staticVm.setAllowConsoleReconnect(entity.isAllowConsoleReconnect()); staticVm.setVncKeyboardLayout(entity.getVncKeyboardLayout()); staticVm.setVmInit(entity.getVmInit()); staticVm.setSerialNumberPolicy(entity.getSerialNumberPolicy()); staticVm.setCustomSerialNumber(entity.getCustomSerialNumber()); staticVm.setSpiceFileTransferEnabled(entity.isSpiceFileTransferEnabled()); staticVm.setSpiceCopyPasteEnabled(entity.isSpiceCopyPasteEnabled()); staticVm.setRunAndPause(entity.isRunAndPause()); staticVm.setCpuProfileId(entity.getCpuProfileId()); staticVm.setAutoConverge(entity.getAutoConverge()); staticVm.setMigrateCompressed(entity.getMigrateCompressed()); staticVm.setCustomProperties(entity.getCustomProperties());
private static VmStatic doMapVmBaseHwPartToVmStatic(VmBase entity, VmStatic staticVm, Version version) { staticVm.setMemSizeMb(entity.getMemSizeMb()); staticVm.setMaxMemorySizeMb(entity.getMaxMemorySizeMb()); staticVm.setAutoStartup(entity.isAutoStartup()); staticVm.setSmartcardEnabled(entity.isSmartcardEnabled()); staticVm.setDefaultBootSequence(entity.getDefaultBootSequence()); staticVm.setDefaultDisplayType(entity.getDefaultDisplayType()); staticVm.setNumOfSockets(entity.getNumOfSockets()); staticVm.setCpuPerSocket(entity.getCpuPerSocket()); staticVm.setThreadsPerCpu(entity.getThreadsPerCpu()); staticVm.setNumOfMonitors(entity.getNumOfMonitors()); staticVm.setSingleQxlPci(entity.getSingleQxlPci()); staticVm.setPriority(entity.getPriority()); staticVm.setUsbPolicy(entity.getUsbPolicy()); staticVm.setTunnelMigration(entity.getTunnelMigration()); staticVm.setMigrationSupport(entity.getMigrationSupport()); staticVm.setMigrationDowntime(entity.getMigrationDowntime()); staticVm.setDedicatedVmForVdsList(entity.getDedicatedVmForVdsList()); staticVm.setMinAllocatedMem(entity.getMinAllocatedMem()); staticVm.setNumOfIoThreads(entity.getNumOfIoThreads()); return staticVm; }
@Override protected VmStatic generateNewEntity() { VmStatic newVmStatic = new VmStatic(); newVmStatic.setId(Guid.newGuid()); newVmStatic.setName("New Virtual Machine"); newVmStatic.setClusterId(FixturesTool.CLUSTER); newVmStatic.setVmtGuid(FixturesTool.VM_TEMPLATE_RHEL5); newVmStatic.setOrigin(OriginType.OVIRT); newVmStatic.setQuotaId(FixturesTool.QUOTA_GENERAL); newVmStatic.setCpuProfileId(FixturesTool.CPU_PROFILE_1); newVmStatic.setSmallIconId(FixturesTool.SMALL_ICON_ID); newVmStatic.setLargeIconId(FixturesTool.LARGE_ICON_ID); newVmStatic.setConsoleDisconnectAction(ConsoleDisconnectAction.REBOOT); return newVmStatic; }
@Mapping(from = Vm.class, to = VmStatic.class) public static VmStatic map(Vm vm, VmStatic template) { VmStatic staticVm = template != null ? template : new VmStatic(); if (!vm.isSetMemory() && staticVm.getMemSizeMb()==0){ staticVm.setMemSizeMb(DEFAULT_MEMORY_SIZE); staticVm.setVmtGuid(GuidUtils.asGuid(vm.getTemplate().getId())); staticVm.setUseLatestVersion(vm.isUseLatestTemplateVersion()); staticVm.setUseHostCpuFlags(vm.getCpu().getMode() == CpuMode.HOST_PASSTHROUGH); staticVm.setCpuPinning(cpuTuneToString(vm.getCpu().getCpuTune())); staticVm.setVmInit(InitializationMapper.map(vm.getInitialization(), staticVm.getVmInit())); if (staticVm.getVmInit() == null) { staticVm.setVmInit(new VmInit()); staticVm.getVmInit().setDomain(vm.getDomain().getName()); staticVm.setNumaTuneMode(map(vm.getNumaTuneMode(), null)); staticVm.setProviderId(providerId == null ? null : GuidUtils.asGuid(providerId));
@Mapping(from = VmPool.class, to = VmStatic.class) public static VmStatic map(VmPool model, VmStatic template) { VmStatic entity = template != null ? template : new VmStatic(); if (model.getVm() != null) { entity = VmMapper.map(model.getVm(), entity); } entity.setName(model.getName()); entity.setDescription(model.getDescription()); if (model.isSetTemplate() && model.getTemplate().isSetId()) { entity.setVmtGuid(GuidUtils.asGuid(model.getTemplate().getId())); } if (model.isSetCluster() && model.getCluster().isSetId()) { entity.setClusterId(GuidUtils.asGuid(model.getCluster().getId())); } if (model.isSetUseLatestTemplateVersion()) { entity.setUseLatestVersion(model.isUseLatestTemplateVersion()); } return entity; }
private void createHostedEngineVm(Guid id) { VmStatic vmStatic = new VmStatic(); vmStatic.setId(id); vmStatic.setClusterId(FixturesTool.CLUSTER_RHEL6_ISCSI); vmStatic.setName("HostedEngine"); vmStatic.setOrigin(OriginType.HOSTED_ENGINE); vmStatic.setCpuProfileId(FixturesTool.CPU_PROFILE_1); vmStaticDao.save(vmStatic); VmDynamic vmDynamic = new VmDynamic(); vmDynamic.setId(id); vmDynamicDao.save(vmDynamic); VmStatistics vmStatistics = new VmStatistics(); vmStatistics.setId(id); vmStatisticsDao.save(vmStatistics); }
builtFromTemplate.setCpuProfileId(null); instanceTypeEntity = lookupInstance(vm.getInstanceType()); builtFromInstanceType = VmMapper.map(instanceTypeEntity, builtFromTemplate, cluster.getCompatibilityVersion()); builtFromInstanceType.setInstanceTypeId(instanceTypeEntity.getId()); staticVm.setClusterId(cluster.getId()); staticVm.setOsId(OsRepository.AUTO_SELECT_OS); staticVm.setUsbPolicy(VmMapper.getUsbPolicyOnCreate(vm.getUsb())); staticVm.setDedicatedVmForVdsList(new LinkedList<>(hostGuidsSet)); } else { vm.setPlacementPolicy(null); staticVm.setMigrationSupport(null);
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); existingVm = dao.get(FixturesTool.VM_RHEL5_POOL_57); existingVm.setStatus(VMStatus.Up); VM newVm = new VM(); newVm.setId(Guid.newGuid()); newVm.setClusterId(FixturesTool.CLUSTER_RHEL6_ISCSI); newVm.setVmtGuid(FixturesTool.VM_TEMPLATE_RHEL5); VmStatic newVmStatic = new VmStatic(); newVmStatic.setName("New Virtual Machine"); newVmStatic.setClusterId(FixturesTool.CLUSTER_RHEL6_ISCSI); newVmStatic.setVmtGuid(FixturesTool.VM_TEMPLATE_RHEL5); }
@Test public void testIsHostedEngineStorage() { VmStatic vm = new VmStatic(); vm.setId(Guid.newGuid()); vm.setOrigin(OriginType.HOSTED_ENGINE); vmStaticDao.save(vm); new VmDeviceId(disk.getId(), vm.getId()), VmDeviceGeneralType.DISK, VmDeviceType.DISK.getName(), vm.setOrigin(OriginType.MANAGED_HOSTED_ENGINE); vmStaticDao.update(vm);
public void setStaticData(final VmStatic value) { vmStatic = value == null ? new VmStatic() : value; }
@Override public Object getQueryableId() { return getId(); }
@Test public void testUpdateHostPinningPolicy() { final VmStatic vmTemplate = new VmStatic(); vmTemplate.setDedicatedVmForVdsList(Guid.newGuid()); final Vm vm = new Vm(); vm.setPlacementPolicy(createPlacementPolicy(Guid.newGuid(), Guid.newGuid())); final VmStatic mappedVm = VmMapper.map(vm, vmTemplate); final List<Guid> hosts = new ArrayList<>(); for (Host host : vm.getPlacementPolicy().getHosts().getHosts()){ hosts.add(Guid.createGuidFromString(host.getId())); } assertEquals(new HashSet(hosts), new HashSet(mappedVm.getDedicatedVmForVdsList())); }
private void setupHostedEngineTests(boolean isHostedEngineVm, int vmCount) { // create the VmStatic instance VmStatic vmStatic = new VmStatic(); vmStatic.setId(newVmId); vmStatic.setOrigin(isHostedEngineVm ? OriginType.MANAGED_HOSTED_ENGINE : OriginType.RHEV); vmStaticDao.save(vmStatic); // create the VmDynamic instance VmDynamic vmDynamic = new VmDynamic(); vmDynamic.setId(newVmId); vmDynamic.setStatus(VMStatus.Up); vmDynamic.setRunOnVds(existingVds.getId()); vmDynamicDao.save(vmDynamic); // update the VDS instance existingVds.setVmCount(vmCount); vdsDynamicDao.update(existingVds.getDynamicData()); } }
@Mapping(from = Template.class, to = VmStatic.class) public static VmStatic map(Template model, VmStatic incoming) { VmStatic staticVm = incoming != null ? incoming : new VmStatic(); mapVmBaseModelToEntity(staticVm, model); if (model.isSetInitialization()) { staticVm.setVmInit(InitializationMapper.map(model.getInitialization(), staticVm.getVmInit())); } if (model.isSetDomain() && model.getDomain().isSetName()) { if (staticVm.getVmInit() == null) { staticVm.setVmInit(new VmInit()); } staticVm.getVmInit().setDomain(model.getDomain().getName()); } return staticVm; }
public void setClusterId(Guid value) { this.vmStatic.setClusterId(value); }
@Override protected void readGeneralData(XmlNode content) { super.readGeneralData(content); consumeReadProperty(content, TEMPLATE_ID, val -> _vm.getStaticData().setVmtGuid(new Guid(val))); consumeReadProperty(content, TEMPLATE_NAME, val -> _vm.setVmtName(val)); consumeReadProperty(content, INSTANCE_TYPE_ID, val -> _vm.setInstanceTypeId(new Guid(val))); consumeReadProperty(content, TRUSTED_SERVICE, val -> _vm.setTrustedService(Boolean.parseBoolean(val))); consumeReadProperty(content, ORIGINAL_TEMPLATE_ID, val -> _vm.setOriginalTemplateGuid(new Guid(val))); consumeReadProperty(content, ORIGINAL_TEMPLATE_NAME, val -> _vm.getStaticData().setOriginalTemplateName(val)); consumeReadProperty(content, USE_LATEST_VERSION, val -> _vm.setUseLatestVersion(Boolean.parseBoolean(val))); consumeReadProperty(content, USE_HOST_CPU, val -> _vm.setUseHostCpuFlags(Boolean.parseBoolean(val)));