import java.util.concurrent.ExecutionException;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
-
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.NetworkUtils;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
private List<Connections> connections = new ArrayList<>();
//Mapping elements
//Mapping between the ord-topo and ord-ntw node
- private Map<String, String> mapDisgNodeRefNode = new HashMap<String, String>();
+ private Map<String, String> mapDisgNodeRefNode = new HashMap<>();
//Mapping between the ord-ntw and node ip
- private Map<String, IpAddress> mapNodeRefIp = new HashMap<String, IpAddress>();
+ private Map<String, IpAddress> mapNodeRefIp = new HashMap<>();
//Mapping between the ROADM-ROADM linkId/secElement and the linkId
- private Map<String, List<String>> mapLinkFiber = new HashMap<String, List<String>>();
+ private Map<String, List<String>> mapLinkFiber = new HashMap<>();
//Mapping between the ROADM-ROADM linkId/secElement and ipAddress
- private Map<String, IpAddress> mapFiberIp = new HashMap<String, IpAddress>();
+ private Map<String, IpAddress> mapFiberIp = new HashMap<>();
//List of Xponders
private List<String> trxList = new ArrayList<>();
//Initialize the 32 bit identifiers for the edfa and the fiber.
.read(LogicalDatastoreType.CONFIGURATION, insIdrOpenRoadmNet).get();
if (openRoadmNet.isPresent() && openRoadmTopo.isPresent()) {
extractElements(openRoadmTopo,openRoadmNet);
- extractConnections(openRoadmTopo,openRoadmNet);
+ extractConnections(openRoadmTopo);
LOG.debug("In GnpyTopoImpl : elements and connections are well extracted");
}
else {
private void extractElements(java.util.Optional<Network> openRoadmTopo,
java.util.Optional<Network> openRoadmNet) throws GnpyException {
+ if ((!openRoadmNet.isPresent()) || (!openRoadmTopo.isPresent())) {
+ throw new GnpyException("In gnpyTopoImpl: openRoadmNet or openRoadmTopo is not present");
+ }
// Create the list of nodes
List<Node> openRoadmNetNodeList = openRoadmNet.get().getNode();
List<Node> openRoadmTopoNodeList = openRoadmTopo.get().getNode();
for (Node openRoadmTopoNode : openRoadmTopoNodeList) {
// Retrieve the supporting node and the type of the node in openRoadm network
List<SupportingNode> supportingNodeList = openRoadmTopoNode.getSupportingNode();
+
for (SupportingNode supportingNode : supportingNodeList) {
+ if (!supportingNode.getNetworkRef().getValue().equals("openroadm-network")) {
+ continue;
+ }
IpAddress ipAddress = null;
String nodeRef = supportingNode.getNodeRef().getValue();
+ if (nodeRef == null) {
+ throw new GnpyException("In gnpyTopoImpl: nodeRef is null");
+ }
// Retrieve the mapping between the openRoadm topology and openRoadm network
mapDisgNodeRefNode.put(openRoadmTopoNode.getNodeId().getValue(), nodeRef);
Node1 openRoadmNetNode1 = null;
commonNetworkNode1 = openRoadmNetNode.augmentation(org.opendaylight.yang.gen.v1
.http.org.openroadm.common.network.rev181130.Node1.class);
ipAddress = openRoadmNetNode1.getIp();
+ if (ipAddress == null) {
+ throw new GnpyException(String.format(
+ "In gnpyTopoImpl: ipAddress of node %s is null",nodeRef));
+ }
mapNodeRefIp.put(nodeRef, ipAddress);
break;
}
}
+ if (commonNetworkNode1 == null) {
+ throw new GnpyException(String.format("In gnpyTopoImpl: the node type of %s is null",nodeRef));
+ }
if (commonNetworkNode1.getNodeType().getName().equals("ROADM")) {
if (!nodesList.contains(nodeRef)) {
Elements element = createElementsRoadm(LATITUDE, LONGITUTE, nodeRef,
- openRoadmNetNode1.getShelf(),TARGET_PCH_OUT_DB, ipAddress.getIpv4Address().getValue()
- .toString());
+ openRoadmNetNode1.getShelf(),TARGET_PCH_OUT_DB, ipAddress.getIpv4Address().getValue());
this.elements.add(element);
nodesList.add(nodeRef);
}
} else if (commonNetworkNode1.getNodeType().getName().equals("XPONDER")) {
if (!nodesList.contains(nodeRef)) {
Elements element = createElementsTransceiver(LATITUDE, LONGITUTE, nodeRef,
- openRoadmNetNode1.getShelf(),ipAddress.getIpv4Address().getValue().toString());
+ openRoadmNetNode1.getShelf(),ipAddress.getIpv4Address().getValue());
this.elements.add(element);
nodesList.add(nodeRef);
trxList.add(nodeRef);
}
}
- private void extractConnections(java.util.Optional<Network> openRoadmTopo,
- java.util.Optional<Network> openRoadmNet) throws GnpyException {
+ private void extractConnections(java.util.Optional<Network> openRoadmTopo) throws GnpyException {
// Create the list of connections
+ if (!openRoadmTopo.isPresent()) {
+ throw new GnpyException("In gnpyTopoImpl: openroadmTopo is not present");
+ }
Network1 nw1 = openRoadmTopo.get().augmentation(Network1.class);
List<Link> linksList = nw1.getLink();
// 1:EXPRESS-LINK 2:ADD-LINK 3:DROP-LINK
org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
.Link1 openroadmNetworkLink1 = link.augmentation(org.opendaylight.yang.gen.v1.http.org
.openroadm.network.topology.rev181130.Link1.class);
+ if (link1.getLinkType() == null) {
+ throw new GnpyException("In gnpyTopoImpl: the link type is null");
+ }
int linkType = link1.getLinkType().getIntValue();
if (! IntStream.of(externalLink).anyMatch(x -> x == linkType)) {
continue;
//Case of Span
if (amplifiedLink.getSectionElement().getSectionElement() instanceof Span) {
Span span = (Span) amplifiedLink.getSectionElement().getSectionElement();
- destIp = extractSpan((SpanAttributes) span.getSpan(), linkId, secElt);
+ destIp = extractSpan(span.getSpan(), linkId, secElt);
}
// Create a new link
if (createNewConnection(srcIp,destIp)) {
throws GnpyException {
SpanAttributes span = omsAttributes.getSpan();
- IpAddress destIp = extractSpan((SpanAttributes) span, linkId, linkId);
+ IpAddress destIp = extractSpan(span, linkId, linkId);
if (createNewConnection(srcIp, destIp)) {
return destIp;
}
Elements element = createElementsEdfa(LATITUDE, LONGITUTE, REGION, CITY,
ila.getGain().getValue(), ila.getTilt().getValue(),
ila.getOutVoaAtt().getValue(), "std_medium_gain",
- ipEdfa.getIpv4Address().getValue().toString());
+ ipEdfa.getIpv4Address().getValue());
this.elements.add(element);
return ipEdfa;
}
// Compute the length of the link
List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
for (LinkConcatenation linkConcatenation : linkConcatenationList) {
- double srlgLength = linkConcatenation.getSRLGLength();
+ double srlgLength = linkConcatenation.getSRLGLength().toJava();
//convert to kilometer
length += srlgLength / CONVERT_KM_M;
}
+ if (length == 0) {
+ throw new GnpyException(String.format(
+ "In gnpyTopoImpl: length of the link %s is equal to zero",linkId));
+ }
double lossCoef = span.getSpanlossCurrent().getValue().doubleValue() / length;
Elements element = createElementsFiber(LATITUDE, LONGITUTE, REGION, CITY,
ipFiber.getIpv4Address().getValue(), length, attIn, lossCoef, connIn, connOut, typeVariety);
private Elements createElementsFiber(double latitude, double longitude, String region, String city, String uidFiber,
double length, double attIn, double lossCoef, double connIn, double connOut, String typeVariety) {
// Create an amplifier after the ROADM
- Coordinate c1 = new Coordinate(new BigDecimal(latitude));
- Coordinate c2 = new Coordinate(new BigDecimal(longitude));
+ Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
+ Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
.build();
Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
- Fiber fiber = new FiberBuilder().setLength(new BigDecimal(length)).setLengthUnits(Km.class)
- .setAttIn(new BigDecimal(attIn)).setLossCoef(new BigDecimal(lossCoef)).setConIn(new BigDecimal(connIn))
- .setConOut(new BigDecimal(connOut)).build();
+ Fiber fiber = new FiberBuilder().setLength(BigDecimal.valueOf(length)).setLengthUnits(Km.class)
+ .setAttIn(BigDecimal.valueOf(attIn)).setLossCoef(BigDecimal.valueOf(lossCoef))
+ .setConIn(BigDecimal.valueOf(connIn))
+ .setConOut(BigDecimal.valueOf(connOut)).build();
Params params1 = new ParamsBuilder().setFiberroadm(fiber).build();
- Elements element1 = new ElementsBuilder().setUid(uidFiber)
+ return new ElementsBuilder().setUid(uidFiber)
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Fiber.class)
.setTypeVariety(typeVariety).setMetadata(metadata1)
.setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
- return element1;
}
/*
private Elements createElementsEdfa(double latitude, double longitude, String region, String city,
BigDecimal gainTarget, BigDecimal tiltTarget, BigDecimal outVoa, String typeVariety, String uidEdfa) {
// Create an amplifier after the ROADM
- Coordinate c1 = new Coordinate(new BigDecimal(latitude));
- Coordinate c2 = new Coordinate(new BigDecimal(longitude));
+ Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
+ Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
.build();
Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
.setOutVoa(outVoa).build();
Edfa edfa = new EdfaBuilder()
.setOperational(operational).build();
- Elements element1 = new ElementsBuilder().setUid(uidEdfa)
+ return new ElementsBuilder().setUid(uidEdfa)
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
.setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
- return element1;
}
/*
private Elements createElementsRoadm(double latitude, double longitude, String region, String city,
double targetPchOutDb, String uidRoadm) {
- Coordinate c1 = new Coordinate(new BigDecimal(latitude));
- Coordinate c2 = new Coordinate(new BigDecimal(longitude));
+ Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
+ Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
.build();
Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
- Roadm roadm = new RoadmBuilder().setTargetPchOutDb(new BigDecimal(targetPchOutDb)).build();
+ Roadm roadm = new RoadmBuilder().setTargetPchOutDb(BigDecimal.valueOf(targetPchOutDb)).build();
Params params1 = new ParamsBuilder().setFiberroadm(roadm).build();
- Elements element1 = new ElementsBuilder().setUid(uidRoadm)
+ return new ElementsBuilder().setUid(uidRoadm)
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Roadm.class)
.setMetadata(metadata1).setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
- return element1;
}
/*
*/
private Elements createElementsTransceiver(double latitude, double longitude, String region, String city,
String uidTrans) {
- Coordinate c1 = new Coordinate(new BigDecimal(latitude));
- Coordinate c2 = new Coordinate(new BigDecimal(longitude));
+ Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
+ Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
.build();
Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
Transceiver transceiver = new TransceiverBuilder().build();
- Elements element1 = new ElementsBuilder().setUid(uidTrans)
+ return new ElementsBuilder().setUid(uidTrans)
.setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Transceiver.class)
.setMetadata(metadata1).setElementType(transceiver).build();
- return element1;
}
/*
}
String fromNode = srcIp.getIpv4Address().getValue();
String toNode = destIp.getIpv4Address().getValue();
- if (fromNode == toNode) {
+ if (fromNode.equals(toNode)) {
return false;
}
Connections connection = new ConnectionsBuilder().setFromNode(fromNode).setToNode(toNode).build();
}
fields[3] = Integer.toString(intF3);
String nidString = fields[0] + "." + fields[1] + "." + fields[2] + "." + fields[3];
- Ipv4Address nid = new Ipv4Address(nidString);
- return nid;
+ return new Ipv4Address(nidString);
}
public List<Elements> getElements() {