Search in sources :

Example 6 with NetworkClusterId

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

the class DefaultRouteUtilImplTest method testIsDefaultRouteWhenNetworkClusterExist.

private void testIsDefaultRouteWhenNetworkClusterExist(boolean isDefaultRoute) {
    NetworkCluster networkCluster = new NetworkCluster();
    networkCluster.setDefaultRoute(isDefaultRoute);
    when(networkClusterDao.get(new NetworkClusterId(clusterId, networkId))).thenReturn(networkCluster);
    assertThat(underTest.isDefaultRouteNetwork(networkId, clusterId), is(isDefaultRoute));
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)

Example 7 with NetworkClusterId

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

the class DefaultRouteUtilImplTest method testIsDefaultRouteWhenNetworkClusterDoesNotExist.

@Test
public void testIsDefaultRouteWhenNetworkClusterDoesNotExist() throws Exception {
    when(networkClusterDao.get(new NetworkClusterId(clusterId, networkId))).thenReturn(null);
    assertThat(underTest.isDefaultRouteNetwork(networkId, clusterId), is(false));
}
Also used : NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId) Test(org.junit.Test)

Example 8 with NetworkClusterId

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

the class NetworkAttachmentValidatorTest method testNetworkAttachedToClusterWhenAttached.

@Test
public void testNetworkAttachedToClusterWhenAttached() {
    Network network = new Network();
    network.setId(Guid.newGuid());
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setNetworkId(network.getId());
    NetworkClusterId networkClusterId = new NetworkClusterId(host.getClusterId(), attachment.getNetworkId());
    when(networkClusterDaoMock.get(eq(networkClusterId))).thenReturn(new NetworkCluster());
    assertThat(createNetworkAttachmentValidator(attachment).networkAttachedToCluster(), isValid());
}
Also used : ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 9 with NetworkClusterId

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

the class NetworkAttachmentValidatorTest method doTestBootProtocolSetForRoleNetworkWhenNullValuedIpConfiguration.

private void doTestBootProtocolSetForRoleNetworkWhenNullValuedIpConfiguration(boolean displayNetwork, boolean migrationNetwork, boolean glusterNetwork, Matcher<ValidationResult> matcher, Network network, NetworkAttachment attachment) {
    NetworkCluster networkCluster = new NetworkCluster();
    networkCluster.setDisplay(displayNetwork);
    networkCluster.setMigration(migrationNetwork);
    networkCluster.setGluster(glusterNetwork);
    NetworkClusterId networkClusterId = new NetworkClusterId(host.getClusterId(), attachment.getNetworkId());
    when(networkClusterDaoMock.get(eq(networkClusterId))).thenReturn(networkCluster);
    when(networkDaoMock.get(eq(network.getId()))).thenReturn(network);
    assertThat(createNetworkAttachmentValidator(attachment).bootProtocolSetForRoleNetwork(), matcher);
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)

Example 10 with NetworkClusterId

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

the class ManageNetworkClustersCommand method validateInputForDuplication.

private ValidationResult validateInputForDuplication() {
    final Set<NetworkClusterId> networkClusterIds = new HashSet<>();
    final Iterable<NetworkCluster> inputNetworkClusters = Stream.of(getParameters().getAttachments(), getParameters().getDetachments(), getParameters().getUpdates()).flatMap(Collection::stream).collect(Collectors.toList());
    for (NetworkCluster networkCluster : inputNetworkClusters) {
        if (networkClusterIds.contains(networkCluster.getId())) {
            final String networkClusterReplacement = String.format("${NetworkCluster} %s", networkCluster.getId());
            return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DUPLICATE_NETWORK_CLUSTER_INPUT, networkClusterReplacement);
        } else {
            networkClusterIds.add(networkCluster.getId());
        }
    }
    return ValidationResult.VALID;
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) HashSet(java.util.HashSet)

Aggregations

NetworkClusterId (org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)13 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)7 Network (org.ovirt.engine.core.common.businessentities.network.Network)5 Test (org.junit.Test)2 Guid (org.ovirt.engine.core.compat.Guid)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Before (org.junit.Before)1 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 LexoNumericComparator (org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator)1 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)1 ProviderNetwork (org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)1 AsyncCallback (org.ovirt.engine.ui.frontend.AsyncCallback)1