Search in sources :

Example 26 with NetworkCluster

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

the class NetworkClusterDaoTest method testGetAllForNetwork.

/**
 * Ensures that the right set is returned for the specified network.
 */
@Test
public void testGetAllForNetwork() {
    List<NetworkCluster> result = dao.getAllForNetwork(network.getId());
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (NetworkCluster cluster : result) {
        assertEquals(network.getId(), cluster.getNetworkId());
    }
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) Test(org.junit.Test)

Example 27 with NetworkCluster

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

the class AbstractBackendNetworksResourceTest method getEntity.

@Override
protected org.ovirt.engine.core.common.businessentities.network.Network getEntity(int index) {
    org.ovirt.engine.core.common.businessentities.network.Network network = new org.ovirt.engine.core.common.businessentities.network.Network();
    NetworkCluster networkCluster = new NetworkCluster();
    networkCluster.setDisplay(false);
    networkCluster.setMigration(false);
    networkCluster.setRequired(false);
    networkCluster.setDefaultRoute(false);
    network.setCluster(networkCluster);
    network.setId(GUIDS[index]);
    network.setName(NAMES[index]);
    network.setDescription(DESCRIPTIONS[index]);
    network.setDataCenterId(GUIDS[1]);
    return network;
}
Also used : Network(org.ovirt.engine.api.model.Network) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 28 with NetworkCluster

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

the class NetworkMapper method map.

@Mapping(from = Network.class, to = org.ovirt.engine.core.common.businessentities.network.Network.class)
public static org.ovirt.engine.core.common.businessentities.network.Network map(Network model, org.ovirt.engine.core.common.businessentities.network.Network template) {
    org.ovirt.engine.core.common.businessentities.network.Network entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.network.Network();
    entity.setCluster(template != null && template.getCluster() != null ? template.getCluster() : new NetworkCluster());
    if (model.isSetId()) {
        entity.setId(GuidUtils.asGuid(model.getId()));
    }
    if (model.isSetName()) {
        entity.setName(model.getName());
    }
    if (model.isSetDescription()) {
        entity.setDescription(model.getDescription());
    }
    if (model.isSetComment()) {
        entity.setComment(model.getComment());
    }
    if (model.isSetDataCenter() && model.getDataCenter().isSetId()) {
        entity.setDataCenterId(GuidUtils.asGuid(model.getDataCenter().getId()));
    }
    if (model.isSetIp()) {
        if (model.getIp().isSetAddress()) {
            entity.setAddr(model.getIp().getAddress());
        }
        if (model.getIp().isSetNetmask()) {
            entity.setSubnet(model.getIp().getNetmask());
        }
        if (model.getIp().isSetGateway()) {
            entity.setGateway(model.getIp().getGateway());
        }
    }
    if (model.isSetVlan()) {
        entity.setVlanId(model.getVlan().getId());
    }
    if (model.isSetStp()) {
        entity.setStp(model.isStp());
    }
    if (model.isSetDisplay()) {
        // for backward compatibility use display tag or usage tag
        entity.getCluster().setDisplay(model.isDisplay());
    }
    if (model.isSetUsages()) {
        List<NetworkUsage> networkUsages = new ArrayList<>();
        for (NetworkUsage usage : model.getUsages().getUsages()) {
            networkUsages.add(usage);
        }
        entity.getCluster().setDisplay(networkUsages.contains(NetworkUsage.DISPLAY));
        entity.getCluster().setMigration(networkUsages.contains(NetworkUsage.MIGRATION));
        entity.getCluster().setManagement(networkUsages.contains(NetworkUsage.MANAGEMENT));
        entity.getCluster().setGluster(networkUsages.contains(NetworkUsage.GLUSTER));
        entity.getCluster().setDefaultRoute(networkUsages.contains(NetworkUsage.DEFAULT_ROUTE));
        entity.setVmNetwork(networkUsages.contains(NetworkUsage.VM));
    }
    if (model.isSetMtu()) {
        entity.setMtu(model.getMtu());
    }
    if (model.isSetRequired()) {
        entity.getCluster().setRequired(model.isRequired());
    }
    if (model.isSetQos()) {
        entity.setQosId(Guid.createGuidFromString(model.getQos().getId()));
    }
    if (model.isSetDnsResolverConfiguration()) {
        entity.setDnsResolverConfiguration(DnsResolverConfigurationMapper.map(entity.getDnsResolverConfiguration(), model.getDnsResolverConfiguration()));
    }
    if (model.isSetExternalProvider() && model.getExternalProvider().isSetId()) {
        ProviderNetwork providerNetwork = new ProviderNetwork();
        providerNetwork.setProviderId(GuidUtils.asGuid(model.getExternalProvider().getId()));
        if (model.isSetExternalProviderPhysicalNetwork() && model.getExternalProviderPhysicalNetwork().isSetId()) {
            providerNetwork.setPhysicalNetworkId(GuidUtils.asGuid(model.getExternalProviderPhysicalNetwork().getId()));
        }
        entity.setProvidedBy(providerNetwork);
    }
    return entity;
}
Also used : NetworkUsage(org.ovirt.engine.api.model.NetworkUsage) ArrayList(java.util.ArrayList) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) ProviderNetwork(org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)

Example 29 with NetworkCluster

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

the class NetworkClusterHelper method removeNetworkAndReassignRoles.

public void removeNetworkAndReassignRoles(NetworkCluster networkCluster) {
    NetworkCluster oldNetworkCluster = networkClusterDao.get(networkCluster.getId());
    networkClusterDao.remove(networkCluster.getClusterId(), networkCluster.getNetworkId());
    networkAttachmentDao.removeByNetworkId(networkCluster.getNetworkId());
    boolean updateManagementNetwork = false;
    final NetworkCluster managementNetworkCluster = getManagementNetworkCluster(networkCluster);
    if (oldNetworkCluster.isDisplay()) {
        managementNetworkCluster.setDisplay(true);
        updateManagementNetwork = true;
    }
    if (oldNetworkCluster.isMigration()) {
        managementNetworkCluster.setMigration(true);
        updateManagementNetwork = true;
    }
    if (oldNetworkCluster.isDefaultRoute()) {
        managementNetworkCluster.setDefaultRoute(true);
        updateManagementNetwork = true;
    }
    if (updateManagementNetwork) {
        networkClusterDao.update(managementNetworkCluster);
    }
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 30 with NetworkCluster

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

the class NetworkClusterValidatorBase method findMissingIpNic.

private VdsNetworkInterface findMissingIpNic(final String networkName) {
    IsRoleNetworkIpConfigurationValid isRoleNetworkIpConfigurationValid = new IsRoleNetworkIpConfigurationValid(networkCluster);
    final List<VdsNetworkInterface> interfacesByClusterId = interfaceDao.getAllInterfacesByClusterId(networkCluster.getClusterId());
    final VdsNetworkInterface missingIpNic = interfacesByClusterId.stream().filter(nic -> networkName.equals(nic.getNetworkName())).filter(isRoleNetworkIpConfigurationValid::isIpAddressMissingForRole).findFirst().orElse(null);
    return missingIpNic;
}
Also used : EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) NetworkDao(org.ovirt.engine.core.dao.network.NetworkDao) IsRoleNetworkIpConfigurationValid(org.ovirt.engine.core.bll.validator.IsRoleNetworkIpConfigurationValid) NetworkUtils(org.ovirt.engine.core.utils.NetworkUtils) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Objects(java.util.Objects) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VdsDao(org.ovirt.engine.core.dao.VdsDao) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) Network(org.ovirt.engine.core.common.businessentities.network.Network) InterfaceDao(org.ovirt.engine.core.dao.network.InterfaceDao) IsRoleNetworkIpConfigurationValid(org.ovirt.engine.core.bll.validator.IsRoleNetworkIpConfigurationValid) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Aggregations

NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)62 Test (org.junit.Test)19 Network (org.ovirt.engine.core.common.businessentities.network.Network)17 ArrayList (java.util.ArrayList)15 NetworkClusterId (org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)7 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 ManageNetworkClustersParameters (org.ovirt.engine.core.common.action.ManageNetworkClustersParameters)5 List (java.util.List)4 Map (java.util.Map)4 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)4 Guid (org.ovirt.engine.core.compat.Guid)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2