+ //Add a node to the route object
+ private Long addNodeToRouteObject(String nodeRef, Long index) throws GnpyException {
+ Long idx = index;
+ for (Elements element : this.elements.values()) {
+ if (element.getUid().equals(nodeRef)) {
+ if ((this.currentNodeId == null) || (!this.currentNodeId.equals(nodeRef))) {
+ this.currentNodeId = nodeRef;
+ RouteObjectIncludeExclude routeObjectIncludeExclude = addRouteObjectIncludeExclude(nodeRef,
+ Uint32.valueOf(1), idx);
+ RouteObjectIncludeExcludeKey key = new RouteObjectIncludeExcludeKey(Uint32.valueOf(idx));
+ routeObjectIncludeExcludes.put(key, routeObjectIncludeExclude);
+ idx += 1;
+ }
+ return idx;
+ }
+ }
+ throw new GnpyException(String.format("In gnpyServiceImpl : NodeRef %s does not exist",nodeRef));
+ }
+
+ //Add a link to the route object
+ private Long addLinkToRouteObject(String linkId, Long index) throws GnpyException {
+ Long idx = index;
+ if (linkId == null) {
+ throw new GnpyException("In GnpyServiceImpl: the linkId is null");
+ }
+ //Only the ROADM-to-ROADM link are included in the route object
+ if (!mapLinkFiber.containsKey(linkId)) {
+ return idx;
+ }
+ List<String> listSubLink = this.mapLinkFiber.get(linkId);
+ if (listSubLink == null) {
+ throw new GnpyException(String.format("In gnpyServiceImpl addNodeRouteObject : no sublink in %s",linkId));
+ }
+ for (String subLink : listSubLink) {
+ RouteObjectIncludeExclude routeObjectIncludeExclude =
+ addRouteObjectIncludeExclude(subLink, Uint32.valueOf(1),idx);
+ RouteObjectIncludeExcludeKey key = new RouteObjectIncludeExcludeKey(Uint32.valueOf(idx));
+ routeObjectIncludeExcludes.put(key, routeObjectIncludeExclude);
+ idx += 1;
+ }
+ return idx;
+ }
+
+ // Add routeObjectIncludeExclude
+ private RouteObjectIncludeExclude addRouteObjectIncludeExclude(String nodeId, Uint32 teTpValue, Long index) {
+ NumUnnumHop numUnnumHop = new org.opendaylight.yang.gen.v1.gnpy.path.rev220221.explicit.route.hop.type.num
+ .unnum.hop.NumUnnumHopBuilder()
+ .setNodeId(nodeId)
+ .setLinkTpId(teTpValue.toString())
+ .setHopType(TeHopType.STRICT).build();
+ Type type1 = new NumUnnumHopBuilder().setNumUnnumHop(numUnnumHop).build();
+ // Create routeObjectIncludeExclude element
+ return new RouteObjectIncludeExcludeBuilder()
+ .setIndex(Uint32.valueOf(index)).setExplicitRouteUsage(RouteIncludeEro.class).setType(type1).build();
+ }
+
+ //Create the path constraints
+ private PathConstraints createPathConstraints(Long rate, String modulationFormat, FrequencyTHz minFrequency,
+ FrequencyTHz maxFrequency) {
+ BigDecimal spacing = GridConstant.SLOT_WIDTH_50;
+ int mvalue = GridConstant.NB_SLOTS_100G;
+ int nvalue = 0;
+ if (minFrequency != null && maxFrequency != null && modulationFormat != null) {
+ LOG.info("Creating path constraints for rate {}, modulationFormat {}, min freq {}, max freq {}", rate,
+ modulationFormat, minFrequency, maxFrequency);
+ ModulationFormat mformat = ModulationFormat.DpQpsk;
+ Optional<ModulationFormat> optionalModulationFormat = ModulationFormat.forName(modulationFormat);
+ if (optionalModulationFormat.isPresent()) {
+ mformat = optionalModulationFormat.get();
+ }
+ spacing = GridConstant.FREQUENCY_SLOT_WIDTH_TABLE.get(Uint32.valueOf(rate), mformat);
+ FrequencyTHz centralFrequency = GridUtils
+ .getCentralFrequency(minFrequency.getValue(), maxFrequency.getValue());
+ int centralFrequencyBitSetIndex = GridUtils.getIndexFromFrequency(centralFrequency.getValue());
+ mvalue = (int) Math.ceil(spacing.doubleValue() / (GridConstant.GRANULARITY));
+ nvalue = GridUtils.getNFromFrequencyIndex(centralFrequencyBitSetIndex);
+ }
+ LOG.info("Creating path constraints for rate {}, mvalue {}, nvalue {}, spacing {}", rate,
+ mvalue, nvalue, spacing);
+ EffectiveFreqSlot effectiveFreqSlot = new EffectiveFreqSlotBuilder()
+ .setM(Uint32.valueOf(mvalue / 2)).setN(nvalue).build();
+
+ TeBandwidth teBandwidth = new TeBandwidthBuilder()
+ .setPathBandwidth(BigDecimal.valueOf(rate * 1e9))
+ .setTechnology("flexi-grid").setTrxType("OpenROADM MSA ver. 5.0")
+ .setTrxMode(TRX_MODE_TABLE.get(Uint32.valueOf(rate), spacing))
+ .setOutputPower(GridUtils.convertDbmW(GridConstant.OUTPUT_POWER_100GB_DBM
+ + 10 * Math.log10(mvalue / (double)GridConstant.NB_SLOTS_100G)))
+ .setEffectiveFreqSlot(Map.of(effectiveFreqSlot.key(), effectiveFreqSlot))
+ .setSpacing(spacing.multiply(BigDecimal.valueOf(1e9))).build();
+ return new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
+ }
+
+ //Create the synchronization
+ private List<Synchronization> extractSynchronization(Uint32 requestId) {
+ // Create RequestIdNumber
+ List<String> requestIdNumber = new ArrayList<>();
+ requestIdNumber.add(requestId.toString());
+ // Create a synchronization
+ Svec svec = new SvecBuilder().setRelaxable(true)
+ .setDisjointness(new TePathDisjointness(true, true, false))
+ .setRequestIdNumber(requestIdNumber).build();
+ List<Synchronization> synchro = new ArrayList<>();
+ Synchronization synchronization1 = new SynchronizationBuilder()
+ .setSynchronizationId(Uint32.valueOf(0).toString())
+ .setSvec(svec).build();
+ synchro.add(synchronization1);
+ return (synchro);
+ }
+
+ public Map<PathRequestKey, PathRequest> getPathRequest() {