Search in sources :

Example 1 with HostNetwork

use of org.ovirt.engine.core.common.vdscommands.HostNetwork in project ovirt-engine by oVirt.

the class HostSetupNetworksCommand method calculateNetworksToConfigure.

private List<HostNetwork> calculateNetworksToConfigure() {
    List<HostNetwork> networksToConfigure = new ArrayList<>(getParameters().getNetworkAttachments().size());
    BusinessEntityMap<VdsNetworkInterface> nics = getExistingNicsBusinessEntityMap();
    for (NetworkAttachment attachment : getAttachmentsWithMissingUpdatedDefaultRoute()) {
        Network network = existingNetworkRelatedToAttachment(attachment);
        NetworkCluster networkCluster = network.getCluster();
        HostNetwork networkToConfigure = new HostNetwork(network, attachment);
        networkToConfigure.setBonding(isBonding(attachment, nics));
        boolean isDefaultRoute = defaultRouteSupported() && networkCluster.isDefaultRoute();
        if (isDefaultRoute) {
            DnsResolverConfiguration dnsResolverConfiguration = getDnsConfigurationFromNetworkOrItsAttachment(attachment, network);
            if (dnsResolverConfiguration != null) {
                networkToConfigure.setNameServers(dnsResolverConfiguration.getNameServers());
            }
        }
        // TODO: YZ - should default route be set separately for IPv4 and IPv6
        networkToConfigure.setDefaultRoute(isDefaultRoute);
        if (NetworkUtils.qosConfiguredOnInterface(attachment, network)) {
            networkToConfigure.setQosConfiguredOnInterface(true);
            HostNetworkQos hostNetworkQos = effectiveHostNetworkQos.getQos(attachment, network);
            networkToConfigure.setQos(hostNetworkQos);
        }
        networksToConfigure.add(networkToConfigure);
    }
    return networksToConfigure;
}
Also used : EffectiveHostNetworkQos(org.ovirt.engine.core.vdsbroker.EffectiveHostNetworkQos) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) HostNetwork(org.ovirt.engine.core.common.vdscommands.HostNetwork) FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) HostNetwork(org.ovirt.engine.core.common.vdscommands.HostNetwork) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 2 with HostNetwork

use of org.ovirt.engine.core.common.vdscommands.HostNetwork in project ovirt-engine by oVirt.

the class HostSetupNetworksCommand method createSetupNetworksParameters.

private HostSetupNetworksVdsCommandParameters createSetupNetworksParameters(int timeout) {
    SwitchType clusterSwitchType = getCluster().getRequiredSwitchTypeForCluster();
    List<HostNetwork> networksToConfigure = calculateNetworksToConfigure();
    final HostSetupNetworksVdsCommandParameters hostCmdParams = new HostSetupNetworksVdsCommandParameters(getVds(), networksToConfigure, getAllNetworksToRemove(), getParameters().getCreateOrUpdateBonds(), getRemovedBondNames(), clusterSwitchType);
    hostCmdParams.setRollbackOnFailure(getParameters().rollbackOnFailure());
    hostCmdParams.setConnectivityTimeout(timeout);
    hostCmdParams.setManagementNetworkChanged(isManagementNetworkChanged(networksToConfigure));
    return hostCmdParams;
}
Also used : SwitchType(org.ovirt.engine.core.common.network.SwitchType) HostSetupNetworksVdsCommandParameters(org.ovirt.engine.core.common.vdscommands.HostSetupNetworksVdsCommandParameters) HostNetwork(org.ovirt.engine.core.common.vdscommands.HostNetwork)

Example 3 with HostNetwork

use of org.ovirt.engine.core.common.vdscommands.HostNetwork in project ovirt-engine by oVirt.

the class HostSetupNetworksCommand method isManagementNetworkChanged.

private boolean isManagementNetworkChanged(List<HostNetwork> networksToConfigure) {
    Network managementNetwork = managementNetworkUtil.getManagementNetwork(getClusterNetworks(), getClusterId());
    String managementNetworkName = managementNetwork.getName();
    for (HostNetwork network : networksToConfigure) {
        if (managementNetworkName.equals(network.getNetworkName())) {
            return true;
        }
    }
    for (CreateOrUpdateBond createOrUpdateBond : getParameters().getCreateOrUpdateBonds()) {
        // We are only interested in existing bonds, whose bonding options/slave have changed, so it
        // enough to check existing bonds. New bonds which have the management network
        // are covered by network attachments
        VdsNetworkInterface bondNic = getExistingNicsBusinessEntityMap().get(createOrUpdateBond.getId());
        if (bondNic != null && managementNetworkName.equals(bondNic.getNetworkName())) {
            return true;
        }
    }
    return false;
}
Also used : HostNetwork(org.ovirt.engine.core.common.vdscommands.HostNetwork) FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) HostNetwork(org.ovirt.engine.core.common.vdscommands.HostNetwork)

Aggregations

HostNetwork (org.ovirt.engine.core.common.vdscommands.HostNetwork)3 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)2 Network (org.ovirt.engine.core.common.businessentities.network.Network)2 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)2 ArrayList (java.util.ArrayList)1 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)1 DnsResolverConfiguration (org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration)1 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)1 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)1 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)1 SwitchType (org.ovirt.engine.core.common.network.SwitchType)1 HostSetupNetworksVdsCommandParameters (org.ovirt.engine.core.common.vdscommands.HostSetupNetworksVdsCommandParameters)1 EffectiveHostNetworkQos (org.ovirt.engine.core.vdsbroker.EffectiveHostNetworkQos)1