+ @Override
+ public ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>>
+ getServiceInterfacePointDetails(GetServiceInterfacePointDetailsInput input) {
+ Uuid sipUuid = input.getUuid();
+ Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips =
+ this.tapiContext.getTapiContext().getServiceInterfacePoint();
+ if (sips == null || sips.isEmpty()) {
+ return RpcResultBuilder.<GetServiceInterfacePointDetailsOutput>failed()
+ .withError(ErrorType.RPC, "No sips in datastore")
+ .buildFuture();
+ }
+ if (!sips.containsKey(new ServiceInterfacePointKey(sipUuid))) {
+ return RpcResultBuilder.<GetServiceInterfacePointDetailsOutput>failed()
+ .withError(ErrorType.RPC, "Sip doesnt exist in datastore")
+ .buildFuture();
+ }
+ org.opendaylight.yang.gen.v1.urn
+ .onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.Sip outSip =
+ new org.opendaylight.yang.gen.v1.urn
+ .onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.SipBuilder(
+ sips.get(new ServiceInterfacePointKey(sipUuid)))
+ .build();
+ return RpcResultBuilder.success(new GetServiceInterfacePointDetailsOutputBuilder().setSip(outSip).build())
+ .buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>>
+ getServiceInterfacePointList(GetServiceInterfacePointListInput input) {
+ Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips =
+ this.tapiContext.getTapiContext().getServiceInterfacePoint();
+ if (sips == null || sips.isEmpty()) {
+ return RpcResultBuilder.<GetServiceInterfacePointListOutput>failed()
+ .withError(ErrorType.RPC, "No sips in datastore")
+ .buildFuture();
+ }
+ Map<SipKey, Sip> outSipMap = new HashMap<>();
+ for (ServiceInterfacePoint sip : sips.values()) {
+ Sip si = new SipBuilder(sip).build();
+ outSipMap.put(si.key(), si);
+ }
+ return RpcResultBuilder
+ .success(new GetServiceInterfacePointListOutputBuilder().setSip(outSipMap).build())
+ .buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<UpdateServiceInterfacePointOutput>>
+ updateServiceInterfacePoint(UpdateServiceInterfacePointInput input) {
+ return RpcResultBuilder.<UpdateServiceInterfacePointOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
+ }
+
+ private Topology createAbstracted100GTpdrTopology(Topology topology) {
+ List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> dsrNodes =
+ topology.nonnullNode().values().stream()
+ .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
+ .collect(Collectors.toList());
+ List<OwnedNodeEdgePoint> nep100GTpdrList = new ArrayList<>();
+ for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node2: dsrNodes) {
+ List<OwnedNodeEdgePoint> nepList = node2.getOwnedNodeEdgePoint().values().stream()
+ .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr"))).collect(Collectors.toList());
+ nep100GTpdrList.addAll(nepList);
+ }
+ Name topoName = new NameBuilder().setValue(TapiStringConstants.TPDR_100G)
+ .setValueName("TAPI Topology Name").build();
+ Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(
+ TapiStringConstants.TPDR_100G.getBytes(Charset.forName("UTF-8"))).toString());
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
+ createTapiNode(nep100GTpdrList, topoUuid);
+ return new TopologyBuilder()
+ .setName(Map.of(topoName.key(), topoName))
+ .setUuid(topoUuid)
+ .setNode(Map.of(node.key(), node))
+ .build();
+ }
+
+ private Network readTopology(InstanceIdentifier<Network> networkIID) throws TapiTopologyException {
+ Network topology = null;
+ FluentFuture<Optional<Network>> topologyFuture = dataBroker.newReadOnlyTransaction()
+ .read(LogicalDatastoreType.CONFIGURATION, networkIID);
+ try {
+ topology = topologyFuture.get().orElseThrow();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new TapiTopologyException("Unable to get from mdsal topology: " + networkIID
+ .firstKeyOf(Network.class).getNetworkId().getValue(), e);
+ } catch (ExecutionException e) {
+ throw new TapiTopologyException("Unable to get from mdsal topology: " + networkIID
+ .firstKeyOf(Network.class).getNetworkId().getValue(), e);
+ }
+ return topology;
+ }
+
+ private Topology createAbstractedOtnTopology() throws TapiTopologyException {
+ // read openroadm-topology
+ Network openroadmTopo = readTopology(InstanceIdentifiers.OVERLAY_NETWORK_II);
+ List<Link> linkList = new ArrayList<>();
+ if (openroadmTopo.augmentation(Network1.class) != null) {
+ linkList.addAll(openroadmTopo.augmentation(Network1.class).getLink().values());
+ }
+ List<Link> xponderOutLinkList = linkList.stream()
+ .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDEROUTPUT))
+ .collect(Collectors.toList());
+ List<Link> xponderInLinkList = linkList.stream()
+ .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDERINPUT))
+ .collect(Collectors.toList());
+ // read otn-topology
+ Network otnTopo = readTopology(InstanceIdentifiers.OTN_NETWORK_II);
+ Map<NodeId, Node> otnNodeMap = otnTopo.nonnullNode().values().stream()
+ .collect(Collectors.toMap(Node::getNodeId, node -> node));
+
+ Map<String, List<String>> networkPortMap = new HashMap<>();
+ Iterator<Entry<NodeId, Node>> itOtnNodeMap = otnNodeMap.entrySet().iterator();
+ while (itOtnNodeMap.hasNext()) {
+ Entry<NodeId, Node> entry = itOtnNodeMap.next();
+ String portMappingNodeId = entry.getValue().getSupportingNode().values().stream()
+ .filter(sn -> sn.getNetworkRef().getValue().equals(NetworkUtils.UNDERLAY_NETWORK_ID))
+ .findFirst()
+ .orElseThrow().getNodeRef().getValue();
+ List<String> networkPortList = new ArrayList<>();
+ for (TerminationPoint tp: entry.getValue().augmentation(Node1.class).getTerminationPoint().values()) {
+ if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)
+ && checkTp(entry.getKey().getValue(), portMappingNodeId, tp, xponderOutLinkList,
+ xponderInLinkList)) {
+ networkPortList.add(tp.getTpId().getValue());
+ }
+ }
+ if (!networkPortList.isEmpty()) {
+ networkPortMap.put(entry.getKey().getValue(), networkPortList);
+ }
+ }
+ Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node>
+ tapiNodeList = new HashMap<>();
+ Map<LinkKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link>
+ tapiLinkList = new HashMap<>();
+ Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER
+ .getBytes(Charset.forName("UTF-8"))).toString());
+ ConvertORTopoToTapiTopo tapiFactory = new ConvertORTopoToTapiTopo(topoUuid, this.tapiLink);
+ Iterator<Entry<String, List<String>>> it = networkPortMap.entrySet().iterator();
+ while (it.hasNext()) {
+ String nodeId = it.next().getKey();
+ tapiFactory.convertNode(otnNodeMap.get(new NodeId(nodeId)), networkPortMap.get(nodeId));
+ tapiNodeList.putAll(tapiFactory.getTapiNodes());
+ tapiLinkList.putAll(tapiFactory.getTapiLinks());
+ }
+ if (openroadmTopo.nonnullNode().values().stream()
+ .filter(nt -> nt
+ .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
+ .getNodeType()
+ .equals(OpenroadmNodeType.SRG))
+ .count() > 0) {
+ tapiFactory.convertRoadmInfrastructure();
+ tapiNodeList.putAll(tapiFactory.getTapiNodes());
+ tapiLinkList.putAll(tapiFactory.getTapiLinks());
+ } else {
+ LOG.warn("Unable to abstract an ROADM infrasctructure from openroadm-topology");
+ }
+ if (otnTopo.augmentation(Network1.class) != null) {
+ Map<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
+ .ietf.network.topology.rev180226.networks.network.LinkKey, Link> otnLinkMap =
+ otnTopo.augmentation(Network1.class).getLink();
+ tapiFactory.convertLinks(otnLinkMap);
+ tapiLinkList.putAll(tapiFactory.getTapiLinks());