Search in sources :

Example 6 with NetworkAttachment

use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment 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;
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 7 with NetworkAttachment

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

the class NetworkAttachmentValidatorTest method testNetworkExistWhenNeitherIdNorNameIsSpecified.

@Test
public void testNetworkExistWhenNeitherIdNorNameIsSpecified() {
    NetworkAttachment networkAttachment = new NetworkAttachment();
    NetworkAttachmentValidator validator = createNetworkAttachmentValidator(networkAttachment);
    assertThat(validator.networkExists(), failsWith(EngineMessage.NETWORK_ATTACHMENT_NETWORK_ID_OR_NAME_IS_NOT_SET));
}
Also used : NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 8 with NetworkAttachment

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

the class NetworkAttachmentValidatorTest method testExistingAttachmentExistingHasSameId.

@Test
public void testExistingAttachmentExistingHasSameId() {
    Guid networkId = Guid.newGuid();
    Guid attachmentId = Guid.newGuid();
    NetworkAttachment oldAttachment = new NetworkAttachment();
    oldAttachment.setNetworkId(networkId);
    oldAttachment.setNetworkName(NETWORK_NAME);
    oldAttachment.setId(attachmentId);
    Map<Guid, NetworkAttachment> existingAttachmentsByNetworkId = new HashMap<>();
    existingAttachmentsByNetworkId.put(networkId, oldAttachment);
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setNetworkId(networkId);
    attachment.setId(attachmentId);
    assertThat(createNetworkAttachmentValidator(attachment).existingAttachmentIsReused(existingAttachmentsByNetworkId), isValid());
}
Also used : HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 9 with NetworkAttachment

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

the class NetworkAttachmentValidatorTest method testNetworkAttachedToClusterWhenNotAttached.

@Test
public void testNetworkAttachedToClusterWhenNotAttached() {
    Network network = new Network();
    network.setId(Guid.newGuid());
    network.setName(NETWORK_NAME);
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setNetworkId(network.getId());
    attachment.setNetworkName(network.getName());
    EngineMessage engineMessage = EngineMessage.NETWORK_OF_GIVEN_NAME_NOT_EXISTS_IN_CLUSTER;
    assertThat(createNetworkAttachmentValidator(attachment).networkAttachedToCluster(), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, network.getName())));
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 10 with NetworkAttachment

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

the class NetworkAttachmentValidatorTest method testExistingAttachmentIsReusedNotReused.

@Test
public void testExistingAttachmentIsReusedNotReused() {
    Guid networkId = Guid.newGuid();
    NetworkAttachment oldAttachment = new NetworkAttachment();
    oldAttachment.setNetworkId(networkId);
    oldAttachment.setNetworkName(NETWORK_NAME);
    oldAttachment.setId(Guid.newGuid());
    Map<Guid, NetworkAttachment> existingAttachmentsByNetworkId = new HashMap<>();
    existingAttachmentsByNetworkId.put(networkId, oldAttachment);
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setNetworkId(networkId);
    assertThat(createNetworkAttachmentValidator(attachment).existingAttachmentIsReused(existingAttachmentsByNetworkId), failsWith(EngineMessage.ATTACHMENT_IS_NOT_REUSED, ReplacementUtils.createSetVariableString(NetworkAttachmentValidator.VAR_NETWORK_ATTACHMENT_ID, oldAttachment.getId()), ReplacementUtils.createSetVariableString(NetworkAttachmentValidator.VAR_NETWORK_NAME, oldAttachment.getNetworkName())));
}
Also used : HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Aggregations

NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)167 Test (org.junit.Test)79 Network (org.ovirt.engine.core.common.businessentities.network.Network)62 Guid (org.ovirt.engine.core.compat.Guid)37 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)36 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)35 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)20 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)18 HashMap (java.util.HashMap)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)14 ArrayList (java.util.ArrayList)10 IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)10 ProviderNetwork (org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)9 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)8 PersistentHostSetupNetworksParameters (org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters)7 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)7 AnonymousHostNetworkQos (org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos)6 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)5 BusinessEntityMap (org.ovirt.engine.core.common.businessentities.BusinessEntityMap)5