use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method createNetworkAttachmentWithIpv4Configuration.
private NetworkAttachment createNetworkAttachmentWithIpv4Configuration(Ipv4BootProtocol bootProtocol) {
IpConfiguration ipConfiguration = new IpConfiguration();
IPv4Address primaryAddress = new IPv4Address();
primaryAddress.setAddress(null);
primaryAddress.setNetmask(null);
primaryAddress.setBootProtocol(bootProtocol);
ipConfiguration.getIPv4Addresses().add(primaryAddress);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setIpConfiguration(ipConfiguration);
return attachment;
}
use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class NetworkInSyncWithVdsNetworkInterfaceTest method testReportConfigurationsOnHostWhenDefaultRouteDiffers.
@Test
public void testReportConfigurationsOnHostWhenDefaultRouteDiffers() {
// cannot use initIpv4ConfigurationBootProtocol because of 'randomized tests' technique.
iface.setIpv4BootProtocol(Ipv4BootProtocol.DHCP);
IPv4Address address = new IPv4Address();
address.setBootProtocol(Ipv4BootProtocol.DHCP);
testedNetworkAttachment.getIpConfiguration().setIPv4Addresses(Collections.singletonList(address));
// network has default route role
NetworkInSyncWithVdsNetworkInterface testedInstance = createTestedInstanceWithSameNonQosValues(true);
ReportedConfigurations reportedConfigurations = testedInstance.reportConfigurationsOnHost();
assertThat(reportedConfigurations.isNetworkInSync(), is(false));
List<ReportedConfiguration> reportedConfigurationList = reportedConfigurations.getReportedConfigurationList();
List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations(combineReportedConfigurations(createBasicReportedConfigurations(), reportQos(true)), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), /*ipv4Address*/
address.getBootProtocol().name(), true), new ReportedConfiguration(ReportedConfigurationType.DNS_CONFIGURATION, addressesAsString(sampleDnsResolverConfiguration.getNameServers()), "192.168.1.1,2001:0db8:85a3:0000:0000:8a2e:0370:7334", true), new ReportedConfiguration(ReportedConfigurationType.DEFAULT_ROUTE, false, true, false));
assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true));
assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size()));
}
use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class HostNetworkAttachmentsPersisterTest method createIpConfiguration.
private IpConfiguration createIpConfiguration() {
IpConfiguration result = new IpConfiguration();
IPv4Address ipv4Address = createIpv4Address();
IpV6Address ipv6Address = createIpv6Address();
result.setIPv4Addresses(Collections.singletonList(ipv4Address));
result.setIpV6Addresses(Collections.singletonList(ipv6Address));
return result;
}
use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class NetworkAttachmentIpConfigurationValidator method validateIpv4Configuration.
private ValidationResult validateIpv4Configuration(NetworkAttachment networkAttachment) {
IpConfiguration ipConfiguration = networkAttachment.getIpConfiguration();
if (!ipConfiguration.hasIpv4PrimaryAddressSet()) {
return ValidationResult.VALID;
}
IPv4Address iPv4Address = ipConfiguration.getIpv4PrimaryAddress();
String networkName = networkAttachment.getNetworkName();
String nicName = networkAttachment.getNicName();
if (iPv4Address.getBootProtocol() == null) {
return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_MISSING_BOOT_PROTOCOL, networkName, nicName);
}
Ipv4BootProtocol bootProtocol = iPv4Address.getBootProtocol();
if (bootProtocol == Ipv4BootProtocol.STATIC_IP) {
if (!validStaticIpv4AddressDetails(iPv4Address)) {
return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_STATIC_BOOT_PROTOCOL_MISSING_IP_ADDRESS_DETAILS, networkName, nicName);
}
} else {
if (!isEmptyIpv4AddressDetails(iPv4Address)) {
return new ValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_INCOMPATIBLE_BOOT_PROTOCOL_AND_IP_ADDRESS_DETAILS, ReplacementUtils.createSetVariableString(VAR_NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(VAR_INTERFACE_NAME, nicName), ReplacementUtils.createSetVariableString(VAR_BOOT_PROTOCOL, bootProtocol.getDisplayName()));
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.network.IPv4Address in project ovirt-engine by oVirt.
the class NicToIpv4AddressFunction method apply.
@Override
public IPv4Address apply(VdsNetworkInterface nic) {
IPv4Address ipv4Address = new IPv4Address();
if (nic.getIpv4BootProtocol() == Ipv4BootProtocol.STATIC_IP) {
ipv4Address.setAddress(nic.getIpv4Address());
ipv4Address.setNetmask(nic.getIpv4Subnet());
ipv4Address.setGateway(nic.getIpv4Gateway());
}
ipv4Address.setBootProtocol(nic.getIpv4BootProtocol());
return ipv4Address;
}
Aggregations