Committed by
Gerrit Code Review
ONOS-3432 register Lambdas
Change-Id: I407e6dfcb3bcd73f16bdbba86d27eb4a5a4a32ff
Showing
1 changed file
with
25 additions
and
0 deletions
... | @@ -23,9 +23,11 @@ import org.onosproject.net.Device; | ... | @@ -23,9 +23,11 @@ import org.onosproject.net.Device; |
23 | import org.onosproject.net.DeviceId; | 23 | import org.onosproject.net.DeviceId; |
24 | import org.onosproject.net.Port; | 24 | import org.onosproject.net.Port; |
25 | import org.onosproject.net.OchPort; | 25 | import org.onosproject.net.OchPort; |
26 | +import org.onosproject.net.OchSignal; | ||
26 | import org.onosproject.net.PortNumber; | 27 | import org.onosproject.net.PortNumber; |
27 | import org.onosproject.net.TributarySlot; | 28 | import org.onosproject.net.TributarySlot; |
28 | import org.onosproject.net.OduSignalType; | 29 | import org.onosproject.net.OduSignalType; |
30 | +import org.onosproject.net.behaviour.LambdaQuery; | ||
29 | import org.onosproject.net.behaviour.MplsQuery; | 31 | import org.onosproject.net.behaviour.MplsQuery; |
30 | import org.onosproject.net.behaviour.VlanQuery; | 32 | import org.onosproject.net.behaviour.VlanQuery; |
31 | import org.onosproject.net.device.DeviceEvent; | 33 | import org.onosproject.net.device.DeviceEvent; |
... | @@ -37,7 +39,9 @@ import org.onosproject.net.newresource.ResourcePath; | ... | @@ -37,7 +39,9 @@ import org.onosproject.net.newresource.ResourcePath; |
37 | import org.slf4j.Logger; | 39 | import org.slf4j.Logger; |
38 | import org.slf4j.LoggerFactory; | 40 | import org.slf4j.LoggerFactory; |
39 | 41 | ||
42 | +import java.util.Collections; | ||
40 | import java.util.List; | 43 | import java.util.List; |
44 | +import java.util.SortedSet; | ||
41 | import java.util.concurrent.ExecutorService; | 45 | import java.util.concurrent.ExecutorService; |
42 | import java.util.stream.Collectors; | 46 | import java.util.stream.Collectors; |
43 | import java.util.stream.IntStream; | 47 | import java.util.stream.IntStream; |
... | @@ -123,6 +127,14 @@ final class ResourceDeviceListener implements DeviceListener { | ... | @@ -123,6 +127,14 @@ final class ResourceDeviceListener implements DeviceListener { |
123 | adminService.registerResources(Lists.transform(ENTIRE_MPLS_LABELS, portPath::child)); | 127 | adminService.registerResources(Lists.transform(ENTIRE_MPLS_LABELS, portPath::child)); |
124 | } | 128 | } |
125 | 129 | ||
130 | + // for Lambdas | ||
131 | + SortedSet<OchSignal> lambdas = queryLambdas(device.id(), port.number()); | ||
132 | + if (!lambdas.isEmpty()) { | ||
133 | + adminService.registerResources(lambdas.stream() | ||
134 | + .map(portPath::child) | ||
135 | + .collect(Collectors.toList())); | ||
136 | + } | ||
137 | + | ||
126 | // for Tributary slots | 138 | // for Tributary slots |
127 | // TODO: need to define Behaviour to make a query about OCh port | 139 | // TODO: need to define Behaviour to make a query about OCh port |
128 | switch (port.type()) { | 140 | switch (port.type()) { |
... | @@ -154,6 +166,19 @@ final class ResourceDeviceListener implements DeviceListener { | ... | @@ -154,6 +166,19 @@ final class ResourceDeviceListener implements DeviceListener { |
154 | executor.submit(() -> adminService.unregisterResources(resource)); | 166 | executor.submit(() -> adminService.unregisterResources(resource)); |
155 | } | 167 | } |
156 | 168 | ||
169 | + private SortedSet<OchSignal> queryLambdas(DeviceId did, PortNumber port) { | ||
170 | + try { | ||
171 | + DriverHandler handler = driverService.createHandler(did); | ||
172 | + if (handler == null) { | ||
173 | + return Collections.emptySortedSet(); | ||
174 | + } | ||
175 | + LambdaQuery query = handler.behaviour(LambdaQuery.class); | ||
176 | + return query.queryLambdas(port); | ||
177 | + } catch (ItemNotFoundException e) { | ||
178 | + return Collections.emptySortedSet(); | ||
179 | + } | ||
180 | + } | ||
181 | + | ||
157 | private boolean isVlanEnabled(DeviceId device, PortNumber port) { | 182 | private boolean isVlanEnabled(DeviceId device, PortNumber port) { |
158 | try { | 183 | try { |
159 | DriverHandler handler = driverService.createHandler(device); | 184 | DriverHandler handler = driverService.createHandler(device); | ... | ... |
-
Please register or login to post a comment