use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class NetworkIdNetworkNameCompleter method completeNetworkAttachment.
private void completeNetworkAttachment(NetworkAttachment networkAttachment, BusinessEntityMap<Network> clusterNetworks, Guid dataCenterId) {
Guid networkId = networkAttachment.getNetworkId();
String networkName = networkAttachment.getNetworkName();
boolean networkNameSpecified = networkName != null;
boolean networkIdSpecified = networkId != null;
if (!networkIdSpecified && !networkNameSpecified || networkIdSpecified && networkNameSpecified) {
return;
}
if (networkNameSpecified) {
Network network = getNetworkByName(networkName, clusterNetworks, dataCenterId);
boolean networkByNameExists = network != null;
if (networkByNameExists) {
networkAttachment.setNetworkId(network.getId());
}
}
if (networkIdSpecified) {
Network network = getNetworkById(networkId, clusterNetworks);
boolean networkByIdExists = network != null;
if (networkByIdExists) {
networkAttachment.setNetworkName(network.getName());
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class NetworkMtuValidator method networksOnNicMatchMtu.
private boolean networksOnNicMatchMtu(List<Network> networksOnNic) {
final Network nonVlanNetwork = networksOnNic.stream().filter(network -> !NetworkUtils.isVlan(network)).findFirst().orElse(null);
if (nonVlanNetwork == null) {
return true;
}
int nonVlanNetworkActualMtu = getMtuActualValue(nonVlanNetwork);
return networksOnNic.stream().map(network -> getMtuActualValue(network)).noneMatch(networkMtu -> networkMtu != nonVlanNetworkActualMtu);
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class NetworkMtuValidator method getNetworksOnNics.
Map<String, List<Network>> getNetworksOnNics(Collection<NetworkAttachment> attachmentsToConfigure) {
Map<String, List<Network>> nicsToNetworks = new HashMap<>();
for (NetworkAttachment attachment : attachmentsToConfigure) {
String nicName = attachment.getNicName();
if (!nicsToNetworks.containsKey(nicName)) {
nicsToNetworks.put(nicName, new ArrayList<>());
}
Network networkToConfigure = networkBusinessEntityMap.get(attachment.getNetworkId());
nicsToNetworks.get(nicName).add(networkToConfigure);
}
return nicsToNetworks;
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class NicLabelsCompleter method completeNetworkAttachmentsByLabels.
private void completeNetworkAttachmentsByLabels() {
for (NicLabel nicLabel : params.getLabels()) {
List<Network> labelNetworks = labelToNetworks.get(nicLabel.getLabel());
if (labelNetworks == null) {
continue;
}
for (Network network : labelNetworks) {
NetworkAttachment newOrModifiedNetworkAttachment = attachmentsByNetworkId.get(network.getId());
NetworkAttachment existingNetworkAttachment = existingNetworkAttachmentsByNetworkId.get(network.getId());
boolean existingAttachmentRemoved = existingNetworkAttachment == null ? false : params.getRemovedNetworkAttachments().contains(existingNetworkAttachment.getId());
boolean noNewOrModifiedNetworkAttachment = newOrModifiedNetworkAttachment == null;
NetworkAttachment attachmentToConfigure = noNewOrModifiedNetworkAttachment && !existingAttachmentRemoved ? existingNetworkAttachment : newOrModifiedNetworkAttachment;
if (attachmentToConfigure == null) {
params.getNetworkAttachments().add(createNetworkAttachment(nicLabel.getNicId(), nicLabel.getNicName(), network.getId(), network.getName()));
} else if (!Objects.equals(attachmentToConfigure.getNicName(), nicLabel.getNicName()) && noNewOrModifiedNetworkAttachment) {
NetworkAttachment updatedNetworkAttachment = new NetworkAttachment(existingNetworkAttachment);
updatedNetworkAttachment.setNicId(nicLabel.getNicId());
updatedNetworkAttachment.setNicName(nicLabel.getNicName());
params.getNetworkAttachments().add(updatedNetworkAttachment);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class ImportExternalNetworkCommand method getNetwork.
protected Network getNetwork() {
if (network == null) {
NetworkProviderProxy proxy = providerProxyFactory.create(getProvider());
String networkId = getParameters().getNetworkExternalId();
network = proxy.getAll().stream().filter(network -> networkId.equals(network.getProvidedBy().getExternalId())).findFirst().orElse(null);
}
return network;
}
Aggregations