*/
Mapping getMapping(String nodeId, String circuitPackName, String portName);
+ /**
+ * This method for a given node's termination point returns the Mapping object
+ * based on portmapping.yang model stored in the MD-SAL data store which is
+ * created when the node is connected for the first time. The mapping object
+ * basically contains the following attributes of interest:
+ *
+ * <p>
+ * 1. Supporting circuit pack
+ *
+ * <p>
+ * 2. Supporting port
+ *
+ * <p>
+ * 3. Supporting OTS/OMS interface (if port on ROADM)
+ *
+ * @param nodeId
+ * Unique Identifier for the node of interest.
+ * @param interfName
+ * Name of the OTS interface
+ *
+ * @return Result Mapping object if success otherwise null.
+ */
+ Mapping getMappingFromOtsInterface(String nodeId, String interfName);
+
/**
* This method removes a given mapping data from the mapping list
* stored in the datastore while the Netconf device is already
.child(Nodes.class, new NodesKey(nodeId));
try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
Optional<Nodes> portMapppingOpt = readTx.read(LogicalDatastoreType.CONFIGURATION, portMappingIID).get();
- if (!portMapppingOpt.isPresent()) {
+ if (portMapppingOpt.isEmpty()) {
LOG.warn("Could not get portMapping for node {}", nodeId);
return null;
}
return this.getNode(nodeId) != null;
}
+ @Override
+ public Mapping getMappingFromOtsInterface(String nodeId, String interfName) {
+ KeyedInstanceIdentifier<Nodes, NodesKey> nodePortmappingIID = InstanceIdentifier.create(Network.class)
+ .child(Nodes.class, new NodesKey(nodeId));
+ try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
+ Optional<Nodes> nodePortmapppingOpt
+ = readTx.read(LogicalDatastoreType.CONFIGURATION, nodePortmappingIID).get();
+ if (nodePortmapppingOpt.isEmpty()) {
+ LOG.warn("Could not get portMapping for node {}", nodeId);
+ return null;
+ }
+ Map<MappingKey, Mapping> mappings = nodePortmapppingOpt.get().getMapping();
+ for (Mapping mapping : mappings.values()) {
+ if (interfName.equals(mapping.getSupportingOts())) {
+ return mapping;
+ }
+ }
+ } catch (InterruptedException | ExecutionException ex) {
+ LOG.error("Unable to get mapping list for nodeId {}", nodeId, ex);
+ }
+ return null;
+ }
+
}
try {
Ports port = deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL,
portId, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT).get();
- Mapping newMapping = updateMappingObject(nodeId, port, oldMapping);
+ Interface otsInterface = null;
+ if (oldMapping.getSupportingOts() != null) {
+ InstanceIdentifier<Interface> interfId = InstanceIdentifier
+ .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+ .child(Interface.class, new InterfaceKey(oldMapping.getSupportingOts()))
+ .build();
+ otsInterface = deviceTransactionManager
+ .getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, interfId, Timeouts.DEVICE_READ_TIMEOUT,
+ Timeouts.DEVICE_READ_TIMEOUT_UNIT)
+ .get();
+ }
+ Mapping newMapping = updateMappingObject(nodeId, port, oldMapping, otsInterface);
LOG.debug(PortMappingUtils.UPDATE_MAPPING_LOGMSG,
nodeId, oldMapping, oldMapping.getLogicalConnectionPoint(), newMapping);
final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
return mpBldr.build();
}
- private Mapping updateMappingObject(String nodeId, Ports port, Mapping oldmapping) {
+ private Mapping updateMappingObject(String nodeId, Ports port, Mapping oldmapping, Interface otsInterf) {
MappingBuilder mpBldr = new MappingBuilder(oldmapping);
- updateMappingStates(mpBldr, port, oldmapping);
+ updateMappingStates(mpBldr, port, oldmapping, otsInterf);
if (port.getInterfaces() == null) {
return mpBldr.build();
}
return mpBldr.build();
}
- private MappingBuilder updateMappingStates(MappingBuilder mpBldr, Ports port, Mapping oldmapping) {
+ private MappingBuilder updateMappingStates(MappingBuilder mpBldr, Ports port, Mapping oldmapping,
+ Interface otsInterf) {
if (port.getAdministrativeState() != null
- && !port.getAdministrativeState().getName().equals(oldmapping.getPortAdminState())) {
+ && !port.getAdministrativeState().getName().equals(oldmapping.getPortAdminState())) {
mpBldr.setPortAdminState(port.getAdministrativeState().name());
}
if (port.getOperationalState() != null
- && !port.getOperationalState().getName().equals(oldmapping.getPortOperState())) {
+ && !port.getOperationalState().getName().equals(oldmapping.getPortOperState())) {
mpBldr.setPortOperState(port.getOperationalState().name());
}
+ if (otsInterf != null && otsInterf.getOperationalState() != null
+ && !otsInterf.getOperationalState().name().equals(oldmapping.getPortOperState())) {
+ mpBldr.setPortOperState(otsInterf.getOperationalState().name());
+ }
return mpBldr;
}
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.change.notification.Edit;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.pack.Ports;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs.CircuitPacks;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.Interface;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
import org.slf4j.Logger;
*/
@Override
public void onChangeNotification(ChangeNotification notification) {
+ LOG.info("notification received from device {}: {}", this.nodeId, notification.toString());
if (notification.getEdit() == null) {
LOG.warn("unable to handle {} notificatin received - list of edit is null", ChangeNotification.QNAME);
return;
Thread thread = new Thread(handleNetconfEvent);
thread.start();
break;
+ case "Interface":
+ LinkedList<PathArgument> pathInter = new LinkedList<>();
+ edit.getTarget().getPathArguments().forEach(p -> pathInter.add(p));
+ InstanceIdentifier<Interface> interfIID = InstanceIdentifier.unsafeOf(pathInter);
+ String interfName = InstanceIdentifier.keyOf(interfIID).getName();
+ LOG.info("interface {} modified on device {}", interfName, this.nodeId);
+ Mapping oldMapping2 = portMapping.getMappingFromOtsInterface(nodeId, interfName);
+ if (oldMapping2 == null) {
+ return;
+ }
+ Runnable handleNetconfEvent2 = new Runnable() {
+ @Override
+ public void run() {
+ portMapping.updateMapping(nodeId, oldMapping2);
+ LOG.info("{} : mapping data for {} updated", nodeId,
+ oldMapping2.getLogicalConnectionPoint());
+ }
+ };
+ Thread thread2 = new Thread(handleNetconfEvent2);
+ thread2.start();
+ break;
default:
LOG.debug("modification of type {} not managed yet", edit.getTarget().getTargetType());
break;