X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2FPcePathDescription.java;h=bc15bf50e68b4a0a30f3744cd6c1653fbc42d30e;hb=66716f66f3fd859a9bbfceac0a50f2e67e626e92;hp=bb29feb6d4f49f9b474aa18c492af47f74f49943;hpb=62fc6625966276207a38955eaf07988f77f6984f;p=transportpce.git diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java b/pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java index bb29feb6d..bc15bf50e 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java @@ -14,21 +14,23 @@ 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; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.atoz.direction.AToZBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.atoz.direction.AToZKey; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ztoa.direction.ZToA; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ztoa.direction.ZToABuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ztoa.direction.ZToAKey; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce.resource.Resource; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce.resource.ResourceBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.LinkBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.NodeBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.TerminationPoint; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.TerminationPointBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.AToZDirectionBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.ZToADirectionBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.atoz.direction.AToZ; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.atoz.direction.AToZBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.atoz.direction.AToZKey; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.ztoa.direction.ZToA; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.ztoa.direction.ZToABuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.ztoa.direction.ZToAKey; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce.resource.Resource; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce.resource.ResourceBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce.resource.resource.resource.LinkBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce.resource.resource.resource.NodeBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce.resource.resource.resource.TerminationPoint; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.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.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,16 +39,10 @@ public class PcePathDescription { private static final Logger LOG = LoggerFactory.getLogger(PcePathDescription.class); private List pathAtoZ = null; + private List pathZtoA = null; private PceResult rc; - - public PceResult getReturnStructure() { - return rc; - } - private Map allPceLinks = null; - private List pathZtoA = null; - public PcePathDescription(List pathAtoZ, Map allPceLinks, PceResult rc) { super(); this.allPceLinks = allPceLinks; @@ -55,8 +51,8 @@ public class PcePathDescription { } public PceResult buildDescriptions() { - LOG.info("In buildDescriptions: AtoZ = {}", pathAtoZ.toString()); - List atozList = new ArrayList(); + LOG.info("In buildDescriptions: AtoZ = {}", pathAtoZ); + List atozList = new ArrayList<>(); if (pathAtoZ == null) { rc.setRC(ResponseCodes.RESPONSE_FAILED); LOG.error("In buildDescriptions: there is empty AtoZ path"); @@ -65,19 +61,27 @@ public class PcePathDescription { buildAtoZ(atozList, pathAtoZ); AToZDirectionBuilder atoZDirectionBldr = new AToZDirectionBuilder() - .setRate(rc.getRate()) + .setRate(Uint32.valueOf(rc.getRate())) .setAToZ(atozList); if ("100GE".equals(rc.getServiceType()) || "OTU4".equals(rc.getServiceType())) { - atoZDirectionBldr.setAToZWavelengthNumber(rc.getResultWavelength()); + atoZDirectionBldr.setAToZWavelengthNumber(Uint32.valueOf(rc.getResultWavelength())); } else if ("10GE".equals(rc.getServiceType()) || "1GE".equals(rc.getServiceType()) || "ODU4".equals(rc.getServiceType())) { - atoZDirectionBldr.setAToZWavelengthNumber(Long.valueOf(0)); + if (rc.getResultTribSlot() != null && rc.getResultTribPort() != null) { + List tribSlotList = (List) rc.getResultTribSlot().values().toArray()[0]; + atoZDirectionBldr.setAToZWavelengthNumber(Uint32.valueOf(0)) + .setTribPortNumber(Uint16.valueOf(rc.getResultTribPort().values().toArray()[0].toString())) + .setTribSlotNumber(tribSlotList.get(0)); + } else { + LOG.error("Trib port and trib slot number should be present"); + atoZDirectionBldr.setTribSlotNumber(Uint16.valueOf(0)).setTribPortNumber(Uint16.valueOf(0)); + } } rc.setAtoZDirection(atoZDirectionBldr.build()); pathZtoA = ImmutableList.copyOf(pathAtoZ).reverse(); - LOG.info("In buildDescriptions: ZtoA {}", pathZtoA.toString()); + LOG.info("In buildDescriptions: ZtoA {}", pathZtoA); - List ztoaList = new ArrayList(); + List ztoaList = new ArrayList<>(); if (pathZtoA == null) { rc.setRC(ResponseCodes.RESPONSE_FAILED); LOG.error("In buildDescriptions: there is empty ZtoA path"); @@ -85,13 +89,21 @@ public class PcePathDescription { } buildZtoA(ztoaList, pathZtoA); ZToADirectionBuilder ztoADirectionBldr = new ZToADirectionBuilder() - .setRate(rc.getRate()) + .setRate(Uint32.valueOf(rc.getRate())) .setZToA(ztoaList); if ("100GE".equals(rc.getServiceType()) || "OTU4".equals(rc.getServiceType())) { - ztoADirectionBldr.setZToAWavelengthNumber(rc.getResultWavelength()); + ztoADirectionBldr.setZToAWavelengthNumber(Uint32.valueOf(rc.getResultWavelength())); } else if ("10GE".equals(rc.getServiceType()) || "1GE".equals(rc.getServiceType()) || "ODU4".equals(rc.getServiceType())) { - ztoADirectionBldr.setZToAWavelengthNumber(Long.valueOf(0)); + if (rc.getResultTribSlot() != null && rc.getResultTribPort() != null) { + List tribSlotList = (List) rc.getResultTribSlot().values().toArray()[0]; + ztoADirectionBldr.setZToAWavelengthNumber(Uint32.valueOf(0)) + .setTribPortNumber(Uint16.valueOf(rc.getResultTribPort().values().toArray()[0].toString())) + .setTribSlotNumber(tribSlotList.get(0)); + } else { + LOG.error("Trib port and trib slot number should be present"); + ztoADirectionBldr.setTribSlotNumber(Uint16.valueOf(0)).setTribPortNumber(Uint16.valueOf(0)); + } } rc.setZtoADirection(ztoADirectionBldr.build()); @@ -114,11 +126,11 @@ public class PcePathDescription { Resource clientResource = new ResourceBuilder().setResource(stp).build(); AToZ firstResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build(); etoeList.add(firstResource); - index++; + index += 1; for (PceLink pcelink : path) { String srcName = pcelink.getSourceId().getValue(); // Nodes - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce .resource.resource.resource.Node sourceNode = new NodeBuilder() .setNodeId(srcName) .build(); @@ -127,7 +139,7 @@ public class PcePathDescription { AToZKey sourceKey = new AToZKey(index.toString()); Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build(); AToZ srcResource = new AToZBuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build(); - index++; + index += 1; etoeList.add(srcResource); // source TP @@ -140,12 +152,12 @@ public class PcePathDescription { 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++; + index += 1; etoeList.add(stpResource); String linkName = pcelink.getLinkId().getValue(); // Link - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce .resource.resource.resource.Link atozLink = new LinkBuilder() .setLinkId(linkName) .build(); @@ -154,7 +166,7 @@ public class PcePathDescription { AToZKey linkKey = new AToZKey(index.toString()); Resource nodeResource2 = new ResourceBuilder().setResource(atozLink).build(); AToZ linkResource = new AToZBuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build(); - index++; + index += 1; etoeList.add(linkResource); String destName = pcelink.getDestId().getValue(); @@ -168,10 +180,10 @@ public class PcePathDescription { AToZKey destTPKey = new AToZKey(index.toString()); Resource tpResource2 = new ResourceBuilder().setResource(dtp).build(); AToZ ttpResource = new AToZBuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build(); - index++; + index += 1; etoeList.add(ttpResource); - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce .resource.resource.resource.Node targetNode = new NodeBuilder() .setNodeId(destName) .build(); @@ -193,8 +205,7 @@ public class PcePathDescription { .setTpNodeId(xname).setTpId(tpName) .build(); - - index++; + index += 1; clientKey = new AToZKey(index.toString()); clientResource = new ResourceBuilder().setResource(stp).build(); lastResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build(); @@ -219,18 +230,18 @@ public class PcePathDescription { Resource clientResource = new ResourceBuilder().setResource(stp).build(); ZToA firstResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build(); etoelist.add(firstResource); - index++; + index += 1; for (PceLink pcelinkAtoZ : path) { pcelink = this.allPceLinks.get(pcelinkAtoZ.getOppositeLink()); - LOG.debug("link to oppsite: {} to {}", pcelinkAtoZ.toString(), pcelink.toString()); + LOG.debug("link to oppsite: {} to {}", pcelinkAtoZ, pcelink); String srcName = pcelink.getSourceId().getValue(); // Nodes - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce .resource.resource.resource.Node sourceNode = new NodeBuilder() .setNodeId(srcName).build(); @@ -239,7 +250,7 @@ public class PcePathDescription { ZToAKey sourceKey = new ZToAKey(index.toString()); Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build(); ZToA srcResource = new ZToABuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build(); - index++; + index += 1; etoelist.add(srcResource); // source TP @@ -252,12 +263,12 @@ public class PcePathDescription { ZToAKey srcTPKey = new ZToAKey(index.toString()); Resource tpResource1 = new ResourceBuilder().setResource(stp).build(); ZToA stpResource = new ZToABuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build(); - index++; + index += 1; etoelist.add(stpResource); String linkName = pcelink.getLinkId().getValue(); // Link - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce .resource.resource.resource.Link ztoaLink = new LinkBuilder() .setLinkId(linkName).build(); @@ -265,7 +276,7 @@ public class PcePathDescription { ZToAKey linkKey = new ZToAKey(index.toString()); Resource nodeResource2 = new ResourceBuilder().setResource(ztoaLink).build(); ZToA linkResource = new ZToABuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build(); - index++; + index += 1; etoelist.add(linkResource); String destName = pcelink.getDestId().getValue(); @@ -278,11 +289,11 @@ public class PcePathDescription { ZToAKey destTPKey = new ZToAKey(index.toString()); Resource tpResource2 = new ResourceBuilder().setResource(ttp).build(); ZToA ttpResource = new ZToABuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build(); - index++; + index += 1; etoelist.add(ttpResource); - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce .resource.resource.resource.Node targetNode = new NodeBuilder() .setNodeId(destName).build(); // Target Resource @@ -300,13 +311,14 @@ public class PcePathDescription { stp = new TerminationPointBuilder() .setTpNodeId(xname).setTpId(tpName).build(); - - index++; + index += 1; clientKey = new ZToAKey(index.toString()); clientResource = new ResourceBuilder().setResource(stp).build(); lastResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build(); etoelist.add(lastResource); - } + public PceResult getReturnStructure() { + return rc; + } }