Search in sources :

Example 21 with HostSetupNetworksParameters

use of org.ovirt.engine.core.common.action.HostSetupNetworksParameters in project ovirt-engine by oVirt.

the class RemoveNetworkAttachmentCommand method executeCommand.

@Override
protected void executeCommand() {
    HostSetupNetworksParameters params = new HostSetupNetworksParameters(getParameters().getVdsId());
    params.getRemovedNetworkAttachments().add(getParameters().getNetworkAttachmentId());
    ActionReturnValue returnValue = runInternalAction(ActionType.HostSetupNetworks, params);
    propagateFailure(returnValue);
    setSucceeded(returnValue.getSucceeded());
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters)

Example 22 with HostSetupNetworksParameters

use of org.ovirt.engine.core.common.action.HostSetupNetworksParameters in project ovirt-engine by oVirt.

the class UnlabelNicCommand method createHostSetupNetworksParameters.

private HostSetupNetworksParameters createHostSetupNetworksParameters() {
    HostSetupNetworksParameters params = new HostSetupNetworksParameters(getVdsId());
    params.setRemovedLabels(Collections.singleton(getLabel()));
    return params;
}
Also used : HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters)

Example 23 with HostSetupNetworksParameters

use of org.ovirt.engine.core.common.action.HostSetupNetworksParameters in project ovirt-engine by oVirt.

the class NetworkConfigurator method createSetupNetworkParams.

public HostSetupNetworksParameters createSetupNetworkParams(VdsNetworkInterface nic) {
    HostSetupNetworksParameters parameters = new HostSetupNetworksParameters(host.getId());
    NetworkAttachment managementAttachment = new NetworkAttachment();
    managementAttachment.setNetworkId(managementNetwork.getId());
    Map<String, VdsNetworkInterface> nicNameToNic = Entities.entitiesByName(host.getInterfaces());
    Guid baseNicId = nicNameToNic.get(NetworkCommonUtils.stripVlan(nic)).getId();
    managementAttachment.setNicId(baseNicId);
    IpConfiguration ipConfiguration = new IpConfiguration();
    ipConfiguration.setIPv4Addresses(Collections.singletonList(new NicToIpv4AddressFunction().apply(nic)));
    if (FeatureSupported.ipv6Supported(host.getClusterCompatibilityVersion())) {
        ipConfiguration.setIpV6Addresses(Collections.singletonList(new NicToIpv6AddressFunction().apply(nic)));
    }
    managementAttachment.setIpConfiguration(ipConfiguration);
    parameters.getNetworkAttachments().add(managementAttachment);
    return parameters;
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) NicToIpv6AddressFunction(org.ovirt.engine.core.utils.network.function.NicToIpv6AddressFunction) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicToIpv4AddressFunction(org.ovirt.engine.core.utils.network.function.NicToIpv4AddressFunction) HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Guid(org.ovirt.engine.core.compat.Guid) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 24 with HostSetupNetworksParameters

use of org.ovirt.engine.core.common.action.HostSetupNetworksParameters in project ovirt-engine by oVirt.

the class BackendHostResource method toParameters.

private HostSetupNetworksParameters toParameters(Action action) {
    HostSetupNetworksParameters parameters = new HostSetupNetworksParameters(guid);
    Map<Guid, NetworkAttachment> attachmentsById = getBackendNetworkAttachments();
    if (action.isSetModifiedNetworkAttachments()) {
        for (org.ovirt.engine.api.model.NetworkAttachment model : action.getModifiedNetworkAttachments().getNetworkAttachments()) {
            NetworkAttachment attachment = mapNetworkAttachment(attachmentsById, model);
            parameters.getNetworkAttachments().add(attachment);
        }
    }
    if (action.isSetSynchronizedNetworkAttachments()) {
        Map<Guid, NetworkAttachment> networkAttachmentFromParams = Entities.businessEntitiesById(parameters.getNetworkAttachments());
        for (org.ovirt.engine.api.model.NetworkAttachment model : action.getSynchronizedNetworkAttachments().getNetworkAttachments()) {
            if (model.isSetId()) {
                Guid networkAttachmentId = asGuid(model.getId());
                if (networkAttachmentFromParams.containsKey(networkAttachmentId)) {
                    networkAttachmentFromParams.get(networkAttachmentId).setOverrideConfiguration(true);
                } else if (attachmentsById.containsKey(networkAttachmentId)) {
                    NetworkAttachment networkAttachment = attachmentsById.get(networkAttachmentId);
                    networkAttachment.setOverrideConfiguration(true);
                    parameters.getNetworkAttachments().add(networkAttachment);
                } else {
                    return handleError(new EntityNotFoundException("NetworkAttachment.id: " + model.getId()), true);
                }
            }
        }
    }
    if (action.isSetModifiedLabels()) {
        for (NetworkLabel label : action.getModifiedLabels().getNetworkLabels()) {
            NicLabel nicLabel = new NicLabel();
            nicLabel.setLabel(label.getId());
            if (label.isSetHostNic()) {
                nicLabel.setNicId(label.getHostNic().isSetId() ? asGuid(label.getHostNic().getId()) : null);
                nicLabel.setNicName(label.getHostNic().getName());
            }
            parameters.getLabels().add(nicLabel);
        }
    }
    if (action.isSetRemovedLabels()) {
        for (NetworkLabel label : action.getRemovedLabels().getNetworkLabels()) {
            parameters.getRemovedLabels().add(label.getId());
        }
    }
    if (action.isSetRemovedNetworkAttachments()) {
        for (org.ovirt.engine.api.model.NetworkAttachment model : action.getRemovedNetworkAttachments().getNetworkAttachments()) {
            NetworkAttachment attachment = mapNetworkAttachment(attachmentsById, model);
            parameters.getRemovedNetworkAttachments().add(attachment.getId());
        }
    }
    BusinessEntityMap<Bond> bonds = getBackendHostBonds();
    if (action.isSetModifiedBonds()) {
        BusinessEntityMap<VdsNetworkInterface> nicsFromBackend = getBackendNics();
        for (HostNic bond : action.getModifiedBonds().getHostNics()) {
            completeSlaveNames(nicsFromBackend, bond);
            parameters.getCreateOrUpdateBonds().add(mapBonds(bonds, bond));
        }
    }
    if (action.isSetRemovedBonds()) {
        for (HostNic bond : action.getRemovedBonds().getHostNics()) {
            parameters.getRemovedBonds().add(mapBonds(bonds, bond).getId());
        }
    }
    if (action.isSetCheckConnectivity()) {
        parameters.setRollbackOnFailure(action.isCheckConnectivity());
    }
    if (action.isSetConnectivityTimeout()) {
        parameters.setConectivityTimeout(action.getConnectivityTimeout());
    }
    return parameters;
}
Also used : HostSetupNetworksParameters(org.ovirt.engine.core.common.action.HostSetupNetworksParameters) Guid(org.ovirt.engine.core.compat.Guid) NetworkLabel(org.ovirt.engine.api.model.NetworkLabel) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) HostNic(org.ovirt.engine.api.model.HostNic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Aggregations

HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)24 Test (org.junit.Test)11 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)7 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)7 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)5 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)4 Guid (org.ovirt.engine.core.compat.Guid)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)2 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)2 HostNic (org.ovirt.engine.api.model.HostNic)1 NetworkLabel (org.ovirt.engine.api.model.NetworkLabel)1 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)1 Network (org.ovirt.engine.core.common.businessentities.network.Network)1 NicToIpv4AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv4AddressFunction)1 NicToIpv6AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv6AddressFunction)1