protected <T> boolean matchEntity(VmNetworkInterface entity, T id) { return id != null && id.equals(entity.getId()); }
private static List<VmDevice> sortInterfacesByName(List<VmDevice> pluggedInterfaces, List<VmNetworkInterface> interfaces) { if (pluggedInterfaces.size() < 2) { return pluggedInterfaces; } final Map<Guid, String> deviceIdToIfaceName = new HashMap<>(); for (VmNetworkInterface iface : interfaces) { deviceIdToIfaceName.put(iface.getId(), iface.getName()); } Collections.sort(pluggedInterfaces, Comparator.comparing(d -> deviceIdToIfaceName.get(d.getId().getDeviceId()))); return pluggedInterfaces; }
private VmNetworkInterface lookupNic(Guid nicId) { List<VmNetworkInterface> nics = getBackendCollection( VmNetworkInterface.class, QueryType.GetVmInterfacesByVmId, new IdQueryParameters(vmId) ); for (VmNetworkInterface nic : nics) { if (Objects.equals(nic.getId(), nicId)) { return nic; } } return null; }
private VmNetworkInterface lookupNic(Guid nicId) { List<VmNetworkInterface> nics = getBackendCollection( VmNetworkInterface.class, QueryType.GetTemplateInterfacesByTemplateId, new IdQueryParameters(instanceTypeId) ); for (VmNetworkInterface nic : nics) { if (Objects.equals(nic.getId(), guid)) { return nic; } } return null; }
private VmNetworkInterface lookupNic(Guid nicId) { List<VmNetworkInterface> nics = getBackendCollection( VmNetworkInterface.class, QueryType.GetTemplateInterfacesByTemplateId, new IdQueryParameters(templateId) ); for (VmNetworkInterface nic : nics) { if (Objects.equals(nic.getId(), nicId)) { return nic; } } return null; }
@Override protected ActionParametersBase getRemoveVmInterfaceParams(VmNetworkInterface vnic) { return new RemoveVmTemplateInterfaceParameters(vnic.getVmTemplateId(), vnic.getId()); }
protected ActionParametersBase getRemoveVmInterfaceParams(VmNetworkInterface vnic) { return new RemoveVmInterfaceParameters(vnic.getVmId(), vnic.getId()); }
private void updateNetworkFilterParameterMap(List<VmNetworkInterface> vmInterfaces) { List<QueryType> queryTypes = new ArrayList<>(); List<QueryParametersBase> queryParametersBases = new ArrayList<>(); vmInterfaces.stream().forEach(iface -> { queryTypes.add(QueryType.GetVmInterfaceFilterParametersByVmInterfaceId); queryParametersBases.add(new IdQueryParameters(iface.getId())); }); final IFrontendMultipleQueryAsyncCallback callback = multiResult -> { Map<Guid, List<VmNicFilterParameter>> networkFilterMap = new HashMap<>(vmInterfaces.size()); for (int i = 0; i < multiResult.getReturnValues().size(); i++) { List<VmNicFilterParameter> params = multiResult.getReturnValues().get(i).getReturnValue(); networkFilterMap.put(vmInterfaces.get(i).getId(), params); } setMapNicFilterParameter(networkFilterMap); setItems(vmInterfaces); }; if (vmInterfaces.isEmpty()) { setItems(vmInterfaces); } Frontend.getInstance().runMultipleQueries(queryTypes, queryParametersBases, callback); }
protected void initNetworkFilterParameters(AsyncQuery<List<NetworkFilterParameterModel>> aQuery) { aQuery.converterCallback = returnValue -> { List<NetworkFilterParameterModel> parameters = new ArrayList<>(); if (returnValue == null) { return parameters; } for (VmNicFilterParameter parameter : (List<VmNicFilterParameter>) returnValue) { parameters.add(new NetworkFilterParameterModel(parameter)); } return parameters; }; AsyncDataProvider.getInstance().getVnicInteraceNetworkFilterParameters(aQuery, getNic().getId()); } }
private VmNetworkInterface setUpNicExpectations() { VmNetworkInterface nic = mock(VmNetworkInterface.class); when(nic.getId()).thenReturn(NIC_ID); when(nic.getType()).thenReturn(0); return nic; } }
private VmNetworkInterface setUpNicExpectations() { VmNetworkInterface nic = mock(VmNetworkInterface.class); when(nic.getId()).thenReturn(NIC_ID); when(nic.getType()).thenReturn(0); return nic; } }
private void readNetworkItem(XmlNode node, int nicIdx) { VmNetworkInterface iface = getNetworkInterface(node); updateSingleNic(node, iface, nicIdx); readManagedVmDevice(node, iface.getId()); }
@Override protected VmNetworkInterface getNetworkInterface(XmlNode node) { // prior to 3.0 the instanceId is int , in 3.1 and on this is Guid String str = selectSingleNode(node, "rasd:InstanceId", _xmlNS).innerText; if (!StringUtils.isNumeric(str)) { // 3.1 and above OVF format final Guid guid = new Guid(str); VmNetworkInterface iface = interfaces.stream().filter(i -> i.getId().equals(guid)).findFirst().orElse(null); if (iface == null) { iface = new VmNetworkInterface(); iface.setId(guid); interfaces.add(iface); } return iface; } else { // 3.0 and below OVF format VmNetworkInterface iface = new VmNetworkInterface(); iface.setId(Guid.newGuid()); interfaces.add(iface); return iface; } }
static VmNetworkInterface setUpEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics, int index, String networkName) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmId()).thenReturn(VM_ID); when(entity.getNetworkName()).thenReturn(networkName); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getMacAddress()).thenReturn(ADDRESSES[2]); when(entity.getType()).thenReturn(0); when(entity.getSpeed()).thenReturn(50); return setUpStatisticalEntityExpectations(entity, statistics); }
static VmNetworkInterface setUpEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics, int index, String networkName) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmId()).thenReturn(VM_ID); when(entity.getNetworkName()).thenReturn(networkName); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getMacAddress()).thenReturn(ADDRESSES[2]); when(entity.getType()).thenReturn(0); when(entity.getSpeed()).thenReturn(50); return setUpStatisticalEntityExpectations(entity, statistics); }
private VmNetworkInterface setUpEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics, int index, String networkName) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmId()).thenReturn(VM_ID); when(entity.getNetworkName()).thenReturn(networkName); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getMacAddress()).thenReturn(ADDRESSES[2]); when(entity.getType()).thenReturn(0); when(entity.getSpeed()).thenReturn(50); return setUpStatisticalEntityExpectations(entity, statistics); }
static VmNetworkInterface setUpEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics, int index, String networkName) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmId()).thenReturn(INSTANCE_TYPE_ID); when(entity.getNetworkName()).thenReturn(networkName); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getMacAddress()).thenReturn(ADDRESSES[2]); when(entity.getType()).thenReturn(0); when(entity.getSpeed()).thenReturn(50); return setUpStatisticalEntityExpectations(entity, statistics); }
/** * Ensures that the network interface is returned. */ @Test public void testGet() { VmNetworkInterface result = dao.get(FixturesTool.VM_NETWORK_INTERFACE); assertNotNull(result); assertEquals(FixturesTool.VM_NETWORK_INTERFACE, result.getId()); }
public VmNetworkInterface(VmNetworkInterface iface) { setId(iface.getId()); setMacAddress(iface.getMacAddress()); setName(iface.getName()); setNetworkName(iface.getNetworkName()); setLinked(iface.isLinked()); setSpeed(iface.getSpeed()); setType(iface.getType()); setVmId(iface.getVmId()); setVmName(iface.getVmName()); setVmTemplateId(iface.getVmTemplateId()); setStatistics(new VmNetworkStatistics(iface.getStatistics())); }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("id", getId()) .append("name", getName()) .append("networkName", getNetworkName()) .append("vnicProfileName", getVnicProfileName()) .append("vnicProfileId", getVnicProfileId()) .append("speed", getSpeed()) .append("type", getType()) .append("macAddress", getMacAddress()) .append("active", isPlugged()) .append("linked", isLinked()) .append("portMirroring", isPortMirroring()) .append("vmId", getVmId()) .append("vmName", getVmName()) .append("vmTemplateId", getVmTemplateId()) .append("QoSName", getQosName()) .append("remoteNetworkName", getRemoteNetworkName()) .build(); }