use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface 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.VdsNetworkInterface 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;
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostSetupNetworksCommand method updateAddedModifiedLabelsOnNics.
private void updateAddedModifiedLabelsOnNics(Map<String, VdsNetworkInterface> nicsToConfigureByName) {
Map<String, VdsNetworkInterface> labelToExistingNic = getLabelToNic(nicsToConfigureByName.values());
for (NicLabel nicLabel : getParameters().getLabels()) {
VdsNetworkInterface currentLabelNic = labelToExistingNic.get(nicLabel.getLabel());
VdsNetworkInterface newLabelNic = nicsToConfigureByName.get(nicLabel.getNicName());
moveLabel(nicLabel.getLabel(), currentLabelNic, newLabelNic);
}
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class GetNetworkAttachmentsByHostIdQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Guid hostId = getParameters().getId();
List<NetworkAttachment> networkAttachments = networkAttachmentDao.getAllForHost(hostId);
List<VdsNetworkInterface> allInterfacesForHost = interfaceDao.getAllInterfacesForVds(hostId);
VDS vds = hostDao.get(hostId);
Guid clusterId = vds.getClusterId();
BusinessEntityMap<Network> networkMap = new BusinessEntityMap<>(networkDao.getAllForCluster(clusterId));
reportedConfigurationsFiller.fillReportedConfigurations(allInterfacesForHost, networkMap, networkAttachments, vds.getDynamicData().getReportedDnsResolverConfiguration(), clusterId);
completeNicNames(networkAttachments, allInterfacesForHost);
completeNetworkNames(networkAttachments, networkMap);
getQueryReturnValue().setReturnValue(networkAttachments);
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostNicsUtil method findHostNics.
private List<VdsNetworkInterface> findHostNics(Guid hostId, Function<Guid, Guid> hostClusterIdFinder, Guid userID, boolean isFiltered) {
final List<VdsNetworkInterface> vdsInterfaces = interfaceDao.getAllInterfacesForVds(hostId, userID, isFiltered);
// 1. here we return all interfaces (eth0, eth1, eth2) - the first
// condition
// 2. we also return bonds that connected to network and has interfaces
// - the second condition
// i.e.
// we have:
// Network | Interface
// -------------------
// red-> |->eth0
// |->eth1
// | |->eth2
// blue-> |->bond0->|->eth3
// |->bond1
//
// we return: eth0, eth1, eth2, eth3, bond0
// we don't return bond1 because he is not connected to network and has
// no child interfaces
List<VdsNetworkInterface> interfaces = new ArrayList<>(vdsInterfaces.size());
if (!vdsInterfaces.isEmpty()) {
final Guid clusterId = hostClusterIdFinder.apply(hostId);
Map<String, Network> networks = Entities.entitiesByName(networkDao.getAllForCluster(clusterId));
for (final VdsNetworkInterface nic : vdsInterfaces) {
if (!nic.isBond() || nicDoesHaveSlaves(vdsInterfaces, nic)) {
interfaces.add(nic);
Network network = networks.get(nic.getNetworkName());
NetworkImplementationDetails networkImplementationDetails = networkImplementationDetailsUtils.calculateNetworkImplementationDetails(nic, network);
nic.setNetworkImplementationDetails(networkImplementationDetails);
}
}
}
return interfaces;
}
Aggregations