import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.transportpce.common.NetworkUtils;
-//import org.opendaylight.yang.gen.v1.gnpy.gnpy.eqpt.config.rev181119.EdfaVariety;
-//import org.opendaylight.yang.gen.v1.gnpy.gnpy.eqpt.config.rev181119.FiberVariety;
import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Coordinate;
import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Km;
import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.Operational;
import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.SynchronizationBuilder;
import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.Svec;
import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.SvecBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.AmplifiedLink;
import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.Span;
import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.ila.Ila;
public class ExtractTopoDataStoreImpl {
private static final Logger LOG = LoggerFactory.getLogger(ExtractTopoDataStoreImpl.class);
private final DataBroker dataBroker;
- // private final OpenRoadmTopology openRoadmTopology;
- // private final OpenRoadmInterfaces openRoadmInterfaces;
private List<Elements> elements = new ArrayList<>();
private List<Connections> connections = new ArrayList<>();
private List<PathRequest> pathRequest = new ArrayList<>();
} else {
elements = null;
}
- if (map.containsKey("Elements")) {
+ if (map.containsKey("Connections")) {
connections = (List<Connections>) map.get("Connections");
} else {
connections = null;
}
+
pathRequest = extractPathRequest(input, atoz, requestId);
synchronization = extractSynchronization(requestId);
}
} else {
elements = null;
}
- if (map.containsKey("Elements")) {
+ if (map.containsKey("Connections")) {
connections = (List<Connections>) map.get("Connections");
} else {
connections = null;
// Create the list of connections
Network1 nw1 = openRoadmTopo.get().augmentation(Network1.class);
List<Link> linksList = nw1.getLink();
- // 1:EXPRESS-LINK ; 2:ADD-LINK ; 3:DROP-LINK ;
- // 4:ROADM-To-ROADM ; 5:XPONDER-INPUT ; 6:XPONDER-OUTPUT
+ // 1:EXPRESS-LINK 2:ADD-LINK 3:DROP-LINK
+ // 4:ROADM-To-ROADM 5:XPONDER-INPUT 6:XPONDER-OUTPUT
int[] externalLink = {4,5,6};
int idFiber = 0;
int nbEDFA = 0;
if (!linksList.isEmpty()) {
- LOG.warn("The link list is not empty");
+ LOG.debug("The link list is not empty");
for (Link link : linksList) {
Link1 link1 = link.augmentation(Link1.class);
int linkType = link1.getLinkType().getIntValue();
nbEDFA++;
mapDisgNodeRefNode.put(nodeId, nodeId);
mapNodeRefIp.put(nodeId, ipEdfa);
- // class std_medium_gain
- // implements EdfaVariety {}
element1 = addElementsEdfa(2, 0, "RLD", "Lannion_CAS",
ila.getGain().getValue(), ila.getTilt().getValue(),
ila.getOutVoaAtt().getValue(), "std_medium_gain",
mapLinkFiber.put(link.getLinkId().getValue(), clfi);
mapFiberIp.put(clfi, ipFiber);
idFiber++;
- // class SSMF implements
- // FiberVariety {}
element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0,
"SSMF");
mapFiberIp.put(clfi, ipFiber);
idFiber++;
- double attIn = span.getSpanlossCurrent().getValue().doubleValue();
- double lossCoef = 0.2;
+ double attIn = 0;
double connIn = 0;
double connOut = 0;
String typeVariety = "SSMF";
- double length = 0; //convert to kilometer
+ double length = 0;
// Compute the length of the link
List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
for (LinkConcatenation linkConcatenation : linkConcatenationList) {
double srlgLength = linkConcatenation.getSRLGLength();
- length += srlgLength / convertKmM; //convert to kilometer
+ //convert to kilometer
+ length += srlgLength / convertKmM;
}
+ double lossCoef = span.getSpanlossCurrent().getValue().doubleValue() / length;
Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
ipFiber.getIpv4Address().getValue(), length, attIn, lossCoef, connIn,
mapFiberIp.put(clfi, ipFiber);
idFiber++;
// Create a new element
- // class SSMF implements FiberVariety {}
Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0, "SSMF");
topoElements.add(element1);
// List of A to Z
List<AToZ> listAtoZ = atoz.getAToZ();
int atozSize = listAtoZ.size();
- // String modulationFormat = atoz.getModulationFormat();
// Create the path request
List<PathRequest> pathRequestList = new ArrayList<>();
- // Define the instance identifier
- // InstanceIdentifier<Network> nwInstanceIdentifier = InstanceIdentifier
- // .builder(Network.class, new NetworkKey(new
- // NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
-
- // read the configuration part of the data broker that concerns the
- // nodes ID and get all the nodes
- // java.util.Optional<Network> networkObject = readOnlyTransaction
- // .read(LogicalDatastoreType.CONFIGURATION,
- // nwInstanceIdentifier).get().toJavaUtil();
+
// 1.1 Create explicitRouteObjects
// 1.1.1. create RouteObjectIncludeExclude list
List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
IpAddress ipAddressCurrent = null;
Long index = (long) 0;
- //ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction();
for (int i = 0; i < atozSize; i++) {
- // String idAtoZ = listAtoZ.get(i).getId();
String nodeId = null;
if (listAtoZ.get(i).getResource()
.getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
for (Elements element : elements) {
if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
- String type = element.getType().getName();
if ((ipAddressCurrent == null) || (ipAddressCurrent != ipAddress)) {
ipAddressCurrent = ipAddress;
// Fill in routeObjectIncludeExcludes
} else {
LOG.warn("node ID is null");
}
- } else if (listAtoZ.get(i).getResource()
- .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
- .pathdescription.rev171017.pce.resource.resource.resource.TerminationPoint) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
- .resource.resource.resource.TerminationPoint tp = (org.opendaylight.yang.gen.v1.http.org
- .transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource
- .TerminationPoint) listAtoZ.get(i).getResource().getResource();
- // Not used in this version
+ //TODO else if termination point not implemented in this version
} else if (listAtoZ.get(i).getResource()
.getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
.pathdescription.rev171017.pce.resource.resource.resource.Link) {
// 1. Create the path request element 1
// Find parameters
- // String serviceName = input.getServiceName();
String sourceNode = input.getServiceAEnd().getNodeId();
String destNode = input.getServiceZEnd().getNodeId();
// 1.2 Create a path constraints
Long rate = atoz.getRate();
- // Long wavelengthNumber = atoz.getAToZWavelengthNumber();
// Create EffectiveFreqSlot
List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
.setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
.setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
- // .setMaxNbOfChannel(new Long(80)).setOutputPower(new
- // BigDecimal(0.0012589254117941673))
PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
- // PathRequest pathRequest1 = new
- // PathRequestBuilder().setRequestId(new
- // Long(0)).setSource(mapNodeRefIp.get(sourceNode))
- // .setDestination(mapNodeRefIp.get(destNode)).setSrcTpId(input.getServiceAEnd().getTxDirection()
- // .getPort().getPortName().getBytes())
- // .setDstTpId(input.getServiceAEnd().getRxDirection().getPort().getPortName().getBytes())
- // .setPathConstraints(pathConstraints)
- // .setExplicitRouteObjects(explicitRouteObjects).build();
PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
.setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
.setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
.setExplicitRouteObjects(explicitRouteObjects).build();
pathRequestList.add(pathRequest1);
- //readOnlyTransaction.close();
return pathRequestList;
}
// List of A to Z
List<ZToA> listZToA = ztoa.getZToA();
int ztoaSize = listZToA.size();
- // String modulationFormat = ztoa.getModulationFormat();
// Create the path request
List<PathRequest> servicePathRequest = new ArrayList<>();
- // Define the instance identifier
- InstanceIdentifier<Network> nwInstanceIdentifier = InstanceIdentifier
- .builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
- //ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction();
- // read the configuration part of the data broker that concerns the
- // nodes ID and get all the nodes
- // java.util.Optional<Network> networkObject = readOnlyTransaction
- // .read(LogicalDatastoreType.CONFIGURATION,
- // nwInstanceIdentifier).get().toJavaUtil();
// 1.1 Create explicitRouteObjects
// 1.1.1. create RouteObjectIncludeExclude list
List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
IpAddress ipAddressCurrent = null;
Long index = (long) 0;
for (int i = 0; i < ztoaSize; i++) {
- // String idZtoA = listZToA.get(i).getId();
String nodeId = null;
if (listZToA.get(i).getResource()
.getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
for (Elements element : elements) {
if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
- // String type = element.getType().getName();
if ((ipAddressCurrent == null) || (ipAddressCurrent != ipAddress)) {
ipAddressCurrent = ipAddress;
// Fill in routeObjectIncludeExcludes
} else {
LOG.warn("node ID is null");
}
- } else if (listZToA.get(i).getResource()
- .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
- .pathdescription.rev171017.pce.resource.resource.resource.TerminationPoint) {
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
- .resource.resource.resource.TerminationPoint tp = (org.opendaylight.yang.gen.v1.http.org
- .transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource
- .TerminationPoint) listZToA.get(i).getResource().getResource();
- // Not used in this version
+ //TODO else if termination point not implemented in this version
} else if (listZToA.get(i).getResource()
.getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
.pathdescription.rev171017.pce.resource.resource.resource.Link) {
// 1. Create the path request element 1
// Find parameters
- // String serviceName = input.getServiceName();
String sourceNode = input.getServiceZEnd().getNodeId();
String destNode = input.getServiceAEnd().getNodeId();
// 1.2 Create a path constraints
Long rate = ztoa.getRate();
- // Long wavelengthNumber = ztoa.getZToAWavelengthNumber();
// Create EffectiveFreqSlot
List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
.setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
.setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
- // .setMaxNbOfChannel(new Long(80)).setOutputPower(new
- // BigDecimal(0.0012589254117941673))
PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
- // PathRequest pathRequest1 = new
- // PathRequestBuilder().setRequestId(new
- // Long(0)).setSource(mapNodeRefIp.get(sourceNode))
- // .setDestination(mapNodeRefIp.get(destNode)).setSrcTpId(input.getServiceAEnd().getTxDirection()
- // .getPort().getPortName().getBytes())
- // .setDstTpId(input.getServiceAEnd().getRxDirection().getPort().getPortName().getBytes())
- // .setPathConstraints(pathConstraints)
- // .setExplicitRouteObjects(explicitRouteObjects).build();
PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
.setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
.setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
.setExplicitRouteObjects(explicitRouteObjects).build();
servicePathRequest.add(pathRequest1);
- //readOnlyTransaction.close();
return servicePathRequest;
}
public List<Synchronization> extractSynchronization(Long requestId) {
// Create RequestIdNumber
List<Long> requestIdNumber = new ArrayList<>();
- requestIdNumber.add(0, new Long(0));
+ requestIdNumber.add(requestId);
// Create a synchronization
Svec svec = new SvecBuilder().setRelaxable(true).setDisjointness(new TePathDisjointness(true, true, false))
.setRequestIdNumber(requestIdNumber).build();
.setAttIn(new BigDecimal(attIn)).setLossCoef(new BigDecimal(lossCoef)).setConIn(new BigDecimal(connIn))
.setConOut(new BigDecimal(connOut)).build();
Params params1 = new ParamsBuilder().setFiberroadm(fiber).build();
- // TypeElement Fiber = ; //new TypeElement(Fiber);
Elements element1 = new ElementsBuilder().setUid(clfi)
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Fiber.class)
.setTypeVariety(typeVariety).setMetadata(metadata1)
Operational operational = new OperationalBuilder().setGainTarget(gainTarget).setTiltTarget(tiltTarget)
.setOutVoa(outVoa).build();
Edfa edfa = new EdfaBuilder()
- // .setTypeVariety(typeVariety)
.setOperational(operational).build();
- Elements element1 = new ElementsBuilder().setUid(uidEdfa) // Choose an
- // ip
- // address
+ Elements element1 = new ElementsBuilder().setUid(uidEdfa)
+ // Choose an ip address
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
.setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
return element1;
return routeObjectIncludeExclude1;
}
- private String fromToNodeForConnection(String id, IpAddress ip) {
- String fromToNode = id;
- if (ip != null) {
- fromToNode = ip.getIpv4Address().getValue().toString();
- }
- return (fromToNode);
- }
-
private Connections createNewConnection(String srcId, IpAddress srcIp, String destId, IpAddress destIp) {
String fromNode = srcId;
String toNode = destId;
}
public List<PathRequest> createEmptyPathRequest(PathComputationRequestInput input, AToZDirection atoz) {
- // List of A to Z
- // List<AToZ> listAtoZ = atoz.getAToZ();
- // int atozSize = listAtoZ.size();
-
// Create the path request
List<PathRequest> pathRequestList = new ArrayList<>();
// 1. Create the path request element 1
// Find parameters
- // String serviceName = input.getServiceName();
String sourceNode = input.getServiceAEnd().getNodeId();
String destNode = input.getServiceZEnd().getNodeId();