use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class UpdateNetworkCommand method onlyPermittedFieldsChanged.
/**
* @return <code>true</code> iff only the description or comment field were changed, otherwise <code>false</code>.
*/
private boolean onlyPermittedFieldsChanged() {
Network oldNetwork = getOldNetwork();
Network newNetwork = getNetwork();
if (oldNetwork == null || newNetwork == null) {
return false;
}
return Objects.equals(oldNetwork.getName(), newNetwork.getName()) && Objects.equals(oldNetwork.getDataCenterId(), newNetwork.getDataCenterId()) && Objects.equals(oldNetwork.getId(), newNetwork.getId()) && Objects.equals(oldNetwork.getMtu(), newNetwork.getMtu()) && Objects.equals(oldNetwork.getName(), newNetwork.getName()) && Objects.equals(oldNetwork.getProvidedBy(), newNetwork.getProvidedBy()) && Objects.equals(oldNetwork.getStp(), newNetwork.getStp()) && Objects.equals(oldNetwork.getVlanId(), newNetwork.getVlanId()) && Objects.equals(oldNetwork.isVmNetwork(), newNetwork.isVmNetwork());
}
use of org.ovirt.engine.core.common.businessentities.network.Network 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.Network 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.Network 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;
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateCustomProperties.
ValidationResult validateCustomProperties(SimpleCustomPropertiesUtil util, Map<String, String> validPropertiesForVm, Map<String, String> validPropertiesForNonVm) {
for (NetworkAttachment attachment : params.getNetworkAttachments()) {
Network network = existingNetworkRelatedToAttachment(attachment);
if (attachment.hasProperties()) {
List<ValidationError> errors = util.validateProperties(network.isVmNetwork() ? validPropertiesForVm : validPropertiesForNonVm, attachment.getProperties());
if (!errors.isEmpty()) {
handleCustomPropertiesError(util, errors);
EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_NETWORK_CUSTOM_PROPERTIES_BAD_INPUT;
return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentStringWithMultipleValues(engineMessage, network.getName()));
}
}
}
return ValidationResult.VALID;
}
Aggregations