use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NetworkDeviceHelperImplTest method testGetVfMap.
@Test
public void testGetVfMap() {
final HostDevice pfNetDevice = new HostDevice();
final HostDevice pfPciDevice = new HostDevice();
final Guid pfNicId = Guid.newGuid();
final String pfNicName = "pf" + NIC_NAME;
final String pfPciDeviceName = "pf" + PCI_DEVICE_NAME;
pfNetDevice.setHostId(HOST_ID);
pfNetDevice.setDeviceName("pf" + NET_DEVICE_NAME);
pfNetDevice.setNetworkInterfaceName(pfNicName);
pfNetDevice.setParentDeviceName(pfPciDeviceName);
pfPciDevice.setHostId(HOST_ID);
pfPciDevice.setDeviceName(pfPciDeviceName);
pfPciDevice.setDeviceName(pfPciDeviceName);
when(pciDevice.getParentPhysicalFunction()).thenReturn(pfPciDeviceName);
mockHostDevices(Arrays.asList(pfNetDevice, pfPciDevice, new HostDevice()));
when(nic.getVlanId()).thenReturn(null);
final VdsNetworkInterface pfNic = new VdsNetworkInterface();
pfNic.setId(pfNicId);
pfNic.setName(pfNetDevice.getNetworkInterfaceName());
final VdsNetworkInterface bondNic = new VdsNetworkInterface();
bondNic.setBonded(true);
final VdsNetworkInterface vlanNic = new VdsNetworkInterface();
vlanNic.setVlanId(666);
mockNics(Arrays.asList(pfNic, bondNic, vlanNic), true);
final Map<Guid, Guid> actual = networkDeviceHelper.getVfMap(HOST_ID);
assertEquals(1, actual.size());
assertThat(actual, hasEntry(NIC_ID, pfNicId));
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NetworkDeviceHelperImplTest method freeVfCommon.
private List<HostDevice> freeVfCommon(int numOfFreeVfs, int numOfVfsAttachedToVm, int numOfVfsHasNoNic, int numOfVfsHasNetworkAttached, int numOfVfsHasVlanDeviceAttached, int numOfVfsArePartOfBond) {
networkDeviceHelper = spy(new NetworkDeviceHelperImpl(interfaceDao, hostDeviceDao, hostNicVfsConfigDao));
List<HostDevice> devices = new ArrayList<>();
List<HostDevice> freeVfs = new ArrayList<>();
int numOfVfs = numOfFreeVfs + numOfVfsAttachedToVm + numOfVfsHasNoNic + numOfVfsHasNetworkAttached + numOfVfsHasVlanDeviceAttached + numOfVfsArePartOfBond;
List<HostDevice> vfs = mockVfsOnNetDevice(numOfVfs);
List<VdsNetworkInterface> nics = new ArrayList<>();
devices.addAll(vfs);
for (HostDevice vfPciDevice : vfs) {
HostDevice vfNetDevice = mockNetworkDeviceForPciDevice(vfPciDevice);
devices.add(vfNetDevice);
if (numOfVfsHasNoNic != 0) {
--numOfVfsHasNoNic;
} else {
VdsNetworkInterface vfNic = mockNicForNetDevice(vfNetDevice);
nics.add(vfNic);
if (numOfVfsAttachedToVm != 0) {
--numOfVfsAttachedToVm;
vfPciDevice.setVmId(Guid.newGuid());
} else if (numOfVfsHasNetworkAttached != 0) {
--numOfVfsHasNetworkAttached;
vfNic.setNetworkName("netName");
} else if (numOfVfsHasVlanDeviceAttached != 0) {
--numOfVfsHasVlanDeviceAttached;
doReturn(true).when(networkDeviceHelper).isVlanDeviceAttached(vfNic);
} else if (numOfVfsArePartOfBond != 0) {
--numOfVfsArePartOfBond;
vfNic.setBondName("bondName");
} else {
doReturn(false).when(networkDeviceHelper).isVlanDeviceAttached(vfNic);
freeVfs.add(vfPciDevice);
}
}
}
mockHostDevices(devices);
mockNics(nics, true);
return freeVfs;
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToNewSlave.
@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToNewSlave() {
HostSetupNetworksParameters params = createHostSetupNetworksParams();
VdsNetworkInterface slave = createNic();
CreateOrUpdateBond createOrUpdateBond = new CreateOrUpdateBond();
createOrUpdateBond.setName("bond");
createOrUpdateBond.setSlaves(Collections.singleton(slave.getName()));
params.setCreateOrUpdateBonds(Collections.singletonList(createOrUpdateBond));
assertLabelBeingAttachedToNonVlanNonSlaveInterfaceFailed(params, slave);
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NicLabelValidatorTest method createNic.
private VdsNetworkInterface createNic() {
VdsNetworkInterface nic = new VdsNetworkInterface();
nic.setId(Guid.newGuid());
nic.setName(nic.getId().toString());
return nic;
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class GetManagementInterfaceAddressByVmIdQueryTest method testExecuteQuery.
@Test
public void testExecuteQuery() {
Guid vmID = Guid.newGuid();
VM vm = new VM();
Guid vdsID = Guid.newGuid();
vm.setRunOnVds(vdsID);
VDS vds = new VDS();
vds.setId(vdsID);
VdsNetworkInterface managementInterface = new VdsNetworkInterface();
managementInterface.setIpv4Address("my_address");
IdQueryParameters paramsMock = getQueryParameters();
when(paramsMock.getId()).thenReturn(vmID);
when(vmDaoMock.get(vmID)).thenReturn(vm);
when(interfaceDaoMock.getManagedInterfaceForVds(vdsID, getUser().getId(), getQueryParameters().isFiltered())).thenReturn(managementInterface);
getQuery().executeQueryCommand();
String result = getQuery().getQueryReturnValue().getReturnValue();
assertEquals("Wrong address returned", "my_address", result);
}
Aggregations