Search in sources :

Example 51 with VdsNetworkInterface

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

the class BackendHostNicNetworkAttachmentsResource method verifyNicExistenceToHandle404StatusCode.

private void verifyNicExistenceToHandle404StatusCode() {
    List<VdsNetworkInterface> hostInterfaces = getBackendCollection(VdsNetworkInterface.class, QueryType.GetVdsInterfacesByVdsId, new IdQueryParameters(getHostId()));
    boolean found = false;
    for (VdsNetworkInterface hostInterface : hostInterfaces) {
        if (hostInterface.getId().equals(nicId)) {
            found = true;
            break;
        }
    }
    if (!found) {
        notFound(VdsNetworkInterface.class);
    }
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 52 with VdsNetworkInterface

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

the class BackendHostNicResource method getOldNetwork.

private org.ovirt.engine.core.common.businessentities.network.Network getOldNetwork(VdsNetworkInterface originalInter) {
    String oldNetworkName = originalInter.getNetworkName();
    if (!StringUtils.isEmpty(oldNetworkName)) {
        return lookupAtachedNetwork(originalInter.getNetworkName());
    } else {
        InterfaceAndIdQueryParameters params = new InterfaceAndIdQueryParameters(originalInter.getVdsId(), originalInter);
        List<VdsNetworkInterface> vlans = getBackendCollection(VdsNetworkInterface.class, QueryType.GetAllChildVlanInterfaces, params);
        if (vlans != null && !vlans.isEmpty()) {
            return lookupAtachedNetwork(vlans.get(0).getNetworkName());
        } else {
            return null;
        }
    }
}
Also used : InterfaceAndIdQueryParameters(org.ovirt.engine.core.common.queries.InterfaceAndIdQueryParameters) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 53 with VdsNetworkInterface

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

the class HostNicMapper method map.

@Mapping(from = HostNic.class, to = VdsNetworkInterface.class)
public static VdsNetworkInterface map(HostNic model, VdsNetworkInterface template) {
    VdsNetworkInterface entity;
    if (template != null) {
        entity = template;
    } else if (model.isSetBonding()) {
        entity = new Bond();
    } else if (model.isSetVlan()) {
        entity = new Vlan();
    } else {
        entity = new Nic();
    }
    if (model.isSetId()) {
        entity.setId(GuidUtils.asGuid(model.getId()));
    }
    if (model.isSetNetwork() && model.getNetwork().isSetName()) {
        entity.setNetworkName(model.getNetwork().getName());
    }
    if (model.isSetName()) {
        entity.setName(model.getName());
    }
    if (model.isSetBaseInterface()) {
        entity.setBaseInterface(model.getBaseInterface());
    }
    mapIpv4FromModel(model, entity);
    mapIpv6FromModel(model, entity);
    if (model.isSetMac() && model.getMac().isSetAddress()) {
        entity.setMacAddress(model.getMac().getAddress());
    }
    if (model.isSetBonding()) {
        entity.setBonded(true);
        if (model.getBonding().isSetOptions()) {
            List<Option> bondingOptions = model.getBonding().getOptions().getOptions();
            String optionsString = bondingOptions.stream().filter(Option::isSetName).map(x -> x.getName() + "=" + x.getValue()).collect(joining(" "));
            entity.setBondOptions(optionsString);
        }
    }
    if (model.isSetQos()) {
        entity.setQos((HostNetworkQos) QosMapper.map(model.getQos(), null));
    }
    return entity;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) InterfaceStatus(org.ovirt.engine.core.common.businessentities.network.InterfaceStatus) HostNic(org.ovirt.engine.api.model.HostNic) GuidUtils(org.ovirt.engine.api.restapi.utils.GuidUtils) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) Option(org.ovirt.engine.api.model.Option) Network(org.ovirt.engine.api.model.Network) Mac(org.ovirt.engine.api.model.Mac) BootProtocol(org.ovirt.engine.api.model.BootProtocol) Bonding(org.ovirt.engine.api.model.Bonding) IpVersion(org.ovirt.engine.api.model.IpVersion) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol) Collectors.joining(java.util.stream.Collectors.joining) NicStatus(org.ovirt.engine.api.model.NicStatus) UpdateHostNicVfsConfigParameters(org.ovirt.engine.core.common.action.UpdateHostNicVfsConfigParameters) List(java.util.List) HostNicVirtualFunctionsConfiguration(org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Ip(org.ovirt.engine.api.model.Ip) Options(org.ovirt.engine.api.model.Options) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) HostNic(org.ovirt.engine.api.model.HostNic) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Option(org.ovirt.engine.api.model.Option) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Example 54 with VdsNetworkInterface

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

the class AutoRecoveryManager method recoverImpl.

public void recoverImpl() {
    check(vdsDao, ActionType.ActivateVds, arg -> {
        final VdsActionParameters params = new VdsActionParameters(arg.getId());
        params.setRunSilent(true);
        return params;
    }, list -> {
        List<VDS> filtered = new ArrayList<>(list.size());
        List<VdsNetworkInterface> nics;
        for (VDS vds : list) {
            if (vds.getNonOperationalReason() == NonOperationalReason.NETWORK_INTERFACE_IS_DOWN) {
                backend.getResourceManager().runVdsCommand(VDSCommandType.GetStats, new VdsIdAndVdsVDSCommandParametersBase(vds));
                nics = vds.getInterfaces();
            } else {
                nics = interfaceDao.getAllInterfacesForVds(vds.getId());
            }
            Map<String, Set<String>> problematicNics = NetworkMonitoringHelper.determineProblematicNics(nics, networkDao.getAllForCluster(vds.getClusterId()));
            if (problematicNics.isEmpty()) {
                filtered.add(vds);
            }
        }
        return filtered;
    }, "hosts");
    check(storageDomainDao, ActionType.ConnectDomainToStorage, arg -> {
        final StorageDomainPoolParametersBase params = new StorageDomainPoolParametersBase(arg.getId(), arg.getStoragePoolId());
        params.setRunSilent(true);
        return params;
    }, list -> list, "storage domains");
}
Also used : Set(java.util.Set) VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsIdAndVdsVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdAndVdsVDSCommandParametersBase) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 55 with VdsNetworkInterface

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

the class GlusterSyncJob method updateStatusAndpeerProbeOtherIface.

private void updateStatusAndpeerProbeOtherIface(Network glusterNetwork, VDS host, GlusterServerInfo fetchedServerInfo) {
    GlusterServer glusterServer = serverDao.get(host.getId());
    if (glusterServer == null) {
        return;
    }
    if (glusterServer.getPeerStatus() == PeerStatus.DISCONNECTED && fetchedServerInfo.getStatus() == PeerStatus.CONNECTED) {
        // change the status to indicate that host is now part of cluster
        serverDao.updatePeerStatus(host.getId(), PeerStatus.CONNECTED);
    }
    if (glusterNetwork == null || host.getStatus() != VDSStatus.Up) {
        return;
    }
    List<VdsNetworkInterface> interfaces = interfaceDao.getAllInterfacesForVds(host.getId());
    for (VdsNetworkInterface iface : interfaces) {
        if (glusterNetwork.getName().equals(iface.getNetworkName()) && StringUtils.isNotBlank(iface.getIpv4Address()) && !glusterServer.getKnownAddresses().contains(iface.getIpv4Address())) {
            // get another server in the cluster
            VDS upServer = getAlternateUpServerInCluster(host.getClusterId(), host.getId());
            if (upServer != null) {
                boolean peerProbed = glusterPeerProbeAdditionalInterface(upServer, iface.getIpv4Address());
                if (peerProbed) {
                    serverDao.addKnownAddress(host.getId(), iface.getIpv4Address());
                }
            } else {
                log.warn("probe could not be done for server '{}' as no alternate UP server found", host.getHostName());
            }
        }
    }
}
Also used : GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

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