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 LOG.debug("NEPs of node before creating map to be returned to the getTapiNode function = {}",
266 node.getOwnedNodeEdgePoint().size());
267 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
268 for (OwnedNodeEdgePoint onep: node.getOwnedNodeEdgePoint().values()) {
269 if (onep.augmentation(OwnedNodeEdgePoint1.class) == null) {
270 onepMap.put(onep.key(), onep);
273 OwnedNodeEdgePointBuilder newOnepBuilder = new OwnedNodeEdgePointBuilder()
274 .setUuid(onep.getUuid())
275 .setLayerProtocolName(onep.getLayerProtocolName())
276 .setName(onep.getName())
277 .setSupportedCepLayerProtocolQualifier(onep.getSupportedCepLayerProtocolQualifier())
278 .setAdministrativeState(onep.getAdministrativeState())
279 .setOperationalState(onep.getOperationalState())
280 .setLifecycleState(onep.getLifecycleState())
281 .setTerminationDirection(onep.getTerminationDirection())
282 .setTerminationState(onep.getTerminationState())
283 .setLinkPortDirection(onep.getLinkPortDirection())
284 .setLinkPortRole(onep.getLinkPortRole());
285 if (onep.getMappedServiceInterfacePoint() != null) {
286 newOnepBuilder.setMappedServiceInterfacePoint(onep.getMappedServiceInterfacePoint());
288 OwnedNodeEdgePoint newOnep = newOnepBuilder.build();
289 onepMap.put(newOnep.key(), newOnep);
291 LOG.debug("NEPs of node after creating map to be returned to the getTapiNode function = {}",
293 return new NodeBuilder(node)
294 .setOwnedNodeEdgePoint(onepMap)
296 } catch (InterruptedException | ExecutionException e) {
297 LOG.error("Couldnt read node in topology", e);
302 public OwnedNodeEdgePoint getTapiNEP(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid) {
303 InstanceIdentifier<OwnedNodeEdgePoint> nepIID = InstanceIdentifier.builder(Context.class)
304 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
305 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
306 .child(Topology.class, new TopologyKey(topoUuid))
307 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
308 new NodeKey(nodeUuid)).child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid)).build();
310 Optional<OwnedNodeEdgePoint> optNode = this.networkTransactionService
311 .read(LogicalDatastoreType.OPERATIONAL, nepIID)
313 if (!optNode.isPresent()) {
314 LOG.error(NODE_NOT_PRESENT);
317 return optNode.get();
318 } catch (InterruptedException | ExecutionException e) {
319 LOG.error("Couldnt read NEP in topology", e);
324 public Link getTapiLink(Uuid topoUuid, Uuid linkUuid) {
325 InstanceIdentifier<Link> linkIID = InstanceIdentifier.builder(Context.class)
326 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
327 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
328 .child(Topology.class, new TopologyKey(topoUuid))
329 .child(Link.class, new LinkKey(linkUuid)).build();
331 Optional<Link> optLink = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, linkIID)
333 if (!optLink.isPresent()) {
334 LOG.error(NODE_NOT_PRESENT);
337 return optLink.get();
338 } catch (InterruptedException | ExecutionException e) {
339 LOG.error("Couldnt read link in topology", e);
344 public Map<TopologyKey, Topology> getTopologyContext() {
345 InstanceIdentifier<TopologyContext> topologycontextIID =
346 InstanceIdentifier.builder(Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
347 .onf.otcc.yang.tapi.topology.rev181210.Context1.class)
348 .child(TopologyContext.class)
351 Optional<TopologyContext> optTopoContext = this.networkTransactionService.read(
352 LogicalDatastoreType.OPERATIONAL, topologycontextIID).get();
353 if (!optTopoContext.isPresent()) {
354 LOG.error("Topology context is not present in datastore");
357 return optTopoContext.get().getTopology();
358 } catch (InterruptedException | ExecutionException e) {
359 LOG.error("Couldnt read topology context", e);
364 public ConnectivityService getConnectivityService(Uuid serviceUuid) {
366 // First read connectivity service with service uuid and update info
367 InstanceIdentifier<ConnectivityService> connectivityServIID =
368 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
369 .child(org.opendaylight.yang.gen.v1.urn
370 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
371 .child(ConnectivityService.class, new ConnectivityServiceKey(serviceUuid))
374 Optional<ConnectivityService> optConnServ =
375 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivityServIID).get();
376 if (!optConnServ.isPresent()) {
377 LOG.error("Connectivity service not found in tapi context");
380 return optConnServ.get();
381 } catch (InterruptedException | ExecutionException e) {
382 LOG.error("Connectivity service not found in tapi context. Error:", e);
387 public void deleteConnectivityService(Uuid serviceUuid) {
388 ConnectivityService connectivityService = getConnectivityService(serviceUuid);
389 if (connectivityService == null) {
390 LOG.error("Service doesnt exist in tapi context");
393 for (org.opendaylight.yang.gen.v1
394 .urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.Connection connection:
395 connectivityService.getConnection().values()) {
396 deleteConnection(connection.getConnectionUuid());
398 InstanceIdentifier<ConnectivityService> connectivityServIID =
399 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
400 .child(org.opendaylight.yang.gen.v1.urn
401 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
402 .child(ConnectivityService.class, new ConnectivityServiceKey(serviceUuid))
405 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, connectivityServIID);
406 this.networkTransactionService.commit().get();
407 LOG.info("Connectivity service deleted");
408 } catch (InterruptedException | ExecutionException e) {
409 LOG.error("Failed to delete Connectivity service", e);
413 private void deleteConnection(Uuid connectionUuid) {
414 // First read connectivity service with service uuid and update info
415 InstanceIdentifier<org.opendaylight.yang.gen.v1
416 .urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection> connectionIID =
417 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
418 .child(org.opendaylight.yang.gen.v1.urn
419 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
420 .child(org.opendaylight.yang.gen.v1.urn
421 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection.class,
422 new org.opendaylight.yang.gen.v1.urn
423 .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey(
427 this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, connectionIID);
428 this.networkTransactionService.commit().get();
429 } catch (InterruptedException | ExecutionException e) {
430 LOG.error("Failed to delete TAPI Connection", e);
434 public Connection getConnection(Uuid connectionUuid) {
436 // First read connectivity service with service uuid and update info
437 InstanceIdentifier<Connection> connIID =
438 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
439 .child(org.opendaylight.yang.gen.v1.urn
440 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
441 .child(Connection.class, new ConnectionKey(connectionUuid))
444 Optional<Connection> optConn =
445 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connIID).get();
446 if (!optConn.isPresent()) {
447 LOG.error("Connection not found in tapi context");
450 return optConn.get();
451 } catch (InterruptedException | ExecutionException e) {
452 LOG.error("Connection not found in tapi context. Error:", e);
457 public Map<ConnectivityServiceKey, ConnectivityService> getConnectivityServices() {
459 // First read connectivity service with service uuid and update info
460 InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
461 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext> connectivityContextIID =
462 InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
463 .child(org.opendaylight.yang.gen.v1.urn
464 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext.class)
467 Optional<org.opendaylight.yang.gen.v1.urn
468 .onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext> optConnContext =
469 this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, connectivityContextIID)
471 if (!optConnContext.isPresent()) {
472 LOG.error("Connectivity context not found in tapi context");
475 return optConnContext.get().getConnectivityService();
476 } catch (InterruptedException | ExecutionException e) {
477 LOG.error("Connectivity context not found in tapi context. Error:", e);
482 public ConnectionEndPoint getTapiCEP(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, Uuid cepUuid) {
483 InstanceIdentifier<OwnedNodeEdgePoint> nepIID = InstanceIdentifier.builder(Context.class)
484 .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class)
485 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class)
486 .child(Topology.class, new TopologyKey(topoUuid))
487 .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node.class,
488 new NodeKey(nodeUuid)).child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid)).build();
490 Optional<OwnedNodeEdgePoint> optNode = this.networkTransactionService
491 .read(LogicalDatastoreType.OPERATIONAL, nepIID).get();
492 if (!optNode.isPresent()) {
493 LOG.error(NODE_NOT_PRESENT);
496 if (optNode.get().augmentation(OwnedNodeEdgePoint1.class) == null) {
497 LOG.error("Node doesnt have ceps");
500 return optNode.get().augmentation(OwnedNodeEdgePoint1.class).getCepList().getConnectionEndPoint()
501 .get(new ConnectionEndPointKey(cepUuid));
502 } catch (InterruptedException | ExecutionException e) {
503 LOG.error("Couldnt read node in topology", e);