Permalink
Browse files

get tetunnel by tetunnelKey string

for the relationship of tunnel id and tetunnelKey will created after tunnel setup so in the setup process, we can't get tetunnel by tunnel id, now we use tetunnelKey in tunnel annotations to get the tetunnel

Change-Id: I2551766bdeaa13a0d1c3582141322d0c3f50790a
  • Loading branch information...
1 parent 03265dd commit 6c240ab4698d2db801fba670416074c65a06f1e2 @chengfannature chengfannature committed with jonohart Dec 30, 2016
@@ -54,7 +54,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.ws.rs.core.MediaType;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
@@ -95,6 +94,7 @@
private static final String SHOULD_IN_ONE = "Tunnel should be setup in one topo";
private static final String PROVIDER_ID = "org.onosproject.provider.ietf";
private static final String RESTCONF_ROOT = "/onos/restconf";
+ private static final String TE_TUNNEL_KEY = "TeTunnelKey";
private final RestConfNotificationEventListener listener =
new InternalTunnelNotificationListener();
@@ -192,9 +192,24 @@ public void setupTunnel(Tunnel tunnel, Path path) {
@Override
public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
- TeTunnel teTunnel = tunnelService.getTeTunnel(tunnel.tunnelId());
+ if (!tunnel.annotations().keys().contains(TE_TUNNEL_KEY)) {
+ log.warn("No tunnel key info in tunnel {}", tunnel);
+ return;
+ }
+
+ String teTunnelKey = tunnel.annotations().value(TE_TUNNEL_KEY);
+
+ Optional<TeTunnel> optTunnel = tunnelService.getTeTunnels()
+ .stream()
+ .filter(t -> t.teTunnelKey().toString().equals(teTunnelKey))
+ .findFirst();
+
+ if (!optTunnel.isPresent()) {
+ log.warn("No te tunnel map to tunnel {}", tunnel);
+ return;
+ }
- IetfTe ietfTe = buildIetfTe(teTunnel);
+ IetfTe ietfTe = buildIetfTe(optTunnel.get());
YangCompositeEncoding encoding = codecHandler.
encodeCompositeOperation(RESTCONF_ROOT, null, ietfTe,
@@ -208,7 +223,7 @@ public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
}
controller.post((DeviceId) srcElement, identifier,
new ByteArrayInputStream(resourceInformation.getBytes()),
- MediaType.APPLICATION_JSON, ObjectNode.class);
+ MEDIA_TYPE_JSON, ObjectNode.class);
}
@Override

0 comments on commit 6c240ab

Please sign in to comment.