use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails 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.NetworkImplementationDetails 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.VdsNetworkInterface.NetworkImplementationDetails in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method validateValidBondsForBondMode.
private void validateValidBondsForBondMode(boolean isValidForAllModes, boolean isVmNetwork, boolean isInSync, boolean isOverriddenConfiguration, BondMode bondMode) {
String networkName = "network";
String bondName = "bondName";
Network network = createNetworkWithName(networkName);
network.setVmNetwork(isVmNetwork);
NetworkImplementationDetails networkImplementationDetails = new NetworkImplementationDetails(isInSync, true);
Bond bond = createBond(bondName, networkName, null);
bond.setBondOptions(bondMode.getConfigurationValue());
bond.setNetworkImplementationDetails(networkImplementationDetails);
NetworkAttachment networkAttachment = createNetworkAttachment(network, bond);
networkAttachment.setOverrideConfiguration(isOverriddenConfiguration);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addBonds(CreateOrUpdateBond.fromBond(bond))).addNetworks(network).addExistingInterfaces(bond).build();
boolean expectValidValidationResult = isValidForAllModes || bondMode.isBondModeValidForVmNetwork();
List<NetworkAttachment> attachmentsToConfigure = Collections.singletonList(networkAttachment);
ValidationResult result = validator.validateBondModeVsNetworksAttachedToIt(attachmentsToConfigure);
if (expectValidValidationResult) {
collector.checkThat(result, isValid());
} else {
collector.checkThat(result, failsWith(EngineMessage.INVALID_BOND_MODE_FOR_BOND_WITH_VM_NETWORK, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_BOND_NAME, bondName), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, networkName)));
}
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidatorTest method createVlanNic.
public VdsNetworkInterface createVlanNic(VdsNetworkInterface baseNic, String nicName, Integer vlanId, boolean isManaged) {
VdsNetworkInterface vlanNic = new VdsNetworkInterface();
vlanNic.setId(Guid.newGuid());
vlanNic.setName(nicName);
vlanNic.setVlanId(vlanId);
vlanNic.setBaseInterface(baseNic.getName());
vlanNic.setNetworkName("unmanagedNetworkName");
vlanNic.setNetworkImplementationDetails(new NetworkImplementationDetails(true, isManaged));
return vlanNic;
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidatorTest method createNicWithNetworkImplementationDetails.
private Nic createNicWithNetworkImplementationDetails(String name, boolean isManaged) {
Nic nic = createNic(name);
NetworkImplementationDetails networkImplementationDetails1 = new NetworkImplementationDetails(true, isManaged);
nic.setNetworkImplementationDetails(networkImplementationDetails1);
return nic;
}
Aggregations