package org.opendaylight.transportpce.renderer.provisiondevice;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.base.Optional;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
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.mapping.PortMapping;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.OpticalControlMode;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.connection.DestinationBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.connection.SourceBuilder;
-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.transportpce.renderer.openroadminterface.OpenRoadmInterfaces;
+import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmOchInterface;
+import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmXponderInterface;
+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.CircuitPacksBuilder;
+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.org.openroadm.device.container.OrgOpenroadmDevice;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev161014.States;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes.ModulationFormat;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.R100G;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathOutput;
* service provides two functions:
*
* <p>
- * 1. Create
- * This operation results in provisioning the device for a given wavelength and a
- * list of nodes with each node listing its termination points.
+ * 1. Create This operation results in provisioning the device for a given
+ * wavelength and a list of nodes with each node listing its termination
+ * points.
*
* <p>
- * 2. Delete
- * This operation results in de-provisioning the device for a given wavelength and a
- * list of nodes with each node listing its termination points.
+ * 2. Delete This operation results in de-provisioning the device for a
+ * given wavelength and a list of nodes with each node listing its
+ * termination points.
*
* <p>
* The signature for this method was generated by yang tools from the
* renderer API model.
*
- * @param input Input parameter from the service-path yang model
+ * @param input
+ * Input parameter from the service-path yang model
*
* @return Result of the request
*/
}
/**
- * This method set's wavelength path based on following steps:
+ * This method set's wavelength path based on the following steps.
* For each node:
*
* <p>
- * 1. Create Och interface on source termination point.
- * 2. Create Och interface on destination termination point.
- * 3. Create cross connect between source and destination
- * tps created in step 1 and 2.
+ * 1. Create Och interface on source termination point. 2. Create Och
+ * interface on destination termination point. 3. Create cross connect
+ * between source and destination tps created in step 1 and 2.
*
* <p>
- * Naming convention used for OCH interfaces name : tp-wavenumber
- * Naming convention used for cross connect name : src-dest-wavenumber
+ * Naming convention used for OCH interfaces name : tp-wavenumber Naming
+ * convention used for cross connect name : src-dest-wavenumber
*
- * @param input Input parameter from the service-path yang model
+ * @param input
+ * Input parameter from the service-path yang model
*
- * @return Result list of all nodes if request successful
- * otherwise specific reason of failure.
+ * @return Result list of all nodes if request successful otherwise specific
+ * reason of failure.
*/
public ServicePathOutputBuilder setupServicePath(ServicePathInput input) {
+ String serviceName = input.getServiceName();
List<Nodes> nodes = input.getNodes();
ServicePathOutputBuilder setServBldr = new ServicePathOutputBuilder();
LOG.info(currentMountedDevice.toString());
+ int crossConnectFlag;
for (Nodes n : nodes) {
- LOG.info("Starting provisioning for node : " + n.getNodeId());
- //if the node is currently mounted then proceed
+ LOG.info("Starting provisioning for node : {}", n.getNodeId());
+ crossConnectFlag = 0;
+ String nodeId = n.getNodeId();
+ // if the node is currently mounted then proceed
if (currentMountedDevice.contains(n.getNodeId())) {
String srcTp = n.getSrcTp();
String destTp = n.getDestTp();
+
Long waveNumber = input.getWaveNumber();
- String srcIf = new OpenRoadmInterfaces(db, mps, n.getNodeId(), srcTp).createOchInterface(waveNumber);
- //if source interface creation was successful then proceed otherwise return.
- if (srcIf == null) {
- LOG.warn("Unable to create OCH interface on " + n.getNodeId() + " at " + srcTp);
- return setServBldr.setResult("Unable to create OCH interface on " + n.getNodeId() + " at " + srcTp);
- }
- //if destination interface creation was then proceed otherwise return.
- String dstIf = new OpenRoadmInterfaces(db, mps, n.getNodeId(), destTp).createOchInterface(waveNumber);
- if (dstIf == null) {
- LOG.warn("Unable to create OCH interface on " + n.getNodeId() + " at " + destTp);
- return setServBldr.setResult("Unable to create OCH interface on " + n.getNodeId() + " at "
- + destTp);
- }
- LOG.info("Creating cross connect between source :" + srcTp + " destination " + destTp + " for node " + n
- .getNodeId());
- //Build cross connect object
- RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder();
- rdmConnBldr.setConnectionNumber(srcTp + "-" + destTp + "-" + waveNumber);
- rdmConnBldr.setWavelengthNumber(waveNumber);
- rdmConnBldr.setOpticalControlMode(OpticalControlMode.Off);
- rdmConnBldr.setSource(new SourceBuilder().setSrcIf(srcIf).build());
- rdmConnBldr.setDestination(new DestinationBuilder().setDstIf(dstIf).build());
- InstanceIdentifier<RoadmConnections> rdmConnectionIID = InstanceIdentifier.create(
- OrgOpenroadmDevice.class).child(RoadmConnections.class, new RoadmConnectionsKey(rdmConnBldr
- .getConnectionNumber()));
- DataBroker netconfNodeDataBroker = PortMapping.getDeviceDataBroker(n.getNodeId(), mps);
- if (netconfNodeDataBroker != null) {
- final WriteTransaction writeTransaction = netconfNodeDataBroker.newWriteOnlyTransaction();
- //post the cross connect on the device
- writeTransaction.put(LogicalDatastoreType.CONFIGURATION, rdmConnectionIID, rdmConnBldr.build());
- final CheckedFuture<Void, TransactionCommitFailedException> submit = writeTransaction.submit();
+ String mf = input.getModulationFormat();
+ if (destTp.contains("LINE")) {
+ crossConnectFlag++;
+
+ ModulationFormat modulationFormat = null;
+ for (int i = 0; i < ModulationFormat.values().length; i++) {
+ ModulationFormat smodulationFormat = ModulationFormat.forValue(i);
+ if (smodulationFormat.getName().equals(mf)) {
+ modulationFormat = smodulationFormat;
+ }
+ }
try {
- submit.checkedGet();
- nodesProvisioned.add(n.getNodeId());
- LOG.info("Roadm-connection successfully created: " + srcTp + "-" + destTp);
+ LOG.info("Modulation Format {} configured exists.", modulationFormat.getName());
+ } catch (NullPointerException e) {
+ LOG.error("{} modulation format does not exist.",mf);
+ }
- } catch (TransactionCommitFailedException ex) {
- LOG.warn("Failed to post {} ", rdmConnBldr.build(), ex);
- return setServBldr.setResult("Unable to post Roadm-connection for node " + n.getNodeId());
+ if (!new OpenRoadmXponderInterface(db, mps, nodeId, destTp, serviceName)
+ .createLineInterfaces(waveNumber, R100G.class, modulationFormat)) {
+
+ return setServBldr.setResult("Unable to LINE interface on " + nodeId + " at " + destTp);
+ }
+ if (!activateService(nodeId, destTp, mps, true)) {
+ return setServBldr
+ .setResult("Unable to activate Equipment State on " + nodeId + " for " + destTp);
+ }
+ }
+ if (srcTp.contains("CLNT")) {
+ crossConnectFlag++;
+ if (!new OpenRoadmXponderInterface(db, mps, nodeId, srcTp, serviceName).createClientInterfaces()) {
+ return setServBldr.setResult("Unable to Client interface on " + nodeId + " at " + srcTp);
+ }
+ }
+ String srcIf;
+ String dstIf;
+ if (srcTp.contains("TTP") || srcTp.contains("PP")) {
+ srcIf = new OpenRoadmOchInterface(db, mps, nodeId, srcTp, serviceName).createInterface(waveNumber);
+ // if source interface creation was successful
+ // then proceed otherwise return.
+ if (srcIf == null) {
+ LOG.warn("Unable to create OCH interface on {} at {}", nodeId, srcTp);
+ return setServBldr.setResult("Unable to create OCH interface on " + nodeId + " at " + srcTp);
+ }
+ }
+ if (destTp.contains("TTP") || destTp.contains("PP")) {
+ dstIf = new OpenRoadmOchInterface(db, mps, nodeId, destTp, serviceName).createInterface(waveNumber);
+ // if destination interface creation was successful
+ // then proceed otherwise return.
+ if (dstIf == null) {
+ LOG.warn("Unable to create OCH interface on {} at {}", nodeId, destTp);
+ return setServBldr.setResult("Unable to create OCH interface on " + nodeId + " at " + destTp);
+ }
+ }
+ if (crossConnectFlag < 1) {
+ LOG.info("Creating cross connect between source :{} destination {} for node {}", srcTp, destTp,
+ n.getNodeId());
+ DataBroker netconfNodeDataBroker = PortMapping.getDeviceDataBroker(nodeId, mps);
+ String crossConnectName = srcTp + "-" + destTp + "-" + waveNumber;
+ CrossConnect roadmConnections = new CrossConnect(netconfNodeDataBroker);
+ if (roadmConnections.postCrossConnect(waveNumber, srcTp, destTp)) {
+ nodesProvisioned.add(nodeId);
+ roadmConnections.getConnectionPortTrail(nodeId, mps, waveNumber, srcTp, destTp);
+ } else {
+ return setServBldr.setResult("Unable to post Roadm-connection for node " + nodeId);
}
- } else {
- LOG.error("Unable to get device broker for node " + n.getNodeId());
- return setServBldr.setResult("Unable to get device broker for node " + n.getNodeId());
}
} else {
- LOG.warn(n.getNodeId() + " is not mounted on the controller");
- return setServBldr.setResult(n.getNodeId() + " is not mounted on the controller");
+ LOG.warn("{} is not mounted on the controller", nodeId);
+ return setServBldr.setResult(nodeId + " is not mounted on the controller");
}
}
return setServBldr.setResult("Roadm-connection successfully created for nodes " + nodesProvisioned.toString());
}
/**
- * This method removes wavelength path based on following steps:
- * For each node:
+ * This method removes wavelength path based on following steps: For each
+ * node:
*
* <p>
- * 1. Delete Cross connect between source and destination tps.
- * 2. Delete Och interface on source termination point.
- * 3. Delete Och interface on destination termination point.
+ * 1. Delete Cross connect between source and destination tps.
+ * 2. Delete Och interface on source termination point.
+ * 3. Delete Och interface on destination termination point.
*
- *<p>
- * Naming convention used for OCH interfaces name : tp-wavenumber
- * Naming convention used for cross connect name : src-dest-wavenumber
+ * <p>
+ * Naming convention used for OCH interfaces name : tp-wavenumber Naming
+ * convention used for cross connect name : src-dest-wavenumber
*
- * @param input Input parameter from the service-path yang model
+ * @param input
+ * Input parameter from the service-path yang model
*
* @return Result result of the request.
*/
ServicePathOutputBuilder delServBldr = new ServicePathOutputBuilder();
LOG.info(currentMountedDevice.toString());
for (Nodes n : nodes) {
- LOG.info("Deleting service setup on node " + n.getNodeId());
+
+ String nodeId = n.getNodeId();
+ LOG.info("Deleting service setup on node {}", nodeId);
String srcTp = n.getSrcTp();
String destTp = n.getDestTp();
Long waveNumber = input.getWaveNumber();
- //if the node is currently mounted then proceed.
- if (currentMountedDevice.contains(n.getNodeId())) {
- DataBroker netconfNodeDataBroker = PortMapping.getDeviceDataBroker(n.getNodeId(), mps);
- if (netconfNodeDataBroker != null) {
- // Deleting roadm connection
- InstanceIdentifier<RoadmConnections> rdmConnectionIID = InstanceIdentifier.create(
- OrgOpenroadmDevice.class).child(RoadmConnections.class, new RoadmConnectionsKey(srcTp + "-"
- + destTp + "-" + waveNumber));
- ReadWriteTransaction writeTx = netconfNodeDataBroker.newReadWriteTransaction();
- writeTx.delete(LogicalDatastoreType.CONFIGURATION, rdmConnectionIID);
- final CheckedFuture<Void, TransactionCommitFailedException> submit = writeTx.submit();
- try {
- submit.checkedGet();
- LOG.info("Successfully deleted interface " + srcTp + "-" + destTp + "-" + waveNumber);
- } catch (TransactionCommitFailedException ex) {
- LOG.error("Failed to delete {} ", srcTp + "-" + destTp + "-" + waveNumber, ex);
+ // if the node is currently mounted then proceed.
+ if (currentMountedDevice.contains(nodeId)) {
+
+ if (destTp.contains("LINE")) {
+ if (!activateService(nodeId, destTp, mps, false)) {
+ LOG.error("Unable to desactivate Equipment State on {} for {}", nodeId, destTp);
+ }
+ if (new OpenRoadmInterfaces(db, mps, nodeId, destTp)
+ .deleteInterface(destTp + "-ODU") == false) {
+ LOG.error("Failed to delete interface {}-ODU on {}", destTp, nodeId);
}
+ if (new OpenRoadmInterfaces(db, mps, nodeId, destTp)
+ .deleteInterface(destTp + "-OTU") == false) {
+ LOG.error("Failed to delete interface {}-OTU on {}", destTp, nodeId);
+ }
+ if (new OpenRoadmInterfaces(db, mps, nodeId, destTp)
+ .deleteInterface(destTp + "-" + waveNumber) == false) {
+ LOG.error("Failed to delete interface {}-{} on {}", destTp, waveNumber, nodeId);
+ }
+ }
+ if (srcTp.contains("CLNT")) {
// Deleting interface on source termination point
- writeTx = netconfNodeDataBroker.newReadWriteTransaction();
- InstanceIdentifier<Interface> srcInterfacesIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(Interface.class, new InterfaceKey(srcTp + "-" + waveNumber.toString()));
- writeTx.delete(LogicalDatastoreType.CONFIGURATION, srcInterfacesIID);
- final CheckedFuture<Void, TransactionCommitFailedException> submitSrcDel = writeTx.submit();
-
- try {
- submitSrcDel.checkedGet();
- LOG.info("Successfully deleted " + srcTp + "-" + waveNumber.toString());
- } catch (TransactionCommitFailedException ex) {
- LOG.error("Failed to delete interface {} ", srcTp + "-" + waveNumber.toString(), ex);
+ if (new OpenRoadmInterfaces(db, mps, nodeId, srcTp)
+ .deleteInterface(srcTp + "-ETHERNET") == false) {
+ LOG.error("Failed to delete Ethernet interface on {} on {}", srcTp, nodeId);
}
- // Deleting interface on destination termination point
- writeTx = netconfNodeDataBroker.newReadWriteTransaction();
- InstanceIdentifier<Interface> destInterfacesIID = InstanceIdentifier.create(
- OrgOpenroadmDevice.class).child(Interface.class, new InterfaceKey(destTp + "-" + waveNumber
- .toString()));
- writeTx.delete(LogicalDatastoreType.CONFIGURATION, destInterfacesIID);
- final CheckedFuture<Void, TransactionCommitFailedException> submitDestDel = writeTx.submit();
-
- try {
- submitDestDel.checkedGet();
- LOG.info("Successfully deleted " + destTp + "-" + waveNumber.toString());
+ continue;
+ }
+ String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
+ CrossConnect roadmConnection = new CrossConnect(PortMapping.getDeviceDataBroker(nodeId, mps),
+ connectionNumber);
+ if (!roadmConnection.deleteCrossConnect()) {
+ LOG.error("Failed to delete {} on {}", connectionNumber, nodeId);
+ }
+ // Deleting interface on source termination point
+ if (!new OpenRoadmInterfaces(db, mps, nodeId, srcTp)
+ .deleteInterface(srcTp + "-" + waveNumber.toString())) {
+ LOG.error("Failed to delete interface {}-{} on {}", srcTp, waveNumber.toString(), nodeId);
+ }
- } catch (TransactionCommitFailedException ex) {
- LOG.error("Failed to delete interface {} ", destTp + "-" + waveNumber.toString(), ex);
- }
+ // Deleting interface on destination termination point
+ if (!new OpenRoadmInterfaces(db, mps, nodeId, destTp)
+ .deleteInterface(destTp + "-" + waveNumber.toString())) {
+ LOG.error("Failed to delete interface {}-{} on {}", destTp, waveNumber.toString(), nodeId);
}
} else {
- LOG.warn(n.getNodeId() + " is not mounted on the controller");
- return delServBldr.setResult(n.getNodeId() + " is not mounted on the controller");
+ LOG.warn("{} is not mounted on the controller", nodeId);
+ return delServBldr.setResult(nodeId + " is not mounted on the controller");
}
}
return delServBldr.setResult("Request processed");
}
+ /**
+ * This method does a post(edit-config) on a given circuit-packs subtree to
+ * change its equipment-state.
+ *
+ * @param nodeId
+ * Netconf device.
+ * @param logicalConnPoint
+ * Logical Connection point resulting from PortMapping to
+ * retrieve associated circuit-pack.
+ * @param mps
+ * Mount point service.
+ * @param activate
+ * true to configure the circuit-pack to "NotReservedInuse".
+ * false to configure the circuit-pack to "NotReservedAvailable".
+ * @return true/false based on status of operation.
+ */
+ private boolean activateService(String nodeId, String logicalConnPoint, MountPointService mps, boolean activate) {
+ DataBroker deviceDb = PortMapping.getDeviceDataBroker(nodeId, mps);
+ String circuitPack = PortMapping.getMapping(nodeId, logicalConnPoint, db).getSupportingCircuitPackName();
+
+ InstanceIdentifier<CircuitPacks> circuitPackIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(CircuitPacks.class, new CircuitPacksKey(circuitPack));
+ ReadOnlyTransaction readTx = deviceDb.newReadOnlyTransaction();
+ // retrieve relevent CircuitPack object
+ Optional<CircuitPacks> cpObject;
+ CircuitPacks cp = null;
+ try {
+ cpObject = readTx.read(LogicalDatastoreType.CONFIGURATION, circuitPackIID).get();
+ if (cpObject.isPresent()) {
+ cp = cpObject.get();
+ } else {
+ LOG.info("Could not find CircuitPack {} in equipment config datastore for nodeId {}", circuitPack,
+ nodeId);
+ return false;
+ }
+
+ } catch (InterruptedException | ExecutionException ex) {
+ LOG.error("Issue reading config datastore on node {}", nodeId, ex);
+ }
+ CircuitPacksBuilder cpBldr = new CircuitPacksBuilder(cp);
+ if (activate) {
+ cpBldr.setEquipmentState(States.NotReservedInuse);
+ } else {
+ cpBldr.setEquipmentState(States.NotReservedAvailable);
+ }
+ WriteTransaction wt = deviceDb.newWriteOnlyTransaction();
+ wt.put(LogicalDatastoreType.CONFIGURATION, circuitPackIID, cpBldr.build());
+ try {
+ wt.submit().get(15, TimeUnit.SECONDS);
+ LOG.info("Successfully posted Equipment State on circuit pack {} on node {}", circuitPack, nodeId);
+ return true;
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.warn("Failed to post {} on node {}", circuitPack, nodeId, e);
+ return false;
+ }
+ }
}