use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class VmDeviceCommonUtilsTest method createNetworkInterface.
private VmDevice createNetworkInterface(boolean plugged, String name, List<VmNetworkInterface> interfaces) {
Guid id = Guid.newGuid();
VmNetworkInterface vmNic = new VmNetworkInterface();
vmNic.setId(id);
vmNic.setName(name);
interfaces.add(vmNic);
VmDevice device = createNetworkInterfaceDevice(plugged, id);
device.setManaged(true);
return device;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class BackendVmNicResourceTest method setUpStatisticalExpectations.
protected VmNetworkInterface setUpStatisticalExpectations() throws Exception {
VmNetworkStatistics stats = mock(VmNetworkStatistics.class);
VmNetworkInterface entity = mock(VmNetworkInterface.class);
when(entity.getStatistics()).thenReturn(stats);
when(entity.getSpeed()).thenReturn(50);
when(entity.getId()).thenReturn(NIC_ID);
when(stats.getReceiveRate()).thenReturn(10D);
when(stats.getTransmitRate()).thenReturn(20D);
when(stats.getReceiveDropRate()).thenReturn(30D);
when(stats.getTransmitDropRate()).thenReturn(40D);
when(stats.getReceivedBytes()).thenReturn(50L);
when(stats.getTransmittedBytes()).thenReturn(60L);
List<VmNetworkInterface> ifaces = new ArrayList<>();
ifaces.add(entity);
setUpEntityQueryExpectations(QueryType.GetVmInterfacesByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { VM_ID }, ifaces);
return entity;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilderTest method validateVmNetworkInterfaceId.
private void validateVmNetworkInterfaceId(String nicId, Map<String, Object> vmStruct) {
List<VmNetworkInterface> vmNetworkInterfaceList = VdsBrokerObjectsBuilder.buildVmNetworkInterfacesFromDevices(vmStruct);
assertNotNull(vmNetworkInterfaceList);
assertEquals(1, vmNetworkInterfaceList.size());
VmNetworkInterface vmNetworkInterface = vmNetworkInterfaceList.get(0);
assertEquals(Guid.createGuidFromString(nicId), vmNetworkInterface.getId());
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class TemplateInterfaceListModel method edit.
private void edit() {
if (getWindow() != null) {
return;
}
VmInterfaceModel model = EditTemplateInterfaceModel.createInstance(getEntity(), getEntity().getStoragePoolId(), getEntity().getCompatibilityVersion(), (ArrayList<VmNetworkInterface>) getItems(), getSelectedItem(), this);
setWindow(model);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class FindActiveVmsUsingNetwork method findActiveVmsUsingNetworks.
private List<VM> findActiveVmsUsingNetworks(Guid vdsId, Collection<String> networks) {
if (networks.isEmpty()) {
return Collections.emptyList();
}
List<VM> runningVms = vmDao.getAllRunningForVds(vdsId);
List<VM> vms = new ArrayList<>();
for (VM vm : runningVms) {
List<VmNetworkInterface> vmInterfaces = vmNetworkInterfaceDao.getAllForVm(vm.getId());
for (VmNetworkInterface vmNic : vmInterfaces) {
boolean vmHasNetworkAttachedToPluggedNic = vmNic.isPlugged() && vmNic.getNetworkName() != null && networks.contains(vmNic.getNetworkName());
if (vmHasNetworkAttachedToPluggedNic) {
vms.add(vm);
break;
}
}
}
return vms;
}
Aggregations