import java.util.List;
import java.util.Map;
import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
+import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirectionBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirectionBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.atoz.direction.AToZ;
public class PcePathDescription {
/* Logging. */
- private static final Logger LOG = LoggerFactory.getLogger(PceCalculation.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PcePathDescription.class);
private List<PceLink> pathAtoZ = null;
private PceResult rc;
public PceResult getReturnStructure() {
- return this.rc;
+ return rc;
}
private Map<LinkId, PceLink> allPceLinks = null;
}
public PceResult buildDescriptions() {
- LOG.info("In buildDescriptions: AtoZ {}", this.pathAtoZ.toString());
+ LOG.info("In buildDescriptions: AtoZ = {}", pathAtoZ.toString());
List<AToZ> atozList = new ArrayList<AToZ>();
- if (this.pathAtoZ == null) {
- this.rc.setRC(ResponseCodes.RESPONSE_FAILED);
+ if (pathAtoZ == null) {
+ rc.setRC(ResponseCodes.RESPONSE_FAILED);
LOG.error("In buildDescriptions: there is empty AtoZ path");
- return this.rc;
+ return rc;
}
- buildAtoZ(atozList, this.pathAtoZ);
-
- this.rc.setAtoZDirection(new AToZDirectionBuilder().setRate(this.rc.getRate())
- .setAToZWavelengthNumber(this.rc.getResultWavelength()).setAToZ(atozList).build());
-
- this.pathZtoA = ImmutableList.copyOf(this.pathAtoZ).reverse();
- LOG.info("In buildDescriptions: ZtoA {}", this.pathZtoA.toString());
+ buildAtoZ(atozList, pathAtoZ);
+ AToZDirectionBuilder atoZDirectionBldr = new AToZDirectionBuilder()
+ .setRate(rc.getRate())
+ .setAToZ(atozList);
+ if ("100GE".equals(rc.getServiceType()) || "OTU4".equals(rc.getServiceType())) {
+ atoZDirectionBldr.setAToZWavelengthNumber(rc.getResultWavelength());
+ } else if ("10GE".equals(rc.getServiceType()) || "1GE".equals(rc.getServiceType())
+ || "ODU4".equals(rc.getServiceType())) {
+ atoZDirectionBldr.setAToZWavelengthNumber(Long.valueOf(0));
+ }
+ rc.setAtoZDirection(atoZDirectionBldr.build());
+ pathZtoA = ImmutableList.copyOf(pathAtoZ).reverse();
+ LOG.info("In buildDescriptions: ZtoA {}", pathZtoA.toString());
List<ZToA> ztoaList = new ArrayList<ZToA>();
- if (this.pathZtoA == null) {
- this.rc.setRC(ResponseCodes.RESPONSE_FAILED);
+ if (pathZtoA == null) {
+ rc.setRC(ResponseCodes.RESPONSE_FAILED);
LOG.error("In buildDescriptions: there is empty ZtoA path");
- return this.rc;
+ return rc;
}
- buildZtoA(ztoaList, this.pathZtoA);
-
- this.rc.setZtoADirection(new ZToADirectionBuilder().setRate(this.rc.getRate())
- .setZToAWavelengthNumber(this.rc.getResultWavelength()).setZToA(ztoaList).build());
+ buildZtoA(ztoaList, pathZtoA);
+ ZToADirectionBuilder ztoADirectionBldr = new ZToADirectionBuilder()
+ .setRate(rc.getRate())
+ .setZToA(ztoaList);
+ if ("100GE".equals(rc.getServiceType()) || "OTU4".equals(rc.getServiceType())) {
+ ztoADirectionBldr.setZToAWavelengthNumber(rc.getResultWavelength());
+ } else if ("10GE".equals(rc.getServiceType()) || "1GE".equals(rc.getServiceType())
+ || "ODU4".equals(rc.getServiceType())) {
+ ztoADirectionBldr.setZToAWavelengthNumber(Long.valueOf(0));
+ }
+ rc.setZtoADirection(ztoADirectionBldr.build());
- return this.rc;
+ return rc;
}
private void buildAtoZ(List<AToZ> etoeList, List<PceLink> path) {
-
Integer index = 0;
PceLink lastLink = null;
AToZ lastResource = null;
Resource clientResource = new ResourceBuilder().setResource(stp).build();
AToZ firstResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
etoeList.add(firstResource);
-
index++;
-
for (PceLink pcelink : path) {
-
String srcName = pcelink.getSourceId().getValue();
-
// Nodes
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
.resource.resource.resource.Node sourceNode = new NodeBuilder()
.build();
// Resource
- AToZKey srcTPKey = new AToZKey(index.toString());// tpName);
+ AToZKey srcTPKey = new AToZKey(index.toString());
Resource tpResource1 = new ResourceBuilder().setResource(stp).build();
AToZ stpResource = new AToZBuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build();
index++;
// target TP
tpName = pcelink.getDestTP().toString();
TerminationPoint dtp = new TerminationPointBuilder()
- .setTpNodeId(destName).setTpId(tpName)
- .build();
+ .setTpNodeId(destName).setTpId(tpName)
+ .build();
// Resource
AToZKey destTPKey = new AToZKey(index.toString());