2 * Copyright © 2021 Nokia, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.tapi.utils;
10 import java.nio.charset.Charset;
11 import java.util.HashMap;
13 import java.util.Optional;
14 import java.util.UUID;
15 import java.util.concurrent.ExecutionException;
16 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
17 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
18 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Context;
19 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder;
20 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
21 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
22 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
23 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
24 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
25 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1;
26 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1Builder;
27 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.OwnedNodeEdgePoint1;
28 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.OwnedNodeEdgePoint1Builder;
29 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPoint;
30 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey;
31 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection;
32 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey;
33 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService;
34 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceKey;
35 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContextBuilder;
36 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepList;
37 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder;
38 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext;
39 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContextBuilder;
40 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
41 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
42 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
43 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
44 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
45 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node;
46 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.NwTopologyServiceBuilder;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
51 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
52 import org.slf4j.Logger;
53 import org.slf4j.LoggerFactory;
55 public class TapiContext {
57 private static final Logger LOG = LoggerFactory.getLogger(TapiContext.class);
58 public static final String TAPI_CONTEXT = "T-API context";
59 public static final String NODE_NOT_PRESENT = "Node is not present in datastore";
60 private final NetworkTransactionService networkTransactionService;
62 public TapiContext(NetworkTransactionService networkTransactionService) {
63 this.networkTransactionService = networkTransactionService;
67 private void createTapiContext() {
69 // Augmenting tapi context to include topology and connectivity contexts
70 Name contextName = new NameBuilder().setValue(TAPI_CONTEXT).setValueName("TAPI Context Name").build();
72 Context1 connectivityContext =
74 .setConnectivityContext(
75 new ConnectivityContextBuilder()
76 .setConnection(new HashMap<>())
77 .setConnectivityService(new HashMap<>())
81 Name nwTopoServiceName =
83 .setValue("Network Topo Service")
84 .setValueName("Network Topo Service Name")
87 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1 topologyContext
88 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1Builder()
89 .setTopologyContext(new TopologyContextBuilder()
90 .setNwTopologyService(new NwTopologyServiceBuilder()
91 .setTopology(new HashMap<>())
94 UUID.nameUUIDFromBytes("Network Topo Service".getBytes(Charset.forName("UTF-8")))
96 .setName(Map.of(nwTopoServiceName.key(), nwTopoServiceName))
98 .setTopology(new HashMap<>())
102 ContextBuilder contextBuilder = new ContextBuilder()
103 .setName(Map.of(contextName.key(), contextName))
105 new Uuid(UUID.nameUUIDFromBytes(TAPI_CONTEXT.getBytes(Charset.forName("UTF-8"))).toString()))
106 .setServiceInterfacePoint(new HashMap<>())
107 .addAugmentation(connectivityContext)
108 .addAugmentation(topologyContext);
110 // todo: add notification context
111 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
113 this.networkTransactionService.put(LogicalDatastoreType.OPERATIONAL, contextIID, contextBuilder.build());
114 this.networkTransactionService.commit().get();
115 LOG.info("TAPI context created successfully.");
116 } catch (InterruptedException | ExecutionException e) {
117 LOG.error("Failed to create TAPI context", e);
121 public Context getTapiContext() {
122 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
123 // There is no Identifiable in Context model
124 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
126 Optional<Context> optionalContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
128 if (!optionalContext.isPresent()) {
129 LOG.error("Tapi context is not present in datastore");
132 return optionalContext.get();
133 } catch (InterruptedException | ExecutionException e) {
134 LOG.error("Couldnt read tapi context from datastore", e);
139 public void deleteTapiContext() {
143 public void updateTopologyContext(Map<TopologyKey, Topology> topologyMap) {
144 // TODO: solve error when merging: Topology is not a valid child of topology context?
145 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
147 TopologyContext topologyContext = new TopologyContextBuilder()
148 //.setNwTopologyService(new NwTopologyServiceBuilder().build())
149 .setTopology(topologyMap)
151 InstanceIdentifier<TopologyContext> topologycontextIID =
152 InstanceIdentifier.builder(Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
153 .onf.otcc.yang.tapi.topology.rev181210.Context1.class)
154 .child(TopologyContext.class)
156 // merge in datastore
157 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topologycontextIID,
159 this.networkTransactionService.commit().get();
160 LOG.info("TAPI topology merged successfully.");
161 } catch (InterruptedException | ExecutionException e) {
162 LOG.error("Failed to merge TAPI topology", e);
166 public void updateSIPContext(Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap) {
167 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
169 ContextBuilder contextBuilder = new ContextBuilder().setServiceInterfacePoint(sipMap);
170 InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
171 // merge in datastore
172 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, contextIID,
173 contextBuilder.build());
174 this.networkTransactionService.commit().get();
175 LOG.info("TAPI SIPs merged successfully.");
176 } catch (InterruptedException | ExecutionException e) {
177 LOG.error("Failed to merge TAPI SIPs", e);
181 public void updateConnectivityContext(Map<ConnectivityServiceKey, ConnectivityService> connServMap,
182 Map<ConnectionKey, Connection> connectionFullMap) {
183 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
185 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext
186 connectivityContext = new ConnectivityContextBuilder()
187 .setConnectivityService(connServMap)
188 .setConnection(connectionFullMap)
190 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
191 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext> connectivitycontextIID =
192 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
193 .child(org.opendaylight.yang.gen.v1.urn
194 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
196 // merge in datastore
197 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivitycontextIID,
198 connectivityContext);
199 this.networkTransactionService.commit().get();
200 LOG.info("TAPI connectivity merged successfully.");
201 } catch (InterruptedException | ExecutionException e) {
202 LOG.error("Failed to merge TAPI connectivity", e);
206 public void updateTopologyWithCep(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, ConnectionEndPoint cep) {
207 // TODO: verify this is correct. Should we identify the context IID with the context UUID??
208 InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
209 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
210 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
211 .child(Topology.class, new TopologyKey(topoUuid))
212 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
213 new NodeKey(nodeUuid))
214 .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid))
217 Optional<OwnedNodeEdgePoint> optionalOnep = this.networkTransactionService.read(
218 LogicalDatastoreType.OPERATIONAL, onepIID).get();
219 if (!optionalOnep.isPresent()) {
220 LOG.error("ONEP is not present in datastore");
223 OwnedNodeEdgePoint onep = optionalOnep.get();
224 LOG.info("ONEP found = {}", onep);
225 // TODO -> If cep exists -> skip merging to datasore
226 OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class);
227 if (onep1 != null && onep1.getCepList() != null && onep1.getCepList().getConnectionEndPoint() != null
228 && onep1.getCepList().getConnectionEndPoint().containsKey(new ConnectionEndPointKey(cep.key()))) {
229 LOG.info("CEP already in topology, skipping merge");
233 CepList cepList = new CepListBuilder().setConnectionEndPoint(Map.of(cep.key(), cep)).build();
234 OwnedNodeEdgePoint1 onep1Bldr = new OwnedNodeEdgePoint1Builder().setCepList(cepList).build();
235 OwnedNodeEdgePoint newOnep = new OwnedNodeEdgePointBuilder(onep)
236 .addAugmentation(onep1Bldr)
238 LOG.info("New ONEP is {}", newOnep);
239 // merge in datastore
240 this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID,
242 this.networkTransactionService.commit().get();
243 LOG.info("CEP added successfully.");
244 } catch (InterruptedException | ExecutionException e) {
245 LOG.error("Couldnt update cep in topology", e);
249 public Node getTapiNode(Uuid topoUuid, Uuid nodeUuid) {
250 InstanceIdentifier<Node> nodeIID = InstanceIdentifier.builder(Context.class)
251 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
252 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
253 .child(Topology.class, new TopologyKey(topoUuid))
254 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
255 new NodeKey(nodeUuid)).build();
257 Optional<Node> optNode = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID)
259 if (!optNode.isPresent()) {
260 LOG.error(NODE_NOT_PRESENT);
263 // TODO -> Need to remove CEPs from NEPs. If not error from get Topology details output
264 Node node = optNode.get();
265 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
266 for (OwnedNodeEdgePoint onep: node.getOwnedNodeEdgePoint().values()) {
267 if (onep.augmentation(OwnedNodeEdgePoint1.class) == null) {
268 onepMap.put(onep.key(), onep);
271 OwnedNodeEdgePointBuilder newOnepBuilder = new OwnedNodeEdgePointBuilder()
272 .setUuid(onep.getUuid())
273 .setLayerProtocolName(onep.getLayerProtocolName())
274 .setName(onep.getName())
275 .setSupportedCepLayerProtocolQualifier(onep.getSupportedCepLayerProtocolQualifier())
276 .setAdministrativeState(onep.getAdministrativeState())
277 .setOperationalState(onep.getOperationalState())
278 .setLifecycleState(onep.getLifecycleState())
279 .setTerminationDirection(onep.getTerminationDirection())
280 .setTerminationState(onep.getTerminationState())
281 .setLinkPortDirection(onep.getLinkPortDirection())
282 .setLinkPortRole(onep.getLinkPortRole());
283 if (onep.getMappedServiceInterfacePoint() != null) {
284 newOnepBuilder.setMappedServiceInterfacePoint(onep.getMappedServiceInterfacePoint());
286 onepMap.put(newOnepBuilder.key(), newOnepBuilder.build());
288 return new NodeBuilder(node)
289 .setOwnedNodeEdgePoint(onepMap)
291 } catch (InterruptedException | ExecutionException e) {
292 LOG.error("Couldnt read node in topology", e);
297 public OwnedNodeEdgePoint getTapiNEP(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid) {
298 InstanceIdentifier<OwnedNodeEdgePoint> nepIID = InstanceIdentifier.builder(Context.class)
299 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
300 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
301 .child(Topology.class, new TopologyKey(topoUuid))
302 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
303 new NodeKey(nodeUuid)).child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid)).build();
305 Optional<OwnedNodeEdgePoint> optNode = this.networkTransactionService
306 .read(LogicalDatastoreType.OPERATIONAL, nepIID)
308 if (!optNode.isPresent()) {
309 LOG.error(NODE_NOT_PRESENT);
312 return optNode.get();
313 } catch (InterruptedException | ExecutionException e) {
314 LOG.error("Couldnt read NEP in topology", e);
319 public Link getTapiLink(Uuid topoUuid, Uuid linkUuid) {
320 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
321 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
322 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
323 .child(Topology.class, new TopologyKey(topoUuid))
324 .child(Link.class, new LinkKey(linkUuid)).build();
326 Optional<Link> optLink = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, linkIID)
328 if (!optLink.isPresent()) {
329 LOG.error(NODE_NOT_PRESENT);
332 return optLink.get();
333 } catch (InterruptedException | ExecutionException e) {
334 LOG.error("Couldnt read link in topology", e);
339 public Map<TopologyKey, Topology> getTopologyContext() {
340 InstanceIdentifier<TopologyContext> topologycontextIID =
341 InstanceIdentifier.builder(Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
342 .onf.otcc.yang.tapi.topology.rev181210.Context1.class)
343 .child(TopologyContext.class)
346 Optional<TopologyContext> optTopoContext = this.networkTransactionService.read(
347 LogicalDatastoreType.OPERATIONAL, topologycontextIID).get();
348 if (!optTopoContext.isPresent()) {
349 LOG.error("Topology context is not present in datastore");
352 return optTopoContext.get().getTopology();
353 } catch (InterruptedException | ExecutionException e) {
354 LOG.error("Couldnt read topology context", e);
359 public ConnectivityService getConnectivityService(Uuid serviceUuid) {
361 // First read connectivity service with service uuid and update info
362 InstanceIdentifier<ConnectivityService> connectivityServIID =
363 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
364 .child(org.opendaylight.yang.gen.v1.urn
365 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
366 .child(ConnectivityService.class, new ConnectivityServiceKey(serviceUuid))
369 Optional<ConnectivityService> optConnServ =
370 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivityServIID).get();
371 if (!optConnServ.isPresent()) {
372 LOG.error("Connectivity service not found in tapi context");
375 return optConnServ.get();
376 } catch (InterruptedException | ExecutionException e) {
377 LOG.error("Connectivity service not found in tapi context. Error:", e);
382 public void deleteConnectivityService(Uuid serviceUuid) {
383 ConnectivityService connectivityService = getConnectivityService(serviceUuid);
384 if (connectivityService == null) {
385 LOG.error("Service doesnt exist in tapi context");
388 for (org.opendaylight.yang.gen.v1
389 .urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.Connection connection:
390 connectivityService.getConnection().values()) {
391 deleteConnection(connection.getConnectionUuid());
393 InstanceIdentifier<ConnectivityService> connectivityServIID =
394 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
395 .child(org.opendaylight.yang.gen.v1.urn
396 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
397 .child(ConnectivityService.class, new ConnectivityServiceKey(serviceUuid))
400 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, connectivityServIID);
401 this.networkTransactionService.commit().get();
402 LOG.info("Connectivity service deleted");
403 } catch (InterruptedException | ExecutionException e) {
404 LOG.error("Failed to delete Connectivity service", e);
408 private void deleteConnection(Uuid connectionUuid) {
409 // First read connectivity service with service uuid and update info
410 InstanceIdentifier<org.opendaylight.yang.gen.v1
411 .urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection> connectionIID =
412 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
413 .child(org.opendaylight.yang.gen.v1.urn
414 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
415 .child(org.opendaylight.yang.gen.v1.urn
416 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection.class,
417 new org.opendaylight.yang.gen.v1.urn
418 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey(
422 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, connectionIID);
423 this.networkTransactionService.commit().get();
424 } catch (InterruptedException | ExecutionException e) {
425 LOG.error("Failed to delete TAPI Connection", e);
429 public Connection getConnection(Uuid connectionUuid) {
431 // First read connectivity service with service uuid and update info
432 InstanceIdentifier<Connection> connIID =
433 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
434 .child(org.opendaylight.yang.gen.v1.urn
435 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
436 .child(Connection.class, new ConnectionKey(connectionUuid))
439 Optional<Connection> optConn =
440 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connIID).get();
441 if (!optConn.isPresent()) {
442 LOG.error("Connection not found in tapi context");
445 return optConn.get();
446 } catch (InterruptedException | ExecutionException e) {
447 LOG.error("Connection not found in tapi context. Error:", e);
452 public Map<ConnectivityServiceKey, ConnectivityService> getConnectivityServices() {
454 // First read connectivity service with service uuid and update info
455 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
456 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext> connectivityContextIID =
457 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
458 .child(org.opendaylight.yang.gen.v1.urn
459 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
462 Optional<org.opendaylight.yang.gen.v1.urn
463 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext> optConnContext =
464 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivityContextIID)
466 if (!optConnContext.isPresent()) {
467 LOG.error("Connectivity context not found in tapi context");
470 return optConnContext.get().getConnectivityService();
471 } catch (InterruptedException | ExecutionException e) {
472 LOG.error("Connectivity context not found in tapi context. Error:", e);
477 public ConnectionEndPoint getTapiCEP(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, Uuid cepUuid) {
478 InstanceIdentifier<OwnedNodeEdgePoint> nepIID = InstanceIdentifier.builder(Context.class)
479 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
480 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
481 .child(Topology.class, new TopologyKey(topoUuid))
482 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
483 new NodeKey(nodeUuid)).child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid)).build();
485 Optional<OwnedNodeEdgePoint> optNode = this.networkTransactionService
486 .read(LogicalDatastoreType.OPERATIONAL, nepIID).get();
487 if (!optNode.isPresent()) {
488 LOG.error(NODE_NOT_PRESENT);
491 if (optNode.get().augmentation(OwnedNodeEdgePoint1.class) == null) {
492 LOG.error("Node doesnt have ceps");
495 return optNode.get().augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint()
496 .get(new ConnectionEndPointKey(cepUuid));
497 } catch (InterruptedException | ExecutionException e) {
498 LOG.error("Couldnt read node in topology", e);