X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderer%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Frenderer%2Fprovisiondevice%2FDeviceRenderer.java;h=ee4caacfc7c76fcc3aeea4e95e132ea52a63c462;hb=2919da6e5f18c721188a2025e84448b17d4c6c21;hp=6df6ddb27c6d140c1fcbcc1f4fe6814f56a44c4c;hpb=7088d43a03e07109eaee31194168e63a9c147ece;p=transportpce.git diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRenderer.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRenderer.java index 6df6ddb27..ee4caacfc 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRenderer.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRenderer.java @@ -8,8 +8,6 @@ package org.opendaylight.transportpce.renderer.provisiondevice; -import com.google.common.util.concurrent.CheckedFuture; - import java.util.HashSet; import java.util.List; import java.util.Set; @@ -17,29 +15,19 @@ import java.util.concurrent.Future; 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.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.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.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.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; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.service.path.input.Nodes; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,24 +48,23 @@ public class DeviceRenderer implements RendererService { /** * This method is the implementation of the 'service-path' RESTCONF service, - * which is one of the external APIs into the renderer application. The - * service provides two functions: + * which is one of the external APIs into the renderer application. The service + * provides two functions: * *

- * 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. * *

- * 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. * *

- * The signature for this method was generated by yang tools from the - * renderer API model. + * 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 */ @@ -95,102 +82,125 @@ public class DeviceRenderer implements RendererService { } /** - * This method set's wavelength path based on following steps: - * For each node: + * This method set's wavelength path based on following steps: For each node: * *

- * 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. * *

- * 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 = 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 + 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 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 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(mf + " modulation format does not exist."); + } + + if (!new OpenRoadmXponderInterface(db, mps, nodeId, destTp, serviceName) + .createLineInterfaces(waveNumber, R100G.class, modulationFormat)) { - } catch (TransactionCommitFailedException ex) { - LOG.warn("Failed to post {} ", rdmConnBldr.build(), ex); - return setServBldr.setResult("Unable to post Roadm-connection for node " + n.getNodeId()); + return setServBldr.setResult("Unable to LINE interface on " + nodeId + " at " + destTp); + } + LOG.info("LINE interface created for node " + nodeId); + } + 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 " + nodeId + " at " + 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 " + nodeId + " at " + destTp); + return setServBldr.setResult("Unable to create OCH interface on " + nodeId + " at " + destTp); + } + } + if (crossConnectFlag < 1) { + LOG.info("Creating cross connect between source :" + srcTp + " destination " + destTp + " for node " + + 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(nodeId + " is not mounted on the controller"); + 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: * *

- * 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. * - *

- * 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 result of the request. */ @@ -199,63 +209,60 @@ public class DeviceRenderer implements RendererService { 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 rdmConnectionIID = InstanceIdentifier.create( - OrgOpenroadmDevice.class).child(RoadmConnections.class, new RoadmConnectionsKey(srcTp + "-" - + destTp + "-" + waveNumber)); - ReadWriteTransaction writeTx = netconfNodeDataBroker.newReadWriteTransaction(); - writeTx.delete(LogicalDatastoreType.CONFIGURATION, rdmConnectionIID); - final CheckedFuture 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 (new OpenRoadmInterfaces(db, mps, nodeId, destTp) + .deleteInterface(destTp + "-ODU") == false) { + LOG.error("Failed to delete interface " + destTp + "-ODU"); } + if (new OpenRoadmInterfaces(db, mps, nodeId, destTp) + .deleteInterface(destTp + "-OTU") == false) { + LOG.error("Failed to delete interface " + destTp + "-OTU"); + } + if (new OpenRoadmInterfaces(db, mps, nodeId, destTp) + .deleteInterface(destTp + "-" + waveNumber) == false) { + LOG.error("Failed to delete interface " + destTp + "-" + waveNumber); + } + } + if (srcTp.contains("CLNT")) { // Deleting interface on source termination point - writeTx = netconfNodeDataBroker.newReadWriteTransaction(); - InstanceIdentifier srcInterfacesIID = InstanceIdentifier.create(OrgOpenroadmDevice.class) - .child(Interface.class, new InterfaceKey(srcTp + "-" + waveNumber.toString())); - writeTx.delete(LogicalDatastoreType.CONFIGURATION, srcInterfacesIID); - final CheckedFuture 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 " + srcTp); } - // Deleting interface on destination termination point - writeTx = netconfNodeDataBroker.newReadWriteTransaction(); - InstanceIdentifier destInterfacesIID = InstanceIdentifier.create( - OrgOpenroadmDevice.class).child(Interface.class, new InterfaceKey(destTp + "-" + waveNumber - .toString())); - writeTx.delete(LogicalDatastoreType.CONFIGURATION, destInterfacesIID); - final CheckedFuture 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 {} ", srcTp + "-" + destTp + "-" + waveNumber); + } + // Deleting interface on source termination point + if (!new OpenRoadmInterfaces(db, mps, nodeId, srcTp) + .deleteInterface(srcTp + "-" + waveNumber.toString())) { + LOG.error("Failed to delete interface " + srcTp + "-" + waveNumber.toString()); + } - } 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 " + destTp + "-" + waveNumber.toString()); } } else { - LOG.warn(n.getNodeId() + " is not mounted on the controller"); - return delServBldr.setResult(n.getNodeId() + " is not mounted on the controller"); + LOG.warn(nodeId + " is not mounted on the controller"); + return delServBldr.setResult(nodeId + " is not mounted on the controller"); } } return delServBldr.setResult("Request processed"); } - }