use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class PersistentHostSetupNetworksParametersFactoryTest method createNetworkAttachment.
private NetworkAttachment createNetworkAttachment(Network network, HostNetworkQos hostNetworkQos) {
NetworkAttachment networkAttachment = new NetworkAttachment();
networkAttachment.setId(Guid.newGuid());
networkAttachment.setHostNetworkQos(AnonymousHostNetworkQos.fromHostNetworkQos(hostNetworkQos));
networkAttachment.setNetworkId(network.getId());
return networkAttachment;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment 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.NetworkAttachment 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.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksCommand method checkForOutOfSyncNetworks.
private ValidationResult checkForOutOfSyncNetworks() {
for (NetworkAttachment networkAttachment : getParameters().getNetworkAttachments()) {
boolean newNetworkAttachment = networkAttachment.getId() == null;
if (newNetworkAttachment) {
// attachment to be yet created cannot be out of sync.
continue;
}
boolean doNotCheckForOutOfSync = networkAttachment.isOverrideConfiguration();
if (doNotCheckForOutOfSync) {
continue;
}
Map<Guid, NetworkAttachment> existingNetworkAttachmentMap = Entities.businessEntitiesById(getExistingAttachments());
NetworkAttachment existingNetworkAttachment = existingNetworkAttachmentMap.get(networkAttachment.getId());
VdsNetworkInterface nic = NetworkUtils.hostInterfacesByNetworkName(getExistingNics()).get(existingNetworkAttachment.getNetworkName());
NetworkImplementationDetails networkImplementationDetails = nic.getNetworkImplementationDetails();
boolean networkIsNotInSync = networkImplementationDetails != null && !networkImplementationDetails.isInSync();
if (networkIsNotInSync) {
return new ValidationResult(EngineMessage.NETWORKS_NOT_IN_SYNC, ReplacementUtils.createSetVariableString("NETWORK_NOT_IN_SYNC", existingNetworkAttachment.getNetworkName()));
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment 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;
}
Aggregations