aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/vtn
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-10-23 08:31:31 -0700
committerAshlee Young <ashlee@onosfw.com>2015-10-23 08:31:31 -0700
commite52e67767076b29cb01939aa7bdd8fee9d205cc1 (patch)
treeb8c2d28231bccc2a280fea429a9af7297c62f58f /framework/src/onos/apps/vtn
parenta912c5ce9968da5936a695064f22083898e7b93d (diff)
Update ONOS src to commit id 69b36d5d11e81e28e56b46ba44e4b8cd701c5867
Change-Id: I9c13045711dbf9c0181106b66a6bf22c72bcf330 Signed-off-by: Ashlee Young <ashlee@onosfw.com>
Diffstat (limited to 'framework/src/onos/apps/vtn')
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java9
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java23
2 files changed, 32 insertions, 0 deletions
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
index 05ebccf9..0a3ea2cd 100644
--- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
@@ -18,6 +18,7 @@ package org.onosproject.vtnrsc.virtualport;
import java.util.Collection;
import org.onosproject.net.DeviceId;
+import org.onosproject.vtnrsc.FixedIp;
import org.onosproject.vtnrsc.TenantId;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.VirtualPort;
@@ -44,6 +45,14 @@ public interface VirtualPortService {
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.
* @return collection of VirtualPort.
*/
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
index 926809c9..c45373b9 100644
--- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
@@ -17,9 +17,12 @@ package org.onosproject.vtnrsc.virtualport.impl;
import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
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 NETWORKID_NOT_NULL = "NetworkId 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 ApplicationId appId;
@@ -125,6 +129,25 @@ public class VirtualPortManager implements VirtualPortService {
}
@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
public Collection<VirtualPort> getPorts() {
return Collections.unmodifiableCollection(vPortStore.values());
}