X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Ftapi%2Fimpl%2Frpc%2FGetTopologyDetailsImpl.java;h=e2da5de36121309de1963e02f7f5cbb898516018;hb=652c9098f8d97e6f5a723a7c55929f9351bffb5b;hp=eb7c163aba98c3504484168ce5edba2dcb629929;hpb=7effa6e4da00132c76c31f5be91f884203501bb0;p=transportpce.git diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetTopologyDetailsImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetTopologyDetailsImpl.java index eb7c163ab..e2da5de36 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetTopologyDetailsImpl.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetTopologyDetailsImpl.java @@ -31,6 +31,7 @@ import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.tapi.TapiStringConstants; import org.opendaylight.transportpce.tapi.topology.ConvertORToTapiTopology; import org.opendaylight.transportpce.tapi.topology.ConvertORTopoToTapiTopo; +import org.opendaylight.transportpce.tapi.topology.ConvertTapiTopoToAbstracted; import org.opendaylight.transportpce.tapi.topology.TapiTopologyException; import org.opendaylight.transportpce.tapi.topology.TopologyUtils; import org.opendaylight.transportpce.tapi.utils.TapiContext; @@ -111,53 +112,68 @@ public class GetTopologyDetailsImpl implements GetTopologyDetails { @Override public ListenableFuture> invoke(GetTopologyDetailsInput input) { org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology topology; - Uuid topologyUuidAbs = new Uuid(UUID - .nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(Charset.forName("UTF-8"))).toString()); - Uuid topologyUuidFull = new Uuid( - UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8"))) - .toString()); + Uuid topologyUuidFull = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes( + Charset.forName("UTF-8"))).toString()); if (input.getTopologyId().equals(topologyUuidFull)) { Context context = this.tapiContext.getTapiContext(); - Map topologyMap = context - .augmentation(Context1.class).getTopologyContext().getTopology(); + Map + topologyMap = context.augmentation(Context1.class).getTopologyContext().getTopology(); if (topologyMap == null || !topologyMap.containsKey(new TopologyKey(topologyUuidFull))) { LOG.error("Topology {} not found in datastore", input.getTopologyId()); return RpcResultBuilder.failed() - .withError(ErrorType.RPC, "Invalid Topology name") - .buildFuture(); + .withError(ErrorType.RPC, "Invalid Topology name") + .buildFuture(); } topology = topologyMap.get(new TopologyKey(input.getTopologyId())); - return RpcResultBuilder - .success(new GetTopologyDetailsOutputBuilder() - .setTopology(this.topologyUtils.transformTopology(topology)).build()) + return RpcResultBuilder.success(new GetTopologyDetailsOutputBuilder() + .setTopology(this.topologyUtils.transformTopology(topology)) + .build()) + .buildFuture(); + } + Uuid topologyUuidTapiAbs = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_TAPI_MULTILAYER.getBytes( + Charset.forName("UTF-8"))).toString()); + if (input.getTopologyId().equals(topologyUuidTapiAbs)) { + try { + LOG.info("Building TAPI Topology abstraction for {}", input.getTopologyId()); + topology = createAbsTopologyFromTapiTopo(); + return RpcResultBuilder.success(new GetTopologyDetailsOutputBuilder() + .setTopology(this.topologyUtils.transformTopology(topology)).build()) + .buildFuture(); + } catch (TapiTopologyException e) { + LOG.error("error building TAPI topology"); + return RpcResultBuilder.failed() + .withError(ErrorType.RPC, "Error building topology") .buildFuture(); + } } - Uuid topologyUuid100G = new Uuid( - UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(Charset.forName("UTF-8"))).toString()); + Uuid topologyUuid100G = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes( + Charset.forName("UTF-8"))).toString()); + Uuid topologyUuidAbs = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes( + Charset.forName("UTF-8"))).toString()); if (topologyUuid100G.equals(input.getTopologyId()) || topologyUuidAbs.equals(input.getTopologyId())) { try { LOG.info("Building TAPI Topology abstraction for {}", input.getTopologyId()); topology = createAbstractedOtnTopology(); if (input.getTopologyId().equals(topologyUuidAbs)) { - return RpcResultBuilder - .success(new GetTopologyDetailsOutputBuilder() - .setTopology(this.topologyUtils.transformTopology(topology)).build()) - .buildFuture(); + return RpcResultBuilder.success(new GetTopologyDetailsOutputBuilder() + .setTopology(this.topologyUtils.transformTopology(topology)).build()) + .buildFuture(); } topology = createAbstracted100GTpdrTopology(topology); return RpcResultBuilder.success(new GetTopologyDetailsOutputBuilder() - .setTopology(this.topologyUtils.transformTopology(topology)).build()).buildFuture(); + .setTopology(this.topologyUtils.transformTopology(topology)).build()) + .buildFuture(); } catch (TapiTopologyException e) { LOG.error("error building TAPI topology"); return RpcResultBuilder.failed() - .withError(ErrorType.RPC, "Error building topology") - .buildFuture(); + .withError(ErrorType.RPC, "Error building topology") + .buildFuture(); } } return RpcResultBuilder.failed() - .withError(ErrorType.RPC, "Invalid Topology name") - .buildFuture(); + .withError(ErrorType.RPC, "Invalid Topology name") + .buildFuture(); } public org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology @@ -266,7 +282,44 @@ public class GetTopologyDetailsImpl implements GetTopologyDetails { .onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyBuilder() .setName(Map.of(name.key(), name)).setUuid(topoUuid).setNode(tapiNodeList) .setLayerProtocolName(Set.of(LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.DIGITALOTN)) - .setLink(tapiLinkList).build(); + .setLink(tapiLinkList) + .build(); + } + + public org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology + createAbsTopologyFromTapiTopo() throws TapiTopologyException { + Uuid refTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER + .getBytes(Charset.forName("UTF-8"))).toString()); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology tapiFullTopo = + this.tapiContext + .getTopologyContext().entrySet().stream().filter(topo -> topo.getKey().getUuid().equals(refTopoUuid)) + .findAny().orElseThrow().getValue(); + ConvertTapiTopoToAbstracted absTapiTopo = new ConvertTapiTopoToAbstracted(refTopoUuid); + absTapiTopo.setTapiLinks(tapiFullTopo.getLink()); + absTapiTopo.setTapiNodes(tapiFullTopo.getNode()); + absTapiTopo.convertRoadmInfrastructure(); + + Map + tapiNodeList = new HashMap<>(); + Map + tapiLinkList = new HashMap<>(); + tapiNodeList.putAll(absTapiTopo.getTapiNodes()); + tapiLinkList.putAll(absTapiTopo.getTapiLinks()); + Name name = new NameBuilder() + .setValue(TapiStringConstants.T0_MULTILAYER) + .setValueName("TAPI Topology Name") + .build(); + Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_TAPI_MULTILAYER + .getBytes(Charset.forName("UTF-8"))).toString()); + LOG.info("ABSTRACTED TAPI TOPOLOGY : the list of node is as follows {}", tapiNodeList); + return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context + .TopologyBuilder() + .setName(Map.of(name.key(), name)) + .setUuid(topoUuid) + .setNode(tapiNodeList) + .setLayerProtocolName(Set.of(LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.DIGITALOTN)) + .setLink(tapiLinkList) + .build(); } private Network readTopology(InstanceIdentifier networkIID) throws TapiTopologyException {