import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.fixedflex.GridUtils;
import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.FrequencyTHz;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev230526.FrequencyTHz;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.ModulationFormat;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.AToZDirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.ZToADirectionBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.atoz.direction.AToZ;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.atoz.direction.AToZBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.atoz.direction.AToZKey;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.ztoa.direction.ZToA;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.ztoa.direction.ZToABuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.ztoa.direction.ZToAKey;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.Resource;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.ResourceBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.LinkBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.NodeBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.TerminationPoint;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.TerminationPointBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.OpucnTribSlotDef;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToA;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToABuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToAKey;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.Resource;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.ResourceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.LinkBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.NodeBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPoint;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId;
-import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @return a builder for AtoZDirection object
*/
private AToZDirectionBuilder buildAtoZDirection(Map<AToZKey, AToZ> atozMap) {
+ ModulationFormat modulationFormat = GridConstant.RATE_MODULATION_FORMAT_MAP
+ .getOrDefault(Uint32.valueOf(rc.getRate()), ModulationFormat.DpQpsk);
AToZDirectionBuilder atoZDirectionBldr = new AToZDirectionBuilder()
.setRate(Uint32.valueOf(rc.getRate()))
- .setModulationFormat(GridConstant.RATE_MODULATION_FORMAT_MAP
- .getOrDefault(Uint32.valueOf(rc.getRate()), ModulationFormat.DpQpsk).getName())
+ .setModulationFormat(modulationFormat.getName())
.setAToZ(atozMap);
switch (rc.getServiceType()) {
case StringConstants.SERVICE_TYPE_400GE:
- case StringConstants.SERVICE_TYPE_100GE:
+ case StringConstants.SERVICE_TYPE_OTUC2:
+ case StringConstants.SERVICE_TYPE_OTUC3:
+ case StringConstants.SERVICE_TYPE_OTUC4:
+ case StringConstants.SERVICE_TYPE_100GE_T:
case StringConstants.SERVICE_TYPE_OTU4:
- atoZDirectionBldr.setAToZMaxFrequency(new FrequencyTHz(rc.getMaxFreq()));
- atoZDirectionBldr.setAToZMinFrequency(new FrequencyTHz(rc.getMinFreq()));
- atoZDirectionBldr.setAToZWavelengthNumber(Uint32.valueOf(rc.getResultWavelength()));
+ atoZDirectionBldr
+ .setAToZMaxFrequency(new FrequencyTHz(Decimal64.valueOf(rc.getMaxFreq())))
+ .setAToZMinFrequency(new FrequencyTHz(Decimal64.valueOf(rc.getMinFreq())))
+ .setAToZWavelengthNumber(Uint32.valueOf(rc.getResultWavelength()))
+ // Used precision 5 to get the exact decimal values of the frequency
+ .setCentralFrequency(new FrequencyTHz(GridUtils.getCentralFrequencyWithPrecision(
+ rc.getMinFreq(), rc.getMaxFreq(), 5).getValue()))
+ .setWidth(GridUtils.getWidthFromRateAndModulationFormatToModel131(
+ Uint32.valueOf(rc.getRate()), modulationFormat));
break;
+ case StringConstants.SERVICE_TYPE_100GE_M:
+ case StringConstants.SERVICE_TYPE_100GE_S:
case StringConstants.SERVICE_TYPE_10GE:
case StringConstants.SERVICE_TYPE_1GE:
case StringConstants.SERVICE_TYPE_ODU4:
- if (rc.getResultTribSlot() != null && rc.getResultTribPort() != null) {
- @SuppressWarnings("unchecked")
- List<Uint16> tribSlotList = (List<Uint16>) rc.getResultTribSlot().values().toArray()[0];
+ case StringConstants.SERVICE_TYPE_ODUC2:
+ case StringConstants.SERVICE_TYPE_ODUC3:
+ case StringConstants.SERVICE_TYPE_ODUC4:
+ if (rc.getResultTribPortTribSlot() != null && rc.getResultTribPortTribSlot().get(0) != null
+ && rc.getResultTribPortTribSlot().get(1) != null) {
atoZDirectionBldr.setAToZWavelengthNumber(Uint32.valueOf(0))
- .setTribPortNumber(Uint16.valueOf(rc.getResultTribPort().values().toArray()[0].toString()))
- .setTribSlotNumber(tribSlotList.get(0));
+ .setMinTribSlot(rc.getResultTribPortTribSlot().get(0))
+ .setMaxTribSlot(rc.getResultTribPortTribSlot().get(1));
} else {
- LOG.error("Trib port and trib slot number should be present");
- atoZDirectionBldr.setTribSlotNumber(Uint16.valueOf(0)).setTribPortNumber(Uint16.valueOf(0));
+ LOG.warn("Trib port and trib slot number should be present");
+ atoZDirectionBldr.setMinTribSlot(new OpucnTribSlotDef("0.0"))
+ .setMaxTribSlot(new OpucnTribSlotDef("0.0"));
}
break;
default:
- LOG.warn("unknown service type : unable to set Min/Max frequencies");
+ LOG.warn("unknown service type : unable to set Min/Max frequencies or trib-port/trib-slot");
break;
}
return atoZDirectionBldr;
* @return a builder for ZtoADirection object
*/
private ZToADirectionBuilder buildZtoADirection(Map<ZToAKey, ZToA> ztoaMap) {
+ ModulationFormat modulationFormat = GridConstant.RATE_MODULATION_FORMAT_MAP
+ .getOrDefault(Uint32.valueOf(rc.getRate()), ModulationFormat.DpQpsk);
ZToADirectionBuilder ztoADirectionBldr = new ZToADirectionBuilder().setRate(Uint32.valueOf(rc.getRate()))
- .setModulationFormat(GridConstant.RATE_MODULATION_FORMAT_MAP
- .getOrDefault(Uint32.valueOf(rc.getRate()), ModulationFormat.DpQpsk).getName())
+ .setModulationFormat(modulationFormat.getName())
.setZToA(ztoaMap);
switch (rc.getServiceType()) {
case StringConstants.SERVICE_TYPE_400GE:
- case StringConstants.SERVICE_TYPE_100GE:
+ case StringConstants.SERVICE_TYPE_OTUC2:
+ case StringConstants.SERVICE_TYPE_OTUC3:
+ case StringConstants.SERVICE_TYPE_OTUC4:
+ case StringConstants.SERVICE_TYPE_100GE_T:
case StringConstants.SERVICE_TYPE_OTU4:
- ztoADirectionBldr.setZToAMaxFrequency(new FrequencyTHz(rc.getMaxFreq()));
- ztoADirectionBldr.setZToAMinFrequency(new FrequencyTHz(rc.getMinFreq()));
- ztoADirectionBldr.setZToAWavelengthNumber(Uint32.valueOf(rc.getResultWavelength()));
+ ztoADirectionBldr
+ .setZToAMaxFrequency(new FrequencyTHz(Decimal64.valueOf(rc.getMaxFreq())))
+ .setZToAMinFrequency(new FrequencyTHz(Decimal64.valueOf(rc.getMinFreq())))
+ .setZToAWavelengthNumber(Uint32.valueOf(rc.getResultWavelength()))
+ .setCentralFrequency(new FrequencyTHz(GridUtils.getCentralFrequencyWithPrecision(
+ rc.getMinFreq(), rc.getMaxFreq(), 4).getValue()))
+ .setWidth(GridUtils.getWidthFromRateAndModulationFormatToModel131(
+ Uint32.valueOf(rc.getRate()), modulationFormat));
break;
+ case StringConstants.SERVICE_TYPE_100GE_M:
+ case StringConstants.SERVICE_TYPE_100GE_S:
case StringConstants.SERVICE_TYPE_10GE:
case StringConstants.SERVICE_TYPE_1GE:
case StringConstants.SERVICE_TYPE_ODU4:
- if (rc.getResultTribSlot() != null && rc.getResultTribPort() != null) {
- @SuppressWarnings("unchecked")
- List<Uint16> tribSlotList = (List<Uint16>) rc.getResultTribSlot().values().toArray()[0];
+ case StringConstants.SERVICE_TYPE_ODUC2:
+ case StringConstants.SERVICE_TYPE_ODUC3:
+ case StringConstants.SERVICE_TYPE_ODUC4:
+ if (rc.getResultTribPortTribSlot() != null && rc.getResultTribPortTribSlot().get(0) != null
+ && rc.getResultTribPortTribSlot().get(1) != null) {
ztoADirectionBldr.setZToAWavelengthNumber(Uint32.valueOf(0))
- .setTribPortNumber(Uint16.valueOf(rc.getResultTribPort().values().toArray()[0].toString()))
- .setTribSlotNumber(tribSlotList.get(0));
+ .setMinTribSlot(rc.getResultTribPortTribSlot().get(0))
+ .setMaxTribSlot(rc.getResultTribPortTribSlot().get(1));
} else {
- LOG.error("Trib port and trib slot number should be present");
- ztoADirectionBldr.setTribSlotNumber(Uint16.valueOf(0)).setTribPortNumber(Uint16.valueOf(0));
+ LOG.warn("Trib port and trib slot number should be present");
+ ztoADirectionBldr.setMinTribSlot(new OpucnTribSlotDef("0.0"))
+ .setMaxTribSlot(new OpucnTribSlotDef("0.0"));
}
break;
default:
for (PceLink pcelink : path) {
String srcName = pcelink.getSourceId().getValue();
// Nodes
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce
- .resource.resource.resource.Node sourceNode = new NodeBuilder()
- .setNodeId(srcName)
- .build();
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501
+ .pce.resource.resource.resource.Node sourceNode = new NodeBuilder()
+ .setNodeId(srcName)
+ .build();
// Source Resource
AToZKey sourceKey = new AToZKey(index.toString());
atozMap.put(srcResource.key(),srcResource);
// source TP
- tpName = pcelink.getSourceTP().toString();
+ tpName = pcelink.getSourceTP().getValue();
stp = new TerminationPointBuilder()
.setTpNodeId(srcName).setTpId(tpName)
.build();
String linkName = pcelink.getLinkId().getValue();
// Link
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce
- .resource.resource.resource.Link atozLink = new LinkBuilder()
- .setLinkId(linkName)
- .build();
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501
+ .pce.resource.resource.resource.Link atozLink = new LinkBuilder()
+ .setLinkId(linkName)
+ .build();
// Link Resource
AToZKey linkKey = new AToZKey(index.toString());
String destName = pcelink.getDestId().getValue();
// target TP
- tpName = pcelink.getDestTP().toString();
+ tpName = pcelink.getDestTP().getValue();
TerminationPoint dtp = new TerminationPointBuilder()
.setTpNodeId(destName).setTpId(tpName)
.build();
index += 1;
atozMap.put(ttpResource.key(),ttpResource);
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce
.resource.resource.resource.Node targetNode = new NodeBuilder()
.setNodeId(destName)
.build();
// Nodes
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce
.resource.resource.resource.Node sourceNode = new NodeBuilder()
.setNodeId(srcName).build();
ztoaList.put(srcResource.key(),srcResource);
// source TP
- tpName = pcelink.getSourceTP().toString();
+ tpName = pcelink.getSourceTP().getValue();
stp = new TerminationPointBuilder()
.setTpNodeId(srcName).setTpId(tpName)
.build();
String linkName = pcelink.getLinkId().getValue();
// Link
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce
.resource.resource.resource.Link ztoaLink = new LinkBuilder()
.setLinkId(linkName).build();
String destName = pcelink.getDestId().getValue();
// target TP
- tpName = pcelink.getDestTP().toString();
+ tpName = pcelink.getDestTP().getValue();
TerminationPoint ttp = new TerminationPointBuilder()
.setTpNodeId(destName).setTpId(tpName).build();
ztoaList.put(ttpResource.key(),ttpResource);
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce
.resource.resource.resource.Node targetNode = new NodeBuilder()
.setNodeId(destName).build();
// Target Resource