+ 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());
+ }
+ Name name = new NameBuilder()
+ .setValue(TapiStringConstants.T0_MULTILAYER)
+ .setValueName("TAPI Topology Name")
+ .build();
+ return new TopologyBuilder()
+ .setName(Map.of(name.key(), name))
+ .setUuid(topoUuid)
+ .setNode(tapiNodeList)
+ .setLink(tapiLinkList).build();