use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidatorTest method testValidateAttachementsForVlans.
@Test
public void testValidateAttachementsForVlans() {
String unmanagedBaseNicName = "eth0";
NetworkAttachment attachement1 = new NetworkAttachment();
attachement1.setNetworkName("network1");
attachement1.setNicName(unmanagedBaseNicName);
NetworkAttachment attachement2 = new NetworkAttachment();
attachement2.setNetworkName("any2");
attachement2.setNicName("eth1");
List<NetworkAttachment> attachementList = Arrays.asList(attachement1, attachement2);
Nic nic = createNic(unmanagedBaseNicName);
VdsNetworkInterface vlanNic = createVlanNic(nic, "eth0.100", 100, false);
List<VdsNetworkInterface> existingInterfaces = Collections.singletonList(vlanNic);
Set<String> nicsWithUnmanagedNetworks = validator.filterNicsWithUnmanagedNetworks(existingInterfaces, Collections.emptySet());
assertEquals(1, nicsWithUnmanagedNetworks.size());
String filteredNicName = nicsWithUnmanagedNetworks.iterator().next();
assertEquals(unmanagedBaseNicName, filteredNicName);
ValidationResult result = validator.validateAttachements(filteredNicName, attachementList);
assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_ATTACHEMENT_ON_UNMANAGED_NETWORK, ReplacementUtils.createSetVariableString(NETWORK, "network1"), ReplacementUtils.createSetVariableString(NIC, "eth0")));
result = validator.validateAttachements("eth7", attachementList);
assertTrue(result.isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class UnmanagedNetworkValidatorTest method testFilterNicsWithUnmanagedNetworks.
@Test
public void testFilterNicsWithUnmanagedNetworks() {
VdsNetworkInterface nicManaged = createNicWithNetworkImplementationDetails("eth0", true);
VdsNetworkInterface nicUnmanaged = createNicWithNetworkImplementationDetails("eth1", false);
List<VdsNetworkInterface> existingInterfaces = Arrays.asList(nicManaged, nicUnmanaged);
Set<String> unmanagedNicsSet = validator.filterNicsWithUnmanagedNetworks(existingInterfaces, Collections.emptySet());
assertEquals(1, unmanagedNicsSet.size());
assertTrue(unmanagedNicsSet.contains("eth1"));
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class VfSchedulerImplTest method updateVfsConfig.
private HostDevice updateVfsConfig(HostNicVfsConfig hostNicVfsConfig, VmNetworkInterface vnic, int numOfVfs, boolean allNetworksAllowed, boolean vnicNetworkInSriovConfig, boolean vnicLabelInSriovConfig, boolean hasFreeVf, boolean freeVfShareIommuGroup, boolean vfDirectlyAttached) {
hostNicVfsConfig.setNicId(Guid.newGuid());
hostNicVfsConfig.setNumOfVfs(numOfVfs);
hostNicVfsConfig.setAllNetworksAllowed(allNetworksAllowed);
updateVfsConfigNetworks(hostNicVfsConfig, vnic, vnicNetworkInSriovConfig);
updateVfsConfigLabels(hostNicVfsConfig, vnic, vnicLabelInSriovConfig);
VdsNetworkInterface nic = new VdsNetworkInterface();
nic.setId(hostNicVfsConfig.getNicId());
when(getNic(hostNicVfsConfig)).thenReturn(nic);
HostDevice vf = null;
if (hasFreeVf) {
vf = createFreeVf(hostNicVfsConfig);
mockVfShareIommuGroup(vf, freeVfShareIommuGroup);
if (!freeVfShareIommuGroup && (allNetworksAllowed || vnicNetworkInSriovConfig || vnicLabelInSriovConfig)) {
if (!vfDirectlyAttached) {
expectedVnicToVfMap.put(vnic.getId(), vf.getDeviceName());
}
mockVfDirectlyAttached(vfDirectlyAttached, vf);
}
}
return vf;
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidateModifiedBondSlavesWhenSlaveAlreadySlavesForDifferentBondWhichGetsRemoved.
@Test
public void testValidateModifiedBondSlavesWhenSlaveAlreadySlavesForDifferentBondWhichGetsRemoved() throws Exception {
Bond bond = createBond("bondName");
Bond differentBond = createBond("differentBond");
VdsNetworkInterface slaveA = createBondSlave(bond, "slaveA");
VdsNetworkInterface slaveB = createBondSlave(differentBond, "slaveB");
setBondSlaves(bond, slaveA, slaveB);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedBonds(differentBond.getId())).addExistingInterfaces(bond, differentBond, slaveA, slaveB).build();
doTestValidateModifiedBondSlaves(spy(validator), ValidationResult.VALID, ValidationResult.VALID, isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method validateSlaveHasNoLabelsOldLabelWasRemovedValid.
@Test
public void validateSlaveHasNoLabelsOldLabelWasRemovedValid() {
final String removedLabelName = "lbl1";
VdsNetworkInterface slave = createNic("slave");
slave.setLabels(Collections.singleton(removedLabelName));
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedLabels(removedLabelName)).addExistingInterfaces(slave).build();
assertThat(validator.validateSlaveHasNoLabels(slave.getName()), isValid());
}
Aggregations