Search in sources :

Example 46 with VdsNetworkInterface

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

the class ReportedConfigurationsFiller method fillReportedConfigurations.

public void fillReportedConfigurations(List<VdsNetworkInterface> allInterfacesForHost, BusinessEntityMap<Network> networkMap, List<NetworkAttachment> networkAttachments, DnsResolverConfiguration reportedDnsResolverConfiguration, Guid clusterId) {
    Cluster cluster = clusterDao.get(clusterId);
    Map<String, VdsNetworkInterface> networkNameToNicMap = nicsByNetworkId(allInterfacesForHost);
    for (NetworkAttachment networkAttachment : networkAttachments) {
        fillReportedConfigurations(networkNameToNicMap, networkMap, networkAttachment, reportedDnsResolverConfiguration, cluster);
    }
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NetworkInSyncWithVdsNetworkInterface(org.ovirt.engine.core.utils.NetworkInSyncWithVdsNetworkInterface) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 47 with VdsNetworkInterface

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

the class VfSchedulerImpl method getNic.

private VdsNetworkInterface getNic(Guid nicId, Map<Guid, VdsNetworkInterface> fetchedNics) {
    VdsNetworkInterface nic = fetchedNics.get(nicId);
    if (nic == null) {
        nic = interfaceDao.get(nicId);
        fetchedNics.put(nicId, nic);
    }
    return nic;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 48 with VdsNetworkInterface

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

the class NetworkPolicyUnit method filter.

@Override
public List<VDS> filter(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters, PerHostMessages messages) {
    if (hosts == null || hosts.isEmpty()) {
        return Collections.emptyList();
    }
    List<VDS> toRemoveHostList = new ArrayList<>();
    List<VmNetworkInterface> vmNICs = vmNetworkInterfaceDao.getAllForVm(vm.getId());
    Guid clusterId = hosts.get(0).getClusterId();
    List<Network> clusterNetworks = networkDao.getAllForCluster(clusterId);
    Map<String, Network> networksByName = Entities.entitiesByName(clusterNetworks);
    Map<Guid, List<String>> hostNics = interfaceDao.getHostNetworksByCluster(clusterId);
    Network displayNetwork = NetworkUtils.getDisplayNetwork(clusterNetworks);
    Map<Guid, VdsNetworkInterface> hostDisplayNics = getDisplayNics(displayNetwork);
    for (VDS host : hosts) {
        ValidationResult result = validateRequiredNetworksAvailable(host, vm, vmNICs, displayNetwork, networksByName, hostNics.get(host.getId()), hostDisplayNics.get(host.getId()));
        if (result.isValid()) {
            result = validatePassthroughVnics(vm.getId(), host, vmNICs);
        }
        if (!result.isValid()) {
            toRemoveHostList.add(host);
            messages.addMessages(host.getId(), result.getVariableReplacements());
            messages.addMessages(host.getId(), result.getMessagesAsStrings());
        }
    }
    hosts.removeAll(toRemoveHostList);
    return hosts;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArrayList(java.util.ArrayList) List(java.util.List)

Example 49 with VdsNetworkInterface

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

the class BackendHostNicsResource method map.

@Override
protected VdsNetworkInterface map(HostNic entity, VdsNetworkInterface template) {
    VdsNetworkInterface iface = super.map(entity, template);
    if (entity.isSetNetwork()) {
        if (entity.getNetwork().isSetId() || entity.getNetwork().isSetName()) {
            org.ovirt.engine.core.common.businessentities.network.Network net = lookupNetwork(entity.getNetwork());
            iface.setNetworkName(net.getName());
        } else {
            iface.setNetworkName(null);
        }
    }
    return iface;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 50 with VdsNetworkInterface

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

the class BackendHostNicsResource method list.

@Override
public HostNics list() {
    HostNics ret = new HostNics();
    List<VdsNetworkInterface> ifaces = getCollection();
    Map<String, Guid> networkNameToNetworkIdMap = mapNetworkNamesToNetworkIds();
    Map<Guid, NetworkAttachment> attachmentsByNetworkId = getAttachmentsByNetworkId();
    for (VdsNetworkInterface iface : ifaces) {
        HostNic hostNic = populate(map(iface, ifaces), iface);
        setCustomProperties(attachmentsByNetworkId, networkNameToNetworkIdMap, hostNic);
        String networkName = iface.getNetworkName();
        if (networkNameToNetworkIdMap.containsKey(networkName)) {
            Guid networkId = networkNameToNetworkIdMap.get(networkName);
            hostNic.getNetwork().setId(networkId.toString());
            hostNic.getNetwork().setName(null);
        }
        ret.getHostNics().add(addLinks(hostNic));
    }
    return addActions(ret);
}
Also used : HostNic(org.ovirt.engine.api.model.HostNic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) HostNics(org.ovirt.engine.api.model.HostNics) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Aggregations

VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)233 Test (org.junit.Test)68 Network (org.ovirt.engine.core.common.businessentities.network.Network)47 ArrayList (java.util.ArrayList)46 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)35 Guid (org.ovirt.engine.core.compat.Guid)30 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)24 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)23 List (java.util.List)19 HashMap (java.util.HashMap)18 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)18 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)17 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)16 VDS (org.ovirt.engine.core.common.businessentities.VDS)15 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)14 Nic (org.ovirt.engine.core.common.businessentities.network.Nic)13 Map (java.util.Map)12 HostDevice (org.ovirt.engine.core.common.businessentities.HostDevice)9 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)8 Vlan (org.ovirt.engine.core.common.businessentities.network.Vlan)8