use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class VmInterfaceManagerTest method removeAll.
@Test
public void removeAll() {
List<VmNic> interfaces = Arrays.asList(createNewInterface(), createNewInterface());
when(vmNicDao.getAllForVm(any())).thenReturn(interfaces);
vmInterfaceManager.removeAllAndReleaseMacAddresses(Guid.newGuid());
for (VmNic iface : interfaces) {
verify(vmNicDao).remove(iface.getId());
verify(vmNetworkStatisticsDao).remove(iface.getId());
}
verify(macPool).freeMacs(interfaces.stream().map(VmNic::getMacAddress).collect(Collectors.toList()));
}
use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class MacsUsedAcrossWholeSystemTest method createVm.
private VM createVm(Cluster cluster, Guid vmId, boolean running, boolean stateless, VmNetworkInterface... nics) {
VM vm = new VM();
vm.setId(vmId);
vm.setInterfaces(new ArrayList<>(Arrays.asList(nics)));
vm.setClusterId(cluster.getId());
vm.setStatus(running ? VMStatus.Up : VMStatus.Down);
vm.setStateless(stateless);
when(vmNicDao.<VmNic>getAllForVm(vm.getId())).<VmNic>thenReturn(new ArrayList<>(vm.getInterfaces()));
return vm;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class HotPlugOrUnplugNicVDSCommand method initNicStructure.
private Map<String, Object> initNicStructure() {
Map<String, Object> map = new HashMap<>();
VmNic nic = getParameters().getNic();
VmDevice vmDevice = getParameters().getVmDevice();
VM vm = getParameters().getVm();
if (!nic.isPassthrough()) {
map.put(VdsProperties.Type, vmDevice.getType().getValue());
map.put(VdsProperties.Device, VmDeviceType.BRIDGE.getName());
map.put(VdsProperties.MAC_ADDR, nic.getMacAddress());
map.put(VdsProperties.LINK_ACTIVE, String.valueOf(nic.isLinked()));
if (StringUtils.isNotBlank(vmDevice.getAddress())) {
map.put(VdsProperties.Address, StringMapUtils.string2Map(getParameters().getVmDevice().getAddress()));
}
map.put(VdsProperties.SpecParams, vmDevice.getSpecParams());
map.put(VdsProperties.NIC_TYPE, vmInfoBuildUtils.evaluateInterfaceType(VmInterfaceType.forValue(nic.getType()), vm.getHasAgent()));
map.put(VdsProperties.DeviceId, vmDevice.getId().getDeviceId().toString());
vmInfoBuildUtils.addProfileDataToNic(map, vm, vmDevice, nic);
vmInfoBuildUtils.addNetworkFiltersToNic(map, nic);
} else {
vmInfoBuildUtils.addNetworkVirtualFunctionProperties(map, nic, vmDevice, vmDevice.getHostDevice(), vm);
}
return map;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class UpdateVmInterfaceVDSCommand method initDeviceStructure.
protected Map<String, Object> initDeviceStructure() {
Map<String, Object> deviceStruct = new HashMap<>();
deviceStruct.put(VdsProperties.DeviceType, getParameters().getVmDevice().getType().getValue());
deviceStruct.put(VdsProperties.Alias, getParameters().getVmDevice().getAlias());
VmNic nic = getParameters().getNic();
deviceStruct.put(VdsProperties.LINK_ACTIVE, String.valueOf(nic.isLinked()));
VmDevice vmDevice = getParameters().getVmDevice();
vmInfoBuildUtils.addProfileDataToNic(deviceStruct, getParameters().getVm(), vmDevice, nic);
return deviceStruct;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class VmInfoBuildUtilsTest method testAddNetworkFiltersToNic.
@Test
public void testAddNetworkFiltersToNic() {
Map<String, Object> struct = new HashMap<>();
VmNic vmNic = new VmNic();
vmNic.setVnicProfileId(VNIC_PROFILE_ID);
vmNic.setId(VM_NIC_ID);
underTest.addNetworkFiltersToNic(struct, vmNic);
List<Map<String, Object>> parametersList = (List<Map<String, Object>>) struct.get(VdsProperties.NETWORK_FILTER_PARAMETERS);
assertNotNull(struct.get(VdsProperties.NW_FILTER));
assertEquals(struct.get(VdsProperties.NW_FILTER), NETWORK_FILTER_NAME);
assertNotNull(parametersList);
assertEquals(2, parametersList.size());
assertEquals(NETWORK_FILTER_PARAMETER_0_NAME, parametersList.get(0).get("name"));
assertEquals(NETWORK_FILTER_PARAMETER_0_VALUE, parametersList.get(0).get("value"));
assertEquals(NETWORK_FILTER_PARAMETER_1_NAME, parametersList.get(1).get("name"));
assertEquals(NETWORK_FILTER_PARAMETER_1_VALUE, parametersList.get(1).get("value"));
}
Aggregations