import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaces;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.NodeTypes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.PortsKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacksKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.ConnectionPorts;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.DegreeKey;
*/
public boolean createMappingData() {
- LOG.info(" Create Mapping Data for node " + nodeId);
+ LOG.info("Create Mapping Data for node " + nodeId);
DataBroker deviceDb = getDeviceDataBroker(nodeId, mps);
- Info deviceInfo = getDeviceInfo(deviceDb);
List<Mapping> portMapList = new ArrayList<>();
-
+ Info deviceInfo;
+ Integer nodeType = 1;
if (deviceDb != null) {
+ deviceInfo = getDeviceInfo(deviceDb);
if (deviceInfo != null) {
- Integer nodeType = deviceInfo.getNodeType().getIntValue();
+ if (deviceInfo.getNodeType() == null) {
+ LOG.info("Node type mandatory field is missing");
+ return false;
+ }
+ nodeType = deviceInfo.getNodeType().getIntValue();
// Create Mapping for Roadm Node
if (nodeType == 1) {
// Get TTP port mapping
}
}
} else {
- LOG.info(" Device info subtree is absent for " + nodeId);
+ LOG.info("Device info subtree is absent for " + nodeId);
return false;
}
} else {
- LOG.info(" Unable to get Data broker for node " + nodeId);
+ LOG.info("Unable to get Data broker for node " + nodeId);
return false;
}
- return postPortMapping(deviceInfo, portMapList);
+ return postPortMapping(deviceInfo, portMapList, nodeType);
}
/**
}
} catch (InterruptedException | ExecutionException ex) {
LOG.warn("Read failed for Logical Connection Point value missing for " + circuitPackName + " "
- + portName);
+ + portName,ex);
return false;
}
}
}
} catch (InterruptedException | ExecutionException ex) {
- LOG.warn("Read failed for " + circuitPackName);
+ LOG.warn("Read failed for " + circuitPackName,ex);
return false;
}
}
}
} catch (InterruptedException | ExecutionException ex) {
- LOG.warn("Read failed for CircuitPacks of " + nodeId);
+ LOG.warn("Read failed for CircuitPacks of " + nodeId,ex);
return false;
}
return true;
// Get OMS and OTS interface provisioned on the TTP's
if (logicalConnectionPoint.contains("TTP") && port.getInterfaces() != null) {
for (Interfaces interfaces : port.getInterfaces()) {
- Class<? extends InterfaceType> interfaceType = getInterfaceType(deviceDb, interfaces
- .getInterfaceName());
+ Class<? extends InterfaceType> interfaceType = new OpenRoadmInterfaces(db, mps, nodeId,
+ logicalConnectionPoint).getInterface(interfaces.getInterfaceName()).getType();
// Check if interface type is OMS or OTS
if (interfaceType.equals(OpenROADMOpticalMultiplex.class)) {
String omsInterfaceName = interfaces.getInterfaceName();
return mpBldr.build();
}
- /**
- * This private does a get on the interface subtree of the device with the
- * interface name as the key and return the class corresponding to the
- * interface type.
- *
- * @param interfaceName
- * Name of the interface
- * @param deviceDb
- * Reference to device's databroker.
- *
- * @return true/false based on status of operation
- */
-
- private Class<? extends InterfaceType> getInterfaceType(DataBroker deviceDb, String interfaceName) {
- ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction();
- InstanceIdentifier<Interface> interfacesIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(
- Interface.class, new InterfaceKey(interfaceName));
- try {
- Optional<Interface> interfaceObject = rtx.read(LogicalDatastoreType.OPERATIONAL, interfacesIID).get();
- if (interfaceObject.isPresent()) {
- return interfaceObject.get().getType();
- } else {
- LOG.info("Interface subtree is not present for " + interfaceName);
- }
- } catch (InterruptedException | ExecutionException ex) {
- LOG.info("Read failed on interface subtree for");
- return null;
- }
- return null;
- }
-
/**
* This method does a get operation on info subtree of the netconf device's
* configuration datastore and returns info object.It is required to get
try {
Optional<Info> ordmInfoObject = rtx.read(LogicalDatastoreType.OPERATIONAL, infoIID).get();
if (ordmInfoObject.isPresent()) {
+ LOG.info("Info subtree is present {}", ordmInfoObject.get());
return ordmInfoObject.get();
} else {
- LOG.info("Info subtree is not present");
+ LOG.error("Info subtree is not present");
}
+ } catch (NullPointerException ex) {
+ LOG.warn("Try to get Info from a non Open ROADM device {}", deviceDb);
+ return null;
} catch (InterruptedException | ExecutionException ex) {
- LOG.info("Read failed on info subtree for");
+ LOG.error("Read failed on info subtree ", ex);
return null;
}
return null;
Optional<Degree> ordmDegreeObject = rtx.read(LogicalDatastoreType.CONFIGURATION, deviceIID).get();
if (ordmDegreeObject.isPresent()) {
- degreeConPorts.addAll(new ArrayList<ConnectionPorts>(ordmDegreeObject.get().getConnectionPorts()));
+ degreeConPorts.addAll(new ArrayList<>(ordmDegreeObject.get().getConnectionPorts()));
} else {
LOG.info("Device has " + (degreeCounter - 1) + " degree");
break;
}
} catch (InterruptedException | ExecutionException ex) {
- LOG.info("Failed to read degree " + degreeCounter);
+ LOG.error("Failed to read degree " + degreeCounter,ex);
break;
}
if (ordmSrgObject.isPresent()) {
srgCps.addAll(
- new ArrayList<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg
- .CircuitPacks>(ordmSrgObject.get().getCircuitPacks()));
+ new ArrayList<>(ordmSrgObject.get().getCircuitPacks()));
} else {
LOG.info("Device has " + (srgCounter - 1) + " Srg");
break;
}
} catch (InterruptedException | ExecutionException ex) {
- LOG.warn("Failed to read Srg " + srgCounter);
+ LOG.warn("Failed to read Srg " + srgCounter,ex);
break;
}
srgCounter++;
*
* @return Result true/false based on status of operation.
*/
- private boolean postPortMapping(Info deviceInfo, List<Mapping> portMapList) {
+ private boolean postPortMapping(Info deviceInfo, List<Mapping> portMapList, Integer nodeType) {
- List<Nodes> nodesList = new ArrayList<>();
NodesBuilder nodesBldr = new NodesBuilder();
nodesBldr.setKey(new NodesKey(deviceInfo.getNodeId())).setNodeId(deviceInfo.getNodeId());
+ nodesBldr.setNodeType(NodeTypes.forValue(nodeType));
nodesBldr.setMapping(portMapList);
+ List<Nodes> nodesList = new ArrayList<>();
nodesList.add(nodesBldr.build());
NetworkBuilder nwBldr = new NetworkBuilder();
nwBldr.setNodes(nodesList);
* Unique Identifier for the node of interest.
* @param logicalConnPoint
* Name of the logical point
+ * @param db
+ * Databroker / MD-SAL data store
*
* @return Result Mapping object if success otherwise null.
*/
return null;
}
} catch (InterruptedException | ExecutionException ex) {
- LOG.info("Unable to read mapping for logical connection point : " + logicalConnPoint + " for nodeId "
- + nodeId);
+ LOG.error("Unable to read mapping for logical connection point : " + logicalConnPoint + " for nodeId "
+ + nodeId,ex);
}
return null;
}
* @return Databroker for the given device
*/
public static DataBroker getDeviceDataBroker(String nodeId, MountPointService mps) {
+ MountPoint netconfNode = getDeviceMountPoint(nodeId, mps);
+ if (netconfNode != null) {
+ DataBroker netconfNodeDataBroker = netconfNode.getService(DataBroker.class).get();
+ return netconfNodeDataBroker;
+ } else {
+ LOG.error("Device Data broker not found for :" + nodeId);
+ return null;
+ }
+ }
+
+ public static MountPoint getDeviceMountPoint(String nodeId, MountPointService mps) {
InstanceIdentifier<Node> netconfNodeIID = InstanceIdentifier.builder(NetworkTopology.class).child(
Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))).child(Node.class,
new NodeKey(new NodeId(nodeId))).build();
- // Get the mount point for the specified node
+ // Get mount point for specified device
final Optional<MountPoint> netconfNodeOptional = mps.getMountPoint(netconfNodeIID);
if (netconfNodeOptional.isPresent()) {
MountPoint netconfNode = netconfNodeOptional.get();
- // Get the DataBroker for the mounted node
- DataBroker netconfNodeDataBroker = netconfNode.getService(DataBroker.class).get();
- return netconfNodeDataBroker;
+ return netconfNode;
} else {
- LOG.info("Device Data broker not found for :" + nodeId);
+ LOG.error("Mount Point not found for :" + nodeId);
+ return null;
}
- return null;
+
}
-}
\ No newline at end of file
+}