Priyanka B
Committed by Gerrit Code Review

[ONOS-4725]duplicate symbolic path names are allowed in creation of pce path

Change-Id: I81c7282f7c5c47ad6d088b3df1deadf1d44d2772
...@@ -17,6 +17,7 @@ package org.onosproject.pce.cli; ...@@ -17,6 +17,7 @@ package org.onosproject.pce.cli;
17 17
18 import static org.slf4j.LoggerFactory.getLogger; 18 import static org.slf4j.LoggerFactory.getLogger;
19 19
20 +import java.util.Collection;
20 import java.util.List; 21 import java.util.List;
21 import java.util.LinkedList; 22 import java.util.LinkedList;
22 23
...@@ -26,6 +27,8 @@ import org.apache.karaf.shell.commands.Option; ...@@ -26,6 +27,8 @@ import org.apache.karaf.shell.commands.Option;
26 27
27 import org.onlab.util.DataRateUnit; 28 import org.onlab.util.DataRateUnit;
28 import org.onosproject.cli.AbstractShellCommand; 29 import org.onosproject.cli.AbstractShellCommand;
30 +import org.onosproject.incubator.net.tunnel.Tunnel;
31 +import org.onosproject.incubator.net.tunnel.TunnelService;
29 import org.onosproject.net.DeviceId; 32 import org.onosproject.net.DeviceId;
30 import org.onosproject.net.intent.constraint.BandwidthConstraint; 33 import org.onosproject.net.intent.constraint.BandwidthConstraint;
31 import org.onosproject.net.intent.Constraint; 34 import org.onosproject.net.intent.Constraint;
...@@ -71,6 +74,7 @@ public class PceSetupPathCommand extends AbstractShellCommand { ...@@ -71,6 +74,7 @@ public class PceSetupPathCommand extends AbstractShellCommand {
71 log.info("executing pce-setup-path"); 74 log.info("executing pce-setup-path");
72 75
73 PceService service = get(PceService.class); 76 PceService service = get(PceService.class);
77 + TunnelService tunnelService = get(TunnelService.class);
74 78
75 DeviceId srcDevice = DeviceId.deviceId(src); 79 DeviceId srcDevice = DeviceId.deviceId(src);
76 DeviceId dstDevice = DeviceId.deviceId(dst); 80 DeviceId dstDevice = DeviceId.deviceId(dst);
...@@ -85,6 +89,15 @@ public class PceSetupPathCommand extends AbstractShellCommand { ...@@ -85,6 +89,15 @@ public class PceSetupPathCommand extends AbstractShellCommand {
85 } 89 }
86 LspType lspType = LspType.values()[type]; 90 LspType lspType = LspType.values()[type];
87 91
92 + //Validating tunnel name, duplicated tunnel names not allowed
93 + Collection<Tunnel> existingTunnels = tunnelService.queryTunnel(Tunnel.Type.MPLS);
94 + for (Tunnel t : existingTunnels) {
95 + if (t.tunnelName().toString().equals(name)) {
96 + error("Path creation failed, Tunnel name already exists");
97 + return;
98 + }
99 + }
100 +
88 // Add bandwidth 101 // Add bandwidth
89 // bandwidth default data rate unit is in BPS 102 // bandwidth default data rate unit is in BPS
90 if (bandwidth != 0.0) { 103 if (bandwidth != 0.0) {
......