Search in sources :

Example 21 with IpConfiguration

use of org.ovirt.engine.core.common.businessentities.network.IpConfiguration in project ovirt-engine by oVirt.

the class NetworkAttachmentDaoImplTest method testUpdate.

/**
 * 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);
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) HashMap(java.util.HashMap) NameServer(org.ovirt.engine.core.common.businessentities.network.NameServer) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 22 with IpConfiguration

use of org.ovirt.engine.core.common.businessentities.network.IpConfiguration in project ovirt-engine by oVirt.

the class NetworkAttachmentDaoImplTest method networkAttachmentFromFixtures.

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;
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) HashMap(java.util.HashMap) NameServer(org.ovirt.engine.core.common.businessentities.network.NameServer) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 23 with IpConfiguration

use of org.ovirt.engine.core.common.businessentities.network.IpConfiguration in project ovirt-engine by oVirt.

the class NetworkInSyncWithVdsNetworkInterfaceTest method setUp.

@Before
public void setUp() throws Exception {
    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);
    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);
}
Also used : HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) NameServer(org.ovirt.engine.core.common.businessentities.network.NameServer) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Before(org.junit.Before)

Example 24 with IpConfiguration

use of org.ovirt.engine.core.common.businessentities.network.IpConfiguration in project ovirt-engine by oVirt.

the class NetworkAttachmentIpConfigurationValidator method validateNetworkAttachmentIpConfiguration.

public ValidationResult validateNetworkAttachmentIpConfiguration(Collection<NetworkAttachment> attachmentsToConfigure) {
    for (NetworkAttachment networkAttachment : attachmentsToConfigure) {
        IpConfiguration ipConfiguration = networkAttachment.getIpConfiguration();
        if (ipConfiguration == null || !(ipConfiguration.hasIpv4PrimaryAddressSet() || ipConfiguration.hasIpv6PrimaryAddressSet())) {
            return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_MISSING_IP_CONFIGURATION, networkAttachment.getNetworkName(), networkAttachment.getNicName());
        }
        final ValidationResult ipv4ValidationResult = validateIpv4Configuration(networkAttachment);
        if (!ipv4ValidationResult.isValid()) {
            return ipv4ValidationResult;
        }
        final ValidationResult ipv6ValidationResult = validateIpv6Configuration(networkAttachment);
        if (!ipv6ValidationResult.isValid()) {
            return ipv6ValidationResult;
        }
    }
    return ValidationResult.VALID;
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Aggregations

IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)24 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)10 IPv4Address (org.ovirt.engine.core.common.businessentities.network.IPv4Address)6 Test (org.junit.Test)4 IpV6Address (org.ovirt.engine.core.common.businessentities.network.IpV6Address)4 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 NameServer (org.ovirt.engine.core.common.businessentities.network.NameServer)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)2 DnsResolverConfiguration (org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration)2 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)2 Guid (org.ovirt.engine.core.compat.Guid)2 NicToIpv4AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv4AddressFunction)2 NicToIpv6AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv6AddressFunction)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)1 Ipv4BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol)1 Ipv6BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol)1 Network (org.ovirt.engine.core.common.businessentities.network.Network)1