Committed by
Jonathan Hart
[ONOS-4895] Add a method to get VirtualPort based on mac
Change-Id: I3cd6c1ce43f33315f6b73342c6f6393376fff8de
Showing
3 changed files
with
32 additions
and
0 deletions
... | @@ -20,6 +20,7 @@ import java.util.concurrent.ConcurrentHashMap; | ... | @@ -20,6 +20,7 @@ import java.util.concurrent.ConcurrentHashMap; |
20 | import java.util.concurrent.ConcurrentMap; | 20 | import java.util.concurrent.ConcurrentMap; |
21 | 21 | ||
22 | import org.onlab.packet.IpAddress; | 22 | import org.onlab.packet.IpAddress; |
23 | +import org.onlab.packet.MacAddress; | ||
23 | import org.onosproject.net.DeviceId; | 24 | import org.onosproject.net.DeviceId; |
24 | import org.onosproject.vtnrsc.FixedIp; | 25 | import org.onosproject.vtnrsc.FixedIp; |
25 | import org.onosproject.vtnrsc.TenantId; | 26 | import org.onosproject.vtnrsc.TenantId; |
... | @@ -52,6 +53,11 @@ public class VirtualPortAdapter implements VirtualPortService { | ... | @@ -52,6 +53,11 @@ public class VirtualPortAdapter implements VirtualPortService { |
52 | } | 53 | } |
53 | 54 | ||
54 | @Override | 55 | @Override |
56 | + public VirtualPort getPort(MacAddress mac) { | ||
57 | + return null; | ||
58 | + } | ||
59 | + | ||
60 | + @Override | ||
55 | public Collection<VirtualPort> getPorts() { | 61 | public Collection<VirtualPort> getPorts() { |
56 | return null; | 62 | return null; |
57 | } | 63 | } | ... | ... |
... | @@ -18,6 +18,7 @@ package org.onosproject.vtnrsc.virtualport; | ... | @@ -18,6 +18,7 @@ package org.onosproject.vtnrsc.virtualport; |
18 | import java.util.Collection; | 18 | import java.util.Collection; |
19 | 19 | ||
20 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
21 | +import org.onlab.packet.MacAddress; | ||
21 | import org.onosproject.event.ListenerService; | 22 | import org.onosproject.event.ListenerService; |
22 | import org.onosproject.net.DeviceId; | 23 | import org.onosproject.net.DeviceId; |
23 | import org.onosproject.vtnrsc.FixedIp; | 24 | import org.onosproject.vtnrsc.FixedIp; |
... | @@ -55,6 +56,14 @@ public interface VirtualPortService extends ListenerService<VirtualPortEvent, Vi | ... | @@ -55,6 +56,14 @@ public interface VirtualPortService extends ListenerService<VirtualPortEvent, Vi |
55 | VirtualPort getPort(FixedIp fixedIP); | 56 | VirtualPort getPort(FixedIp fixedIP); |
56 | 57 | ||
57 | /** | 58 | /** |
59 | + * Returns the virtualPort associated with the mac address. | ||
60 | + * | ||
61 | + * @param mac the mac address | ||
62 | + * @return virtualPort. | ||
63 | + */ | ||
64 | + VirtualPort getPort(MacAddress mac); | ||
65 | + | ||
66 | + /** | ||
58 | * Returns the virtualPort associated with the networkId and ip. | 67 | * Returns the virtualPort associated with the networkId and ip. |
59 | * | 68 | * |
60 | * @param networkId the TenantNetworkId identifier | 69 | * @param networkId the TenantNetworkId identifier | ... | ... |
... | @@ -31,6 +31,7 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -31,6 +31,7 @@ import org.apache.felix.scr.annotations.Reference; |
31 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 31 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
32 | import org.apache.felix.scr.annotations.Service; | 32 | import org.apache.felix.scr.annotations.Service; |
33 | import org.onlab.packet.IpAddress; | 33 | import org.onlab.packet.IpAddress; |
34 | +import org.onlab.packet.MacAddress; | ||
34 | import org.onlab.util.KryoNamespace; | 35 | import org.onlab.util.KryoNamespace; |
35 | import org.onosproject.core.ApplicationId; | 36 | import org.onosproject.core.ApplicationId; |
36 | import org.onosproject.core.CoreService; | 37 | import org.onosproject.core.CoreService; |
... | @@ -79,6 +80,7 @@ implements VirtualPortService { | ... | @@ -79,6 +80,7 @@ implements VirtualPortService { |
79 | private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null"; | 80 | private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null"; |
80 | private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null"; | 81 | private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null"; |
81 | private static final String FIXEDIP_NOT_NULL = "FixedIp cannot be null"; | 82 | private static final String FIXEDIP_NOT_NULL = "FixedIp cannot be null"; |
83 | + private static final String MAC_NOT_NULL = "Mac address cannot be null"; | ||
82 | private static final String IP_NOT_NULL = "Ip cannot be null"; | 84 | private static final String IP_NOT_NULL = "Ip cannot be null"; |
83 | private static final String EVENT_NOT_NULL = "event cannot be null"; | 85 | private static final String EVENT_NOT_NULL = "event cannot be null"; |
84 | 86 | ||
... | @@ -164,6 +166,21 @@ implements VirtualPortService { | ... | @@ -164,6 +166,21 @@ implements VirtualPortService { |
164 | } | 166 | } |
165 | 167 | ||
166 | @Override | 168 | @Override |
169 | + public VirtualPort getPort(MacAddress mac) { | ||
170 | + checkNotNull(mac, MAC_NOT_NULL); | ||
171 | + List<VirtualPort> vPorts = new ArrayList<>(); | ||
172 | + vPortStore.values().stream().forEach(p -> { | ||
173 | + if (p.macAddress().equals(mac)) { | ||
174 | + vPorts.add(p); | ||
175 | + } | ||
176 | + }); | ||
177 | + if (vPorts.size() == 0) { | ||
178 | + return null; | ||
179 | + } | ||
180 | + return vPorts.get(0); | ||
181 | + } | ||
182 | + | ||
183 | + @Override | ||
167 | public VirtualPort getPort(TenantNetworkId networkId, IpAddress ip) { | 184 | public VirtualPort getPort(TenantNetworkId networkId, IpAddress ip) { |
168 | checkNotNull(networkId, NETWORKID_NOT_NULL); | 185 | checkNotNull(networkId, NETWORKID_NOT_NULL); |
169 | checkNotNull(ip, IP_NOT_NULL); | 186 | checkNotNull(ip, IP_NOT_NULL); | ... | ... |
-
Please register or login to post a comment