private List<NameServer> getNameServersByDnsResolverConfigurationId(Guid dnsResolverConfigurationId) { return getCallsHandler().executeReadList("GetNameServersByDnsResolverConfigurationId", (rs, rowNum) -> { String address = rs.getString("address"); return new NameServer(address); }, getCustomMapSqlParameterSource().addValue("dns_resolver_configuration_id", dnsResolverConfigurationId)); }
@Override protected DnsResolverConfiguration generateNewEntity() { DnsResolverConfiguration dnsResolverConfiguration = new DnsResolverConfiguration(); dnsResolverConfiguration.setNameServers(new ArrayList<>(Arrays.asList(new NameServer("1.1.1.1")))); return dnsResolverConfiguration; }
@Override protected void updateExistingEntity() { existingEntity.getNameServers().add(new NameServer("2.2.2.2")); }
@Test public void testToString() { List<NameServer> nameServers = Arrays.asList(new NameServer("192.168.1.1"), new NameServer("192.168.1.2")); DnsResolverConfiguration dnsResolverConfiguration = new DnsResolverConfiguration(); dnsResolverConfiguration.setNameServers(nameServers); assertThat(dnsResolverConfiguration.toString(), is("DnsResolverConfiguration:{id='null', nameServers='[NameServer:{address='192.168.1.1'}, " + "NameServer:{address='192.168.1.2'}]'}")); }
public DnsResolverConfiguration flush() { Boolean shouldSetDnsConfiguration = this.shouldSetDnsConfiguration.getEntity(); if (!shouldSetDnsConfiguration) { return null; } List<NameServer> nameServers = new ArrayList<>(); for (NameServerModel nameServerModel : this.nameServerModelListModel.getItems()) { nameServers.add(new NameServer(nameServerModel.flush())); } DnsResolverConfiguration result = new DnsResolverConfiguration(); result.setNameServers(nameServers); if (getEntity() != null) { result.setId(getEntity().getId()); } return result; }
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); networkAttachment = new NetworkAttachment(); networkAttachment.setNicId(FixturesTool.VDS_NETWORK_INTERFACE); networkAttachment.setProperties(new HashMap<>()); networkAttachment.setId(Guid.newGuid()); networkAttachment.setNetworkId(FixturesTool.NETWORK_ENGINE); networkAttachment.setIpConfiguration(createIpConfiguration(Ipv4BootProtocol.DHCP, Ipv6BootProtocol.AUTOCONF)); networkAttachment.setDnsResolverConfiguration(new DnsResolverConfiguration()); networkAttachment.getDnsResolverConfiguration().setNameServers( new ArrayList<>(Arrays.asList(new NameServer("1.1.1.1")))); }
public NetworkAttachment networkAttachmentFromFixtures() { NetworkAttachment expected = new NetworkAttachment(); expected.setId(FixturesTool.NETWORK_ATTACHMENT); expected.setNetworkId(FixturesTool.NETWORK_ENGINE_2); expected.setNicId(FixturesTool.VDS_NETWORK_INTERFACE2); IpConfiguration ipConfiguration = new IpConfiguration(); ipConfiguration.getIPv4Addresses().add(createPrimaryIpv4Address()); ipConfiguration.getIpV6Addresses().add(createPrimaryIpv6Address()); expected.setIpConfiguration(ipConfiguration); Map<String, String> properties = new HashMap<>(); properties.put("prop1", "true"); properties.put("prop2", "123456"); expected.setProperties(properties); expected.setDnsResolverConfiguration(new DnsResolverConfiguration()); expected.getDnsResolverConfiguration().setId(Guid.createGuidFromString("6de58dc3-171d-426d-99fc-295c25c091d3")); expected.getDnsResolverConfiguration().setNameServers(Arrays.asList( new NameServer("192.168.1.2"), new NameServer("2002:0db8:85a3:0000:0000:8a2e:0370:7334") )); return expected; }
/** * Ensures updating a network works as expected. */ @Test public void testUpdate() { Network before = dao.getByNameAndCluster(EXISTING_NETWORK_NAME1, FixturesTool.CLUSTER); before.setDescription("This is a completely changed description"); before.getDnsResolverConfiguration().getNameServers().add(new NameServer("1.1.1.1")); dao.update(before); Network after = dao.getByNameAndCluster(EXISTING_NETWORK_NAME1, FixturesTool.CLUSTER); assertNotNull(after); assertEquals(before, after); }
@BeforeEach public void setUp() { sampleDnsResolverConfiguration = new DnsResolverConfiguration(); sampleDnsResolverConfiguration.setNameServers(Arrays.asList( new NameServer("192.168.1.1"), new NameServer("2001:0db8:85a3:0000:0000:8a2e:0370:7334"))); sampleDnsResolverConfiguration2 = new DnsResolverConfiguration(); sampleDnsResolverConfiguration2.setNameServers(Arrays.asList( new NameServer("192.168.1.2"), new NameServer("2002:0db8:85a3:0000:0000:8a2e:0370:7334"))); sampleDnsResolverConfigurationWithReversedNameServers = reverseNameServersOrder(sampleDnsResolverConfiguration); ifaceQos = new HostNetworkQos(); networkQos = new HostNetworkQos(); iface = new VdsNetworkInterface(); //needed because network is vm network by default iface.setBridged(true); iface.setQos(ifaceQos); iface.setReportedSwitchType(SwitchType.LEGACY); iface.setIpv4DefaultRoute(false); iface.setMtu(getDefaultHostMtu()); network = new Network(); network.setDnsResolverConfiguration(sampleDnsResolverConfiguration); testedNetworkAttachment = new NetworkAttachment(); testedNetworkAttachment.setIpConfiguration(new IpConfiguration()); cluster = new Cluster(); cluster.setCompatibilityVersion(Version.v4_2); cluster.setRequiredSwitchTypeForCluster(SwitchType.LEGACY); }
@Test public void testUpdateDnsResolverConfiguration() { VdsDynamic before = dao.get(getExistingEntityId()); before.getReportedDnsResolverConfiguration().setNameServers( Collections.singletonList(new NameServer("1.1.1.1"))); dao.updateDnsResolverConfiguration(before.getId(), before.getReportedDnsResolverConfiguration()); VdsDynamic after = dao.get(getExistingEntityId()); assertEquals(before.getReportedDnsResolverConfiguration(), after.getReportedDnsResolverConfiguration()); } }
/** * Ensures that the update is working correctly */ @Test public void testUpdate() { networkAttachment.setNicId(FixturesTool.NETWORK_ATTACHMENT_NIC); dao.save(networkAttachment); IpConfiguration ipConfiguration = populateIpConfiguration(networkAttachment.getIpConfiguration(), Ipv4BootProtocol.STATIC_IP, Ipv6BootProtocol.NONE); networkAttachment.setIpConfiguration(ipConfiguration); Map<String, String> properties = new HashMap<>(); properties.put("key", "value"); networkAttachment.setProperties(properties); networkAttachment.setNicId(FixturesTool.NETWORK_ATTACHMENT_NIC2); networkAttachment.getDnsResolverConfiguration().getNameServers().add(new NameServer("2.2.2.2")); dao.update(networkAttachment); NetworkAttachment result = dao.get(networkAttachment.getId()); assertNotNull(result); assertNetworkAttachmentEquals(networkAttachment, result); }