Search in sources :

Example 1 with MapNetworkAttachments

use of org.ovirt.engine.core.common.utils.MapNetworkAttachments in project ovirt-engine by oVirt.

the class HostSetupNetworksCommand method getRemovedNetworks.

private Set<String> getRemovedNetworks() {
    if (removedNetworks == null) {
        List<NetworkAttachment> removedNetworkAttachments = Entities.filterEntitiesByRequiredIds(getParameters().getRemovedNetworkAttachments(), existingAttachments);
        removedNetworks = new HashSet<>(removedNetworkAttachments.size());
        Map<Guid, NetworkAttachment> networkIdToAttachment = new MapNetworkAttachments(getParameters().getNetworkAttachments()).byNetworkId();
        for (NetworkAttachment removedAttachment : removedNetworkAttachments) {
            if (!networkIdToAttachment.containsKey(removedAttachment.getNetworkId())) {
                removedNetworks.add(existingNetworkRelatedToAttachment(removedAttachment).getVdsmName());
            }
        }
    }
    return removedNetworks;
}
Also used : MapNetworkAttachments(org.ovirt.engine.core.common.utils.MapNetworkAttachments) Guid(org.ovirt.engine.core.compat.Guid) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 2 with MapNetworkAttachments

use of org.ovirt.engine.core.common.utils.MapNetworkAttachments in project ovirt-engine by oVirt.

the class PersistentHostSetupNetworksParametersFactory method getNetworksToSync.

/**
 * For given host and it's networks, return network attachments representing those networks on this host.
 * @param hostId host ID
 * @param networks networks to transform
 * @return network attachments representing given networks on this host.
 */
private Map<Network, NetworkAttachment> getNetworksToSync(Guid hostId, List<Network> networks) {
    List<NetworkAttachment> allAttachmentsOfHost = networkAttachmentDao.getAllForHost(hostId);
    Map<Guid, NetworkAttachment> attachmentsByNetworkId = new MapNetworkAttachments(allAttachmentsOfHost).byNetworkId();
    Map<Network, NetworkAttachment> networksToSync = new HashMap<>();
    for (Network network : networks) {
        Guid networkId = network.getId();
        NetworkAttachment attachmentToSync = attachmentsByNetworkId.get(networkId);
        if (attachmentToSync != null && !attachmentToSync.isQosOverridden()) {
            attachmentToSync.setOverrideConfiguration(true);
            networksToSync.put(network, attachmentToSync);
        }
    }
    return networksToSync;
}
Also used : MapNetworkAttachments(org.ovirt.engine.core.common.utils.MapNetworkAttachments) HashMap(java.util.HashMap) Network(org.ovirt.engine.core.common.businessentities.network.Network) Guid(org.ovirt.engine.core.compat.Guid) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Aggregations

NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)2 MapNetworkAttachments (org.ovirt.engine.core.common.utils.MapNetworkAttachments)2 Guid (org.ovirt.engine.core.compat.Guid)2 HashMap (java.util.HashMap)1 Network (org.ovirt.engine.core.common.businessentities.network.Network)1