protected final void map(final ResultSet rs, final T entity) throws SQLException { entity.setOsId(rs.getInt("os")); entity.setDescription(rs.getString("description")); entity.setComment(rs.getString("free_text_comment")); entity.setCreationDate(DbFacadeUtils.fromDate(rs.getTimestamp("creation_date"))); entity.setNumOfSockets(rs.getInt("num_of_sockets")); entity.setCpuPerSocket(rs.getInt("cpu_per_socket")); entity.setTimeZone(rs.getString("time_zone")); entity.setVmType(VmType.forValue(rs.getInt("vm_type"))); entity.setUsbPolicy(UsbPolicy.forValue(rs.getInt("usb_policy"))); entity.setFailBack(rs.getBoolean("fail_back")); entity.setDefaultBootSequence(BootSequence.forValue(rs.getInt("default_boot_sequence"))); entity.setNiceLevel(rs.getInt("nice_level")); entity.setCpuShares(rs.getInt("cpu_shares")); entity.setPriority(rs.getInt("priority")); entity.setAutoStartup(rs.getBoolean("auto_startup")); entity.setStateless(rs.getBoolean("is_stateless")); entity.setDbGeneration(rs.getLong("db_generation")); entity.setIsoPath(rs.getString("iso_path")); entity.setOrigin(OriginType.forValue(rs.getInt("origin"))); entity.setKernelUrl(rs.getString("kernel_url")); entity.setKernelParams(rs.getString("kernel_params")); entity.setInitrdUrl(rs.getString("initrd_url")); entity.setSmartcardEnabled(rs.getBoolean("is_smartcard_enabled")); entity.setDeleteProtected(rs.getBoolean("is_delete_protected")); entity.setSsoMethod(SsoMethod.fromString(rs.getString("sso_method"))); entity.setTunnelMigration((Boolean) rs.getObject("tunnel_migration")); entity.setVncKeyboardLayout(rs.getString("vnc_keyboard_layout")); entity.setRunAndPause(rs.getBoolean("is_run_and_pause")); entity.setCreatedByUserId(Guid.createGuidFromString(rs.getString("created_by_user_id"))); entity.setMigrationDowntime((Integer) rs.getObject("migration_downtime")); entity.setSerialNumberPolicy( SerialNumberPolicy.forValue((Integer) rs.getObject("serial_number_policy"))); entity.setCustomSerialNumber(rs.getString("custom_serial_number")); }
@Override public VmDevice mapRow(ResultSet rs, int rowNum) throws SQLException { VmDevice vmDevice = new VmDevice(); vmDevice.setId( new VmDeviceId( Guid.createGuidFromString(rs.getString("device_id")), Guid.createGuidFromString(rs.getString("vm_id")))); vmDevice.setDevice(rs.getString("device")); vmDevice.setType(rs.getString("type")); vmDevice.setAddress(rs.getString("address")); vmDevice.setBootOrder(rs.getInt("boot_order")); vmDevice.setSpecParams(rs.getString("spec_params")); vmDevice.setIsManaged(rs.getBoolean("is_managed")); vmDevice.setIsPlugged(rs.getBoolean("is_plugged")); vmDevice.setIsReadOnly(rs.getBoolean("is_readonly")); return vmDevice; }
protected void executeHttpMethod(final T method) { int responseCode = -1; VdsManager manager = ResourceManager.getInstance().getVdsManager(getParameters().getVdsId()); final HttpClient httpclient = manager.getVdsProxy().getHttpClient(); try { FutureTask<Integer> futureTask = new FutureTask( new Callable<Integer>() { @Override public Integer call() throws Exception { return httpclient.executeMethod(method); } }); Future<Integer> f = ThreadPoolUtil.execute(futureTask); if (f.get(Config.<Integer>getValue(getConfigValueTimeLimitForOperation()), TimeUnit.MINUTES) == null) { responseCode = futureTask.get(); } } catch (InterruptedException e) { throw new RuntimeException(e); } catch (Exception e) { log.debug("Exception", e); throw createNetworkException(e); } if (responseCode == getSuccessCode()) { Guid createdTask = Guid.createGuidFromString(processResponseHeaderValue(getMethod(), "Task-Id", null)); getVDSReturnValue() .setCreationInfo( new AsyncTaskCreationInfo( createdTask, getCreatedTaskType(), getParameters().getStoragePoolId())); handleOkResponse(); getVDSReturnValue().setSucceeded(true); return; } processResponseHeaderValue(getMethod(), "Content-type", "application/json"); String response; try { response = getMethod().getResponseBodyAsString(); } catch (Exception e) { throw createNetworkException(e); } Map<String, Object> resultMap = null; try { resultMap = new ObjectMapper().readValue(response, HashMap.class); status = new StatusOnlyReturnForXmlRpc(resultMap); } catch (Exception e) { throwVdsErrorException("failed to parse response " + response, EngineError.GeneralException); } proceedProxyReturnValue(); }
@Test public void testFetchAllVdsGroupForQuota() throws Exception { List<QuotaVdsGroup> quotaVdsGroupList = dao.getQuotaVdsGroupByVdsGroupGuid(null, FixturesTool.QUOTA_SPECIFIC); assertNotNull(quotaVdsGroupList); assertEquals(quotaVdsGroupList.size(), 2); for (QuotaVdsGroup quotaVdsGroup : quotaVdsGroupList) { if (quotaVdsGroup .getQuotaVdsGroupId() .equals(Guid.createGuidFromString("68c96e11-0aad-4e3a-9091-12897b7f2388"))) { assertEquals(quotaVdsGroup.getVirtualCpu(), new Integer("10")); assertEquals(quotaVdsGroup.getMemSizeMB(), unlimited); } else if (quotaVdsGroup .getQuotaVdsGroupId() .equals(Guid.createGuidFromString("68c96e11-0aad-4e3a-9091-12897b7f2389"))) { assertEquals(quotaVdsGroup.getVirtualCpu(), new Integer("1000")); assertEquals(quotaVdsGroup.getMemSizeMB(), unlimited); } } }
private void readDedicatedHostsList() { vmBase.setDedicatedVmForVdsList(new LinkedList<>()); // initialize to empty list // search all dedicated hosts with xPath XmlNodeList hostsList = selectNodes(_document, "//*/Content/" + OvfProperties.DEDICATED_VM_FOR_VDS); for (XmlNode hostNode : hostsList) { if (hostNode != null && StringUtils.isNotEmpty(hostNode.innerText)) { vmBase.getDedicatedVmForVdsList().add(Guid.createGuidFromString(hostNode.innerText)); } } }
private static Pair<StorageDomainStatic, Guid> BuildStorageStaticFromXmlRpcStruct( Map<String, Object> xmlRpcStruct) { Pair<StorageDomainStatic, Guid> returnValue = new Pair<StorageDomainStatic, Guid>(); StorageDomainStatic sdStatic = new StorageDomainStatic(); if (xmlRpcStruct.containsKey("name")) { sdStatic.setStorageName(xmlRpcStruct.get("name").toString()); } if (xmlRpcStruct.containsKey("type")) { sdStatic.setStorageType( EnumUtils.valueOf(StorageType.class, xmlRpcStruct.get("type").toString(), true)); } if (xmlRpcStruct.containsKey("class")) { String domainType = xmlRpcStruct.get("class").toString(); if ("backup".equalsIgnoreCase(domainType)) { sdStatic.setStorageDomainType(StorageDomainType.ImportExport); } else { sdStatic.setStorageDomainType(EnumUtils.valueOf(StorageDomainType.class, domainType, true)); } } if (xmlRpcStruct.containsKey("version")) { sdStatic.setStorageFormat(StorageFormatType.forValue(xmlRpcStruct.get("version").toString())); } if (sdStatic.getStorageType() != StorageType.UNKNOWN) { if (sdStatic.getStorageType().isFileDomain() && xmlRpcStruct.containsKey("remotePath")) { String path = xmlRpcStruct.get("remotePath").toString(); List<StorageServerConnections> connections = DbFacade.getInstance().getStorageServerConnectionDao().getAllForStorage(path); if (connections.isEmpty()) { sdStatic.setConnection(new StorageServerConnections()); sdStatic.getConnection().setconnection(path); sdStatic.getConnection().setstorage_type(sdStatic.getStorageType()); } else { sdStatic.setStorage(connections.get(0).getid()); sdStatic.setConnection(connections.get(0)); } } else if (sdStatic.getStorageType() != StorageType.NFS && (xmlRpcStruct.containsKey("vguuid"))) { sdStatic.setStorage(xmlRpcStruct.get("vguuid").toString()); } } if (xmlRpcStruct.containsKey("state")) { sdStatic.setSanState( EnumUtils.valueOf( SANState.class, xmlRpcStruct.get("state").toString().toUpperCase(), false)); } returnValue.setFirst(sdStatic); Object[] poolUUIDs = (Object[]) xmlRpcStruct.get("pool"); if (poolUUIDs.length != 0) { returnValue.setSecond(Guid.createGuidFromString(poolUUIDs[0].toString())); } return returnValue; }
@Override protected void readGeneralData(XmlNode content) { // General Vm XmlNode node = content.SelectSingleNode(OvfProperties.NAME); if (node != null) { _vmTemplate.setName(node.innerText); name = _vmTemplate.getName(); } node = content.SelectSingleNode(OvfProperties.TEMPLATE_ID); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { _vmTemplate.setId(new Guid(node.innerText)); } } node = content.SelectSingleNode(OvfProperties.IS_DISABLED); if (node != null) { _vmTemplate.setDisabled(Boolean.parseBoolean(node.innerText)); } node = content.SelectSingleNode(OvfProperties.TRUSTED_SERVICE); if (node != null) { _vmTemplate.setTrustedService(Boolean.parseBoolean(node.innerText)); } node = content.SelectSingleNode(OvfProperties.TEMPLATE_TYPE); if (node != null) { _vmTemplate.setTemplateType(VmEntityType.valueOf(node.innerText)); } node = content.SelectSingleNode(OvfProperties.BASE_TEMPLATE_ID); if (node != null) { _vmTemplate.setBaseTemplateId(Guid.createGuidFromString(node.innerText)); } else { // in case base template is missing, we assume it is a base template _vmTemplate.setBaseTemplateId(_vmTemplate.getId()); } node = content.SelectSingleNode(OvfProperties.TEMPLATE_VERSION_NUMBER); if (node != null) { _vmTemplate.setTemplateVersionNumber(Integer.parseInt(node.innerText)); } node = content.SelectSingleNode(OvfProperties.TEMPLATE_VERSION_NAME); if (node != null) { _vmTemplate.setTemplateVersionName(node.innerText); } node = content.SelectSingleNode("AutoStartup"); if (node != null) { _vmTemplate.setAutoStartup(Boolean.parseBoolean(node.innerText)); } }
@Override public CommandEntity mapRow(ResultSet resultSet, int rowNum) throws SQLException { CommandEntity result = new CommandEntity(); result.setUserId(Guid.createGuidFromString(resultSet.getString("user_id"))); result.setId(Guid.createGuidFromString(resultSet.getString("command_id"))); result.setJobId(Guid.createGuidFromString(resultSet.getString("job_id"))); result.setStepId(Guid.createGuidFromString(resultSet.getString("step_id"))); result.setCreatedAt(DbFacadeUtils.fromDate(resultSet.getTimestamp("created_at"))); result.setCommandType(VdcActionType.forValue(resultSet.getInt("command_type"))); result.setParentCommandId( Guid.createGuidFromString(resultSet.getString("parent_command_id"))); result.setRootCommandId( Guid.createGuidFromString(resultSet.getString("root_command_id"))); result.setCommandParameters( deserializeParameters( resultSet.getString("command_parameters"), resultSet.getString("command_params_class"))); result.setReturnValue( deserializeReturnValue( resultSet.getString("return_value"), resultSet.getString("return_value_class"))); result.setCommandStatus(getCommandStatus(resultSet.getString("status"))); result.setExecuted(resultSet.getBoolean("executed")); result.setCallbackEnabled(resultSet.getBoolean("callback_enabled")); result.setCallbackNotified(resultSet.getBoolean("callback_notified")); return result; }
@Override public storage_pool mapRow(ResultSet rs, int rowNum) throws SQLException { storage_pool entity = new storage_pool(); entity.setdescription(rs.getString("description")); entity.setId(Guid.createGuidFromString(rs.getString("id"))); entity.setname(rs.getString("name")); entity.setstorage_pool_type(StorageType.forValue(rs.getInt("storage_pool_type"))); entity.setstatus(StoragePoolStatus.forValue(rs.getInt("status"))); entity.setmaster_domain_version(rs.getInt("master_domain_version")); entity.setspm_vds_id(NGuid.createGuidFromString(rs.getString("spm_vds_id"))); entity.setcompatibility_version(new Version(rs.getString("compatibility_version"))); entity.setStoragePoolFormatType(getStorageFormatTypeForPool(rs)); return entity; }
protected void processExternallyManagedVms() { // Fetching for details from the host // and marking the VMs for addition List<String> vmsToQuery = new ArrayList<>(externalVms.size()); for (Pair<VM, VmInternalData> pair : externalVms) { vmsToQuery.add(pair.getSecond().getVmDynamic().getId().toString()); } if (!vmsToQuery.isEmpty()) { // Query VDSM for VMs info, and creating a proper VMStatic to be used when importing them Map[] vmsInfo = getVmInfo(vmsToQuery); for (Map vmInfo : vmsInfo) { Guid vmId = Guid.createGuidFromString((String) vmInfo.get(VdsProperties.vm_guid)); VmStatic vmStatic = new VmStatic(); vmStatic.setId(vmId); vmStatic.setCreationDate(new Date()); vmStatic.setVdsGroupId(vdsManager.getVdsGroupId()); String vmNameOnHost = (String) vmInfo.get(VdsProperties.vm_name); if (StringUtils.equals( Config.<String>getValue(ConfigValues.HostedEngineVmName), vmNameOnHost)) { // its a hosted engine VM -> import it and skip the external VM phase importHostedEngineVM(vmInfo); continue; } else { 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))); vmStatic.setSingleQxlPci(false); externalVmsToAdd.add(vmStatic); log.info( "Importing VM '{}' as '{}', as it is running on the on Host, but does not exist in the engine.", vmNameOnHost, vmStatic.getName()); } } }
protected void readGeneralData() { XmlNode content = selectSingleNode(_document, "//*/Content"); XmlNode node; vmBase.setVmInit(new VmInit()); // set ovf version to the ovf object vmBase.setOvfVersion(getVersion()); node = selectSingleNode(content, OvfProperties.DESCRIPTION); if (node != null) { vmBase.setDescription(node.innerText); } node = selectSingleNode(content, OvfProperties.COMMENT); if (node != null) { vmBase.setComment(node.innerText); } node = selectSingleNode(content, OvfProperties.DOMAIN); if (node != null) { vmBase.getVmInit().setDomain(node.innerText); } node = selectSingleNode(content, OvfProperties.CREATION_DATE); if (node != null) { Date creationDate = OvfParser.utcDateStringToLocaDate(node.innerText); if (creationDate != null) { vmBase.setCreationDate(creationDate); } } node = selectSingleNode(content, OvfProperties.EXPORT_DATE); if (node != null) { Date exportDate = OvfParser.utcDateStringToLocaDate(node.innerText); if (exportDate != null) { vmBase.setExportDate(exportDate); } } node = selectSingleNode(content, OvfProperties.DEFAULT_BOOT_SEQUENCE); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setDefaultBootSequence(BootSequence.forValue(Integer.parseInt(node.innerText))); } } node = selectSingleNode(content, OvfProperties.INITRD_URL); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setInitrdUrl(node.innerText); } } node = selectSingleNode(content, OvfProperties.KERNEL_URL); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setKernelUrl(node.innerText); } } node = selectSingleNode(content, OvfProperties.KERNEL_PARAMS); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setKernelParams(node.innerText); } } node = selectSingleNode(content, OvfProperties.GENERATION); if (node != null) { vmBase.setDbGeneration(Long.parseLong(node.innerText)); } else { vmBase.setDbGeneration(1L); } node = selectSingleNode(content, OvfProperties.CUSTOM_COMPATIBILITY_VERSION); if (node != null) { vmBase.setCustomCompatibilityVersion(new Version(node.innerText)); } Version originVersion = new Version(getVersion()); // the originating ENGINE version node = selectSingleNode(content, OvfProperties.CLUSTER_COMPATIBILITY_VERSION); if (node != null) { originVersion = new Version(node.innerText); } vmBase.setClusterCompatibilityVersionOrigin(originVersion); // Note: the fetching of 'default display type' should happen before reading // the hardware section node = selectSingleNode(content, getDefaultDisplayTypeStringRepresentation()); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setDefaultDisplayType(DisplayType.forValue(Integer.parseInt(node.innerText))); } } XmlNodeList list = selectNodes(content, "Section"); if (list != null) { // The Os need to be read before the hardware node = getNode(list, "xsi:type", "ovf:OperatingSystemSection_Type"); if (node != null) { readOsSection(node); if (!osRepository.isLinux(vmBase.getOsId()) || vmBase.getDefaultDisplayType() != DisplayType.qxl) { vmBase.setSingleQxlPci(false); } } node = getNode(list, "xsi:type", "ovf:VirtualHardwareSection_Type"); if (node != null) { readHardwareSection(node); } node = getNode(list, "xsi:type", "ovf:SnapshotsSection_Type"); if (node != null) { readSnapshotsSection(node); } } // after reading the hardware section, if graphics device is still absent, add a default one addDefaultGraphicsDevice(); // if boot order is not set, figure out some default based on the set of bootable disks setDefaultBootDevice(); // due to dependency on vmBase.getOsId() must be read AFTER readOsSection node = selectSingleNode(content, OvfProperties.TIMEZONE); if (node != null && StringUtils.isNotEmpty(node.innerText)) { vmBase.setTimeZone(node.innerText); } else { if (osRepository.isWindows(vmBase.getOsId())) { vmBase.setTimeZone(Config.<String>getValue(ConfigValues.DefaultWindowsTimeZone)); } else { vmBase.setTimeZone(Config.<String>getValue(ConfigValues.DefaultGeneralTimeZone)); } } node = selectSingleNode(content, OvfProperties.ORIGIN); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setOrigin(OriginType.forValue(Integer.parseInt(node.innerText))); } } node = selectSingleNode(content, OvfProperties.VM_TYPE); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setVmType(VmType.forValue(Integer.parseInt(node.innerText))); } } node = selectSingleNode(content, OvfProperties.IS_SMARTCARD_ENABLED); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setSmartcardEnabled(Boolean.parseBoolean(node.innerText)); } } node = selectSingleNode(content, OvfProperties.NUM_OF_IOTHREADS); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setNumOfIoThreads(Integer.parseInt(node.innerText)); } } node = selectSingleNode(content, OvfProperties.DELETE_PROTECTED); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setDeleteProtected(Boolean.parseBoolean(node.innerText)); } } node = selectSingleNode(content, OvfProperties.SSO_METHOD); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setSsoMethod(SsoMethod.fromString(node.innerText)); } } node = selectSingleNode(content, OvfProperties.TUNNEL_MIGRATION); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setTunnelMigration(Boolean.parseBoolean(node.innerText)); } } node = selectSingleNode(content, OvfProperties.VNC_KEYBOARD_LAYOUT); if (node != null) { if (!StringUtils.isEmpty(node.innerText)) { vmBase.setVncKeyboardLayout(node.innerText); } } node = selectSingleNode(content, OvfProperties.MIN_ALLOCATED_MEMORY); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setMinAllocatedMem(Integer.parseInt(node.innerText)); } } node = selectSingleNode(content, OvfProperties.IS_STATELESS); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setStateless(Boolean.parseBoolean(node.innerText)); } } node = selectSingleNode(content, OvfProperties.IS_RUN_AND_PAUSE); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setRunAndPause(Boolean.parseBoolean(node.innerText)); } } node = selectSingleNode(content, OvfProperties.CREATED_BY_USER_ID); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setCreatedByUserId(Guid.createGuidFromString(node.innerText)); } } node = selectSingleNode(content, OvfProperties.MIGRATION_DOWNTIME); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setMigrationDowntime(Integer.parseInt(node.innerText)); } } node = selectSingleNode(content, OvfProperties.MIGRATION_SUPPORT); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { MigrationSupport migrationSupport = MigrationSupport.forValue(Integer.parseInt(node.innerText)); vmBase.setMigrationSupport(migrationSupport); } } // TODO dedicated to multiple hosts readDedicatedHostsList(); node = selectSingleNode(content, OvfProperties.SERIAL_NUMBER_POLICY); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setSerialNumberPolicy(SerialNumberPolicy.forValue(Integer.parseInt(node.innerText))); } } node = selectSingleNode(content, OvfProperties.CUSTOM_SERIAL_NUMBER); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setCustomSerialNumber(node.innerText); } } node = selectSingleNode(content, OvfProperties.AUTO_STARTUP); if (node != null) { vmBase.setAutoStartup(Boolean.parseBoolean(node.innerText)); } node = selectSingleNode(content, OvfProperties.PRIORITY); if (node != null) { vmBase.setPriority(Integer.parseInt(node.innerText)); } node = selectSingleNode(content, OvfProperties.IS_BOOT_MENU_ENABLED); if (node != null) { vmBase.setBootMenuEnabled(Boolean.parseBoolean(node.innerText)); } node = selectSingleNode(content, OvfProperties.IS_SPICE_FILE_TRANSFER_ENABLED); if (node != null) { vmBase.setSpiceFileTransferEnabled(Boolean.parseBoolean(node.innerText)); } node = selectSingleNode(content, OvfProperties.IS_SPICE_COPY_PASTE_ENABLED); if (node != null) { vmBase.setSpiceCopyPasteEnabled(Boolean.parseBoolean(node.innerText)); } node = selectSingleNode(content, OvfProperties.ALLOW_CONSOLE_RECONNECT); if (node != null) { vmBase.setAllowConsoleReconnect(Boolean.parseBoolean(node.innerText)); } node = selectSingleNode(content, OvfProperties.IS_AUTO_CONVERGE); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setAutoConverge(Boolean.parseBoolean(node.innerText)); } } node = selectSingleNode(content, OvfProperties.IS_MIGRATE_COMPRESSED); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setMigrateCompressed(Boolean.parseBoolean(node.innerText)); } } node = selectSingleNode(content, OvfProperties.MIGRATION_POLICY_ID); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setMigrationPolicyId(Guid.createGuidFromString(node.innerText)); } } node = selectSingleNode(content, OvfProperties.CUSTOM_EMULATED_MACHINE); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setCustomEmulatedMachine(node.innerText); } } node = selectSingleNode(content, OvfProperties.CUSTOM_CPU_NAME); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setCustomCpuName(node.innerText); } } node = selectSingleNode(content, OvfProperties.PREDEFINED_PROPERTIES); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setPredefinedProperties(node.innerText); } } node = selectSingleNode(content, OvfProperties.USER_DEFINED_PROPERTIES); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setUserDefinedProperties(node.innerText); } } node = selectSingleNode(content, OvfProperties.MAX_MEMORY_SIZE_MB); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setMaxMemorySizeMb(Integer.parseInt(node.innerText)); } } vmBase.setCustomProperties( VmPropertiesUtils.getInstance() .customProperties(vmBase.getPredefinedProperties(), vmBase.getUserDefinedProperties())); node = selectSingleNode(content, OvfProperties.VM_LEASE); if (node != null) { if (StringUtils.isNotEmpty(node.innerText)) { vmBase.setLeaseStorageDomainId(new Guid(node.innerText)); } } readGeneralData(content); readVmInit(content); }
@Override public Cluster mapRow(ResultSet rs, int rowNum) throws SQLException { Cluster entity = new Cluster(); entity.setDescription(rs.getString("description")); entity.setName(rs.getString("name")); entity.setId(getGuidDefaultEmpty(rs, "cluster_id")); entity.setComment(rs.getString("free_text_comment")); entity.setCpuName(rs.getString("cpu_name")); entity.setStoragePoolId(getGuid(rs, "storage_pool_id")); entity.setStoragePoolName(rs.getString("storage_pool_name")); entity.setMaxVdsMemoryOverCommit(rs.getInt("max_vds_memory_over_commit")); entity.setCountThreadsAsCores(rs.getBoolean("count_threads_as_cores")); entity.setTransparentHugepages(rs.getBoolean("transparent_hugepages")); entity.setCompatibilityVersion(new Version(rs.getString("compatibility_version"))); entity.setMigrateOnError(MigrateOnErrorOptions.forValue(rs.getInt("migrate_on_error"))); entity.setVirtService(rs.getBoolean("virt_service")); entity.setGlusterService(rs.getBoolean("gluster_service")); entity.setGlusterCliBasedSchedulingOn(rs.getBoolean("gluster_cli_based_snapshot_scheduled")); entity.setTunnelMigration(rs.getBoolean("tunnel_migration")); entity .getRequiredRngSources() .addAll(VmRngDevice.csvToSourcesSet(rs.getString("required_rng_sources"))); entity.setEmulatedMachine(rs.getString("emulated_machine")); entity.setDetectEmulatedMachine(rs.getBoolean("detect_emulated_machine")); entity.setTrustedService(rs.getBoolean("trusted_service")); entity.setHaReservation(rs.getBoolean("ha_reservation")); entity.setOptionalReasonRequired(rs.getBoolean("optional_reason")); entity.setMaintenanceReasonRequired(rs.getBoolean("maintenance_reason_required")); entity.setClusterPolicyId(Guid.createGuidFromString(rs.getString("cluster_policy_id"))); entity.setClusterPolicyName(rs.getString("cluster_policy_name")); entity.setClusterPolicyProperties( SerializationFactory.getDeserializer() .deserializeOrCreateNew( rs.getString("cluster_policy_custom_properties"), LinkedHashMap.class)); entity.setEnableBallooning(rs.getBoolean("enable_balloon")); entity.setEnableKsm(rs.getBoolean("enable_ksm")); entity.setArchitecture(ArchitectureType.forValue(rs.getInt("architecture"))); entity.setOptimizationType(OptimizationType.from(rs.getInt("optimization_type"))); entity.setSpiceProxy(rs.getString("spice_proxy")); entity.setSerialNumberPolicy( SerialNumberPolicy.forValue((Integer) rs.getObject("serial_number_policy"))); entity.setCustomSerialNumber(rs.getString("custom_serial_number")); entity .getFencingPolicy() .setSkipFencingIfSDActive(rs.getBoolean("skip_fencing_if_sd_active")); entity .getFencingPolicy() .setSkipFencingIfConnectivityBroken(rs.getBoolean("skip_fencing_if_connectivity_broken")); entity .getFencingPolicy() .setHostsWithBrokenConnectivityThreshold( rs.getInt("hosts_with_broken_connectivity_threshold")); entity.getFencingPolicy().setFencingEnabled(rs.getBoolean("fencing_enabled")); entity.setAutoConverge((Boolean) rs.getObject("is_auto_converge")); entity.setMigrateCompressed((Boolean) rs.getObject("is_migrate_compressed")); entity.setGlusterTunedProfile(rs.getString("gluster_tuned_profile")); entity.setKsmMergeAcrossNumaNodes(rs.getBoolean("ksm_merge_across_nodes")); entity.setMigrationBandwidthLimitType( MigrationBandwidthLimitType.valueOf(rs.getString("migration_bandwidth_limit_type"))); entity.setCustomMigrationNetworkBandwidth(getInteger(rs, "custom_migration_bandwidth_limit")); return entity; }