@Override protected VdsStatic generateNewEntity() { VdsStatic newStaticVds = new VdsStatic(); newStaticVds.setHostName("farkle.redhat.com"); newStaticVds.setSshPort(22); newStaticVds.setSshUsername("root"); newStaticVds.setClusterId(existingEntity.getClusterId()); newStaticVds.setSshKeyFingerprint("b5:ad:16:19:06:9f:b3:41:69:eb:1c:42:1d:12:b5:31"); newStaticVds.setCurrentKernelCmdline("a=b"); newStaticVds.setLastStoredKernelCmdline("c=d"); newStaticVds.setKernelCmdlineIommu(true); return newStaticVds; }
@Override public Guid getId() { return vdsStatic.getId(); }
public static VdsStatic mapOperatingSystem(OperatingSystem model, VdsStatic template) { final VdsStatic entity = template != null ? template : new VdsStatic(); if (model.isSetCustomKernelCmdline()) { entity.setCurrentKernelCmdline(model.getCustomKernelCmdline()); entity.setKernelCmdlineParsable(false); } return entity; }
private MapSqlParameterSource getInsertOrUpdateParams(final VdsStatic vds) { return getCustomMapSqlParameterSource() .addValue("host_name", vds.getHostName()) .addValue("free_text_comment", vds.getComment()) .addValue("vds_unique_id", vds.getUniqueID()) .addValue("port", vds.getPort()) .addValue("cluster_id", vds.getClusterId()) .addValue("vds_id", vds.getId()) .addValue("vds_name", vds.getName()) .addValue("server_SSL_enabled", vds.isServerSslEnabled()) .addValue("vds_type", vds.getVdsType()) .addValue("vds_strength", vds.getVdsStrength()) .addValue("pm_enabled", vds.isPmEnabled()) .addValue("pm_proxy_preferences", FenceProxySourceTypeHelper.saveAsString(vds.getFenceProxySources())) .addValue("pm_detect_kdump", vds.isPmKdumpDetection()) .addValue("otp_validity", vds.getOtpValidity()) .addValue("vds_spm_priority", vds.getVdsSpmPriority()) .addValue("console_address", vds.getConsoleAddress()) .addValue("sshKeyFingerprint", vds.getSshKeyFingerprint()) .addValue("ssh_port", vds.getSshPort()) .addValue("ssh_username", vds.getSshUsername()) .addValue("disable_auto_pm", vds.isDisablePowerManagementPolicy()) .addValue("host_provider_id", vds.getHostProviderId()) .addValue("openstack_network_provider_id", vds.getOpenstackNetworkProviderId()) .addValue("kernel_cmdline", KernelCmdlineColumn.fromVdsStatic(vds).toJson()) .addValue("last_stored_kernel_cmdline", vds.getLastStoredKernelCmdline()) .addValue("reinstall_required", vds.isReinstallRequired()) .addValue("vgpu_placement", vds.getVgpuPlacement()); }
@Override protected VDS getInverse(VdsStatic to) { VDS inverse = new VDS(); inverse.setId(to.getId()); inverse.setVdsName(to.getName()); inverse.setHostName(to.getHostName()); inverse.setClusterId(to.getClusterId()); inverse.setPort(to.getPort()); inverse.setSshKeyFingerprint(to.getSshKeyFingerprint()); inverse.setHostProviderId(to.getHostProviderId()); inverse.setSshPort(to.getSshPort()); inverse.setSshUsername(to.getSshUsername()); inverse.setVdsSpmPriority(to.getVdsSpmPriority()); inverse.setConsoleAddress(to.getConsoleAddress()); inverse.setComment(to.getComment()); return inverse; }
@Mapping(from = Host.class, to = VdsStatic.class) public static VdsStatic map(Host model, VdsStatic template) { VdsStatic entity = template != null ? template : new VdsStatic(); if (model.isSetId()) { entity.setId(GuidUtils.asGuid(model.getId())); entity.setName(model.getName()); entity.setClusterId(GuidUtils.asGuid(model.getCluster().getId())); entity.setHostName(model.getAddress()); entity.setPort(model.getPort()); } else { entity.setPort(DEFAULT_VDSM_PORT); entity.setVdsSpmPriority(model.getSpm().getPriority()); entity.setConsoleAddress("".equals(model.getDisplay().getAddress()) ? null : model.getDisplay().getAddress()); entity.setVgpuPlacement(mapVgpuPlacement(model.getVgpuPlacement())); entity.setComment(model.getComment()); entity.setHostProviderId(providerId == null ? null : GuidUtils.asGuid(providerId)); entity.setOpenstackNetworkProviderId(providerId == null ? null : GuidUtils.asGuid(providerId));
@Test public void testUpdateSshHost() { Ssh sshConf = new Ssh(); sshConf.setPort(22); sshConf.setUser(new User()); sshConf.getUser().setUserName("root"); sshConf.setFingerprint("1234"); VdsStatic vdsStatic = new VdsStatic(); vdsStatic.setSshUsername("root"); vdsStatic.setSshPort(22); vdsStatic.setSshKeyFingerprint("1234"); VdsStatic mappedVdsStatic = HostMapper.map(sshConf, vdsStatic); assertEquals(22, mappedVdsStatic.getSshPort()); assertEquals("1234", mappedVdsStatic.getSshKeyFingerprint()); assertEquals("root", mappedVdsStatic.getSshUsername()); }
@BeforeEach @Override public void setUp() { Cluster cluster = new Cluster(); cluster.setName("test-cluster"); cluster.setId(Guid.newGuid()); cluster.setCompatibilityVersion(Version.v4_3); cluster.setArchitecture(ArchitectureType.x86); cluster.setMacPoolId(FixturesTool.DEFAULT_MAC_POOL_ID); cluster.setFirewallType(FirewallType.IPTABLES); cluster.setLogMaxMemoryUsedThreshold(95); cluster.setLogMaxMemoryUsedThresholdType(LogMaxMemoryUsedThresholdType.PERCENTAGE); clusterDao.save(cluster); host = new VdsStatic(); host.setId(Guid.newGuid()); host.setName("test-host"); host.setHostName("host-ip"); host.setClusterId(cluster.getId()); vdsDao.save(host); }
@Mapping(from = Ssh.class, to = VdsStatic.class) public static VdsStatic map(Ssh model, VdsStatic template) { VdsStatic entity = template != null ? template : new VdsStatic(); if (model.isSetUser() && model.getUser().isSetUserName()) { entity.setSshUsername(model.getUser().getUserName()); } if (model.isSetPort() && model.getPort() > 0) { entity.setSshPort(model.getPort()); } if (model.isSetFingerprint()) { entity.setSshKeyFingerprint(model.getFingerprint()); } return entity; }
@Mapping(from = PowerManagement.class, to = VdsStatic.class) public static VdsStatic map(PowerManagement model, VdsStatic template) { VdsStatic entity = template != null ? template : new VdsStatic(); if (model.isSetEnabled()) { entity.setPmEnabled(model.isEnabled()); } if (model.isSetAutomaticPmEnabled()) { entity.setDisablePowerManagementPolicy(!model.isAutomaticPmEnabled()); } if (model.isSetPmProxies()) { List<FenceProxySourceType> fenceProxySources = model.getPmProxies() .getPmProxies() .stream() .map(pmProxy -> FenceProxySourceType.forValue(pmProxy.getType().toString())) .collect(toCollection(LinkedList::new)); entity.setFenceProxySources(fenceProxySources); } if (model.isSetKdumpDetection()) { entity.setPmKdumpDetection(model.isKdumpDetection()); } return entity; }
@Mapping(from = VdsStatic.class, to = Ssh.class) public static Ssh map(VdsStatic entity, Ssh template) { Ssh model = template != null ? template : new Ssh(); model.setPort(entity.getSshPort()); model.setUser(new User()); model.getUser().setUserName(entity.getSshUsername()); model.setFingerprint(entity.getSshKeyFingerprint()); return model; }
public VDS() { vdsStatic = new VdsStatic(); vdsDynamic = new VdsDynamic(); vdsStatistics = new VdsStatistics(); storagePoolId = Guid.Empty; spmStatus = VdsSpmStatus.None; interfaces = new ArrayList<>(); networkNames = new HashSet<>(); fenceAgents = new LinkedList<>(); }
public Guid getClusterId() { return vdsStatic.getClusterId(); }
@Override public String getName() { return vdsStatic.getName(); }
public String getHostName() { return vdsStatic.getHostName(); }
@Override public void setId(Guid value) { vdsStatic.setId(value); vdsDynamic.setId(value); vdsStatistics.setId(value); }
public void setClusterId(Guid value) { vdsStatic.setClusterId(value); }