mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-23 21:31:00 +02:00
[ONOS-3188] Add the method: Returns the virtualPort associated with the
fixedIP. Change-Id: I4f66287a4186cc103070c9182dae64f81fcd6488
This commit is contained in:
parent
3e594649d5
commit
69b36d5d11
@ -18,6 +18,7 @@ package org.onosproject.vtnrsc.virtualport;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.onosproject.net.DeviceId;
|
import org.onosproject.net.DeviceId;
|
||||||
|
import org.onosproject.vtnrsc.FixedIp;
|
||||||
import org.onosproject.vtnrsc.TenantId;
|
import org.onosproject.vtnrsc.TenantId;
|
||||||
import org.onosproject.vtnrsc.TenantNetworkId;
|
import org.onosproject.vtnrsc.TenantNetworkId;
|
||||||
import org.onosproject.vtnrsc.VirtualPort;
|
import org.onosproject.vtnrsc.VirtualPort;
|
||||||
@ -43,6 +44,14 @@ public interface VirtualPortService {
|
|||||||
*/
|
*/
|
||||||
VirtualPort getPort(VirtualPortId virtualPortId);
|
VirtualPort getPort(VirtualPortId virtualPortId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the virtualPort associated with the fixedIP.
|
||||||
|
*
|
||||||
|
* @param fixedIP the fixedIP identifier
|
||||||
|
* @return virtualPort.
|
||||||
|
*/
|
||||||
|
VirtualPort getPort(FixedIp fixedIP);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the collection of the currently known virtualPort.
|
* Returns the collection of the currently known virtualPort.
|
||||||
* @return collection of VirtualPort.
|
* @return collection of VirtualPort.
|
||||||
|
@ -17,9 +17,12 @@ package org.onosproject.vtnrsc.virtualport.impl;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -68,6 +71,7 @@ public class VirtualPortManager implements VirtualPortService {
|
|||||||
private static final String TENANTID_NOT_NULL = "TenantId cannot be null";
|
private static final String TENANTID_NOT_NULL = "TenantId cannot be null";
|
||||||
private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
|
private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
|
||||||
private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
|
private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
|
||||||
|
private static final String FIXEDIP_NOT_NULL = "FixedIp cannot be null";
|
||||||
|
|
||||||
protected Map<VirtualPortId, VirtualPort> vPortStore;
|
protected Map<VirtualPortId, VirtualPort> vPortStore;
|
||||||
protected ApplicationId appId;
|
protected ApplicationId appId;
|
||||||
@ -124,6 +128,25 @@ public class VirtualPortManager implements VirtualPortService {
|
|||||||
return vPortStore.get(vPortId);
|
return vPortStore.get(vPortId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VirtualPort getPort(FixedIp fixedIP) {
|
||||||
|
checkNotNull(fixedIP, FIXEDIP_NOT_NULL);
|
||||||
|
List<VirtualPort> vPorts = new ArrayList<>();
|
||||||
|
vPortStore.values().stream().forEach(p -> {
|
||||||
|
Iterator<FixedIp> fixedIps = p.fixedIps().iterator();
|
||||||
|
while (fixedIps.hasNext()) {
|
||||||
|
if (fixedIps.next().equals(fixedIP)) {
|
||||||
|
vPorts.add(p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (vPorts.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return vPorts.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<VirtualPort> getPorts() {
|
public Collection<VirtualPort> getPorts() {
|
||||||
return Collections.unmodifiableCollection(vPortStore.values());
|
return Collections.unmodifiableCollection(vPortStore.values());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user