Search in sources :

Example 71 with NetworkAttachment

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

the class NetworkMtuValidatorTest method createNetworkAttachment.

private NetworkAttachment createNetworkAttachment(Network networkA, String nicAName) {
    NetworkAttachment networkAttachmentA = new NetworkAttachment();
    networkAttachmentA.setId(Guid.newGuid());
    networkAttachmentA.setNicName(nicAName);
    networkAttachmentA.setNetworkId(networkA.getId());
    return networkAttachmentA;
}
Also used : NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 72 with NetworkAttachment

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

the class HostSetupNetworksValidatorTest method validateBondModeForLabeledVmNetwork.

private void validateBondModeForLabeledVmNetwork(BondMode bondMode) {
    String bondName = "bondName";
    String networkName = "vmNetwork";
    String label = "label";
    Bond bond = createBond(bondName, networkName, null);
    bond.setLabels(new HashSet<>(Collections.singletonList(label)));
    bond.setBondOptions(bondMode.getConfigurationValue());
    Network vmNetwork = createNetworkWithName(networkName);
    vmNetwork.setVmNetwork(true);
    vmNetwork.setLabel(label);
    NetworkAttachment vmNetworkNetworkAttachment = createNetworkAttachment(vmNetwork, bond);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addBonds(CreateOrUpdateBond.fromBond(bond))).addNetworks(vmNetwork).addExistingInterfaces(bond).build();
    List<NetworkAttachment> attachmentsToConfigure = Collections.singletonList(vmNetworkNetworkAttachment);
    ValidationResult result = validator.validateBondModeVsNetworksAttachedToIt(attachmentsToConfigure);
    if (bondMode.isBondModeValidForVmNetwork()) {
        collector.checkThat(result, isValid());
    } else {
        collector.checkThat(result, failsWith(EngineMessage.INVALID_BOND_MODE_FOR_BOND_WITH_LABELED_VM_NETWORK, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_BOND_NAME, bondName), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_LABEL, label)));
    }
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 73 with NetworkAttachment

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

the class NetworkAttachmentDaoImplTest method testGetWithNonExistingId.

/**
 * Ensures null is returned.
 */
@Test
public void testGetWithNonExistingId() {
    NetworkAttachment result = dao.get(Guid.newGuid());
    assertNull(result);
}
Also used : NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 74 with NetworkAttachment

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

the class NetworkAttachmentDaoImplTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    dao = dbFacade.getNetworkAttachmentDao();
    dnsResolverConfigurationDao = dbFacade.getDnsResolverConfigurationDao();
    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"))));
}
Also used : 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 75 with NetworkAttachment

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

the class NetworkAttachmentDaoImplTest method testGetNetworkAttachmentByNicIdAndNetworkId.

@Test
public void testGetNetworkAttachmentByNicIdAndNetworkId() {
    final Guid nicId = FixturesTool.VDS_NETWORK_INTERFACE2;
    final Guid networkId = FixturesTool.NETWORK_ENGINE_2;
    final NetworkAttachment networkAttachmentByNicIdAndNetworkId = dao.getNetworkAttachmentByNicIdAndNetworkId(nicId, networkId);
    assertNotNull(networkAttachmentByNicIdAndNetworkId);
    assertNetworkAttachmentEquals(networkAttachmentFromFixtures(), networkAttachmentByNicIdAndNetworkId);
}
Also used : 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