Search in sources :

Example 56 with NetworkCluster

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

the class ManageNetworkClustersCommand method validateInputForDuplication.

private ValidationResult validateInputForDuplication() {
    final Set<NetworkClusterId> networkClusterIds = new HashSet<>();
    final Iterable<NetworkCluster> inputNetworkClusters = Stream.of(getParameters().getAttachments(), getParameters().getDetachments(), getParameters().getUpdates()).flatMap(Collection::stream).collect(Collectors.toList());
    for (NetworkCluster networkCluster : inputNetworkClusters) {
        if (networkClusterIds.contains(networkCluster.getId())) {
            final String networkClusterReplacement = String.format("${NetworkCluster} %s", networkCluster.getId());
            return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DUPLICATE_NETWORK_CLUSTER_INPUT, networkClusterReplacement);
        } else {
            networkClusterIds.add(networkCluster.getId());
        }
    }
    return ValidationResult.VALID;
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) HashSet(java.util.HashSet)

Example 57 with NetworkCluster

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

the class NetworkClusterHelper method setStatus.

public void setStatus(Guid clusterId, final Collection<Network> networks) {
    final RequiredNetworkClusterStatusUpdater requiredNetworkClusterStatusUpdater = new RequiredNetworkClusterStatusUpdater(clusterId);
    for (Network network : networks) {
        NetworkCluster networkCluster = networkClusterDao.get(new NetworkClusterId(clusterId, network.getId()));
        boolean doUpdateNetworkClusterStatus = networkCluster != null;
        if (doUpdateNetworkClusterStatus) {
            if (networkCluster.isRequired()) {
                requiredNetworkClusterStatusUpdater.update(networkCluster, network.getName());
            } else {
                updateNetworkClusterStatus(networkCluster, NetworkStatus.OPERATIONAL);
            }
        }
    }
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)

Example 58 with NetworkCluster

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

the class NetworkHelper method attachNetworkToClusters.

public ActionReturnValue attachNetworkToClusters(Guid networkId, Collection<Guid> clusterIds) {
    List<NetworkCluster> networkAttachments = createNetworkClusters(clusterIds);
    networkAttachments.forEach(networkAttachment -> networkAttachment.setNetworkId(networkId));
    return backend.runInternalAction(ActionType.ManageNetworkClusters, new ManageNetworkClustersParameters(networkAttachments));
}
Also used : ManageNetworkClustersParameters(org.ovirt.engine.core.common.action.ManageNetworkClustersParameters) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 59 with NetworkCluster

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

the class PropagateNetworksToClusterHostsCommand method mapParametersByClusterId.

private Map<Guid, ManageNetworkClustersParameters> mapParametersByClusterId() {
    ManageNetworkClustersParameters parameters = getParameters();
    Map<Guid, List<NetworkCluster>> attachmentByClusterId = groupByClusterId(parameters.getAttachments());
    Map<Guid, List<NetworkCluster>> detachmentByClusterId = groupByClusterId(parameters.getDetachments());
    Map<Guid, List<NetworkCluster>> updatesByClusterId = groupByClusterId(parameters.getUpdates());
    Set<Guid> clusterIds = Stream.of(attachmentByClusterId, detachmentByClusterId, updatesByClusterId).flatMap(e -> e.keySet().stream()).collect(Collectors.toSet());
    return clusterIds.stream().collect(Collectors.toMap(Function.identity(), clusterId -> new ManageNetworkClustersParameters(nullToEmptyList(attachmentByClusterId.get(clusterId)), nullToEmptyList(detachmentByClusterId.get(clusterId)), nullToEmptyList(updatesByClusterId.get(clusterId)))));
}
Also used : NonTransactiveCommandAttribute(org.ovirt.engine.core.bll.NonTransactiveCommandAttribute) CollectionUtils.nullToEmptyList(org.ovirt.engine.core.utils.CollectionUtils.nullToEmptyList) InternalCommandAttribute(org.ovirt.engine.core.bll.InternalCommandAttribute) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) Set(java.util.Set) CommandBase(org.ovirt.engine.core.bll.CommandBase) HostSetupNetworksParametersBuilder(org.ovirt.engine.core.bll.network.HostSetupNetworksParametersBuilder) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) NetworkClustersToSetupNetworksParametersTransformerFactory(org.ovirt.engine.core.bll.network.cluster.transformer.NetworkClustersToSetupNetworksParametersTransformerFactory) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ManageNetworkClustersParameters(org.ovirt.engine.core.common.action.ManageNetworkClustersParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) List(java.util.List) Stream(java.util.stream.Stream) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) Map(java.util.Map) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) Collections(java.util.Collections) NetworkClustersToSetupNetworksParametersTransformer(org.ovirt.engine.core.bll.network.cluster.transformer.NetworkClustersToSetupNetworksParametersTransformer) ManageNetworkClustersParameters(org.ovirt.engine.core.common.action.ManageNetworkClustersParameters) CollectionUtils.nullToEmptyList(org.ovirt.engine.core.utils.CollectionUtils.nullToEmptyList) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid)

Example 60 with NetworkCluster

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

the class NetworkAttachmentValidator method bootProtocolSetForRoleNetwork.

public ValidationResult bootProtocolSetForRoleNetwork() {
    NetworkCluster networkCluster = getNetworkCluster();
    IsRoleNetworkIpConfigurationValid isRoleNetworkIpConfigurationValid = new IsRoleNetworkIpConfigurationValid(networkCluster);
    return ValidationResult.failWith(EngineMessage.ACTION_TYPE_FAILED_ROLE_NETWORK_HAS_NO_BOOT_PROTOCOL, ReplacementUtils.createSetVariableString(VAR_ACTION_TYPE_FAILED_ROLE_NETWORK_HAS_NO_BOOT_PROTOCOL_ENTITY, getNetwork().getName())).unless(isRoleNetworkIpConfigurationValid.validate(attachment));
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

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