[ONOS-4160] pce rest and cli
Change-Id: Icc1ec3070fe595bfc1439048234d6a6f23127c13
diff --git a/apps/pce/pom.xml b/apps/pce/pom.xml
index e6cac1b..f4e0926 100644
--- a/apps/pce/pom.xml
+++ b/apps/pce/pom.xml
@@ -37,9 +37,90 @@
</properties>
<dependencies>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava-testlib</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.test-framework</groupId>
+ <artifactId>jersey-test-framework-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.test-framework.providers</groupId>
+ <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/apps/pce/src/main/java/org/onosproject/pce/cli/PceDeletePathCommand.java b/apps/pce/src/main/java/org/onosproject/pce/cli/PceDeletePathCommand.java
new file mode 100644
index 0000000..012fd28
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/cli/PceDeletePathCommand.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.cli;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.pce.pceservice.api.PceService;
+
+import org.slf4j.Logger;
+
+/**
+ * Supports deleting pce path.
+ */
+@Command(scope = "onos", name = "pce-delete-path", description = "Supports deleting pce path.")
+public class PceDeletePathCommand extends AbstractShellCommand {
+ private final Logger log = getLogger(getClass());
+
+ @Argument(index = 0, name = "id", description = "Path Id.", required = true, multiValued = false)
+ String id = null;
+
+ @Override
+ protected void execute() {
+ log.info("executing pce-delete-path");
+
+ PceService service = get(PceService.class);
+
+ //TODO: need to uncomment below lines once releasePath method is added to PceService
+ //if (!service.releasePath(PcePathId.of(id))) {
+ // error("Path deletion failed.");
+ // return;
+ //}
+ }
+}
diff --git a/apps/pce/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java b/apps/pce/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java
new file mode 100644
index 0000000..b7dc3a9
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.cli;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.net.AnnotationKeys;
+import org.onosproject.pce.pceservice.api.PceService;
+
+import org.slf4j.Logger;
+
+/**
+ * Supports quering PCE path.
+ */
+@Command(scope = "onos", name = "pce-query-path",
+ description = "Supports querying PCE path.")
+public class PceQueryPathCommand extends AbstractShellCommand {
+ private final Logger log = getLogger(getClass());
+
+ @Option(name = "-i", aliases = "--id", description = "path-id", required = false,
+ multiValued = false)
+ String id = null;
+
+ @Override
+ protected void execute() {
+ log.info("executing pce-query-path");
+
+ PceService service = get(PceService.class);
+ if (null == id) {
+ //TODO: need to uncomment below line once queryAllPath method is added to PceService
+ Iterable<Tunnel> tunnels = null; // = service.queryAllPath();
+ if (tunnels != null) {
+ for (final Tunnel tunnel : tunnels) {
+ display(tunnel);
+ }
+ } else {
+ print("No path is found.");
+ return;
+ }
+ } else {
+ //TODO: need to uncomment below line once queryPath method is added to PceService
+ Tunnel tunnel = null; // = service.queryPath(PcePathId.of(id));
+ if (tunnel == null) {
+ print("Path doesnot exists.");
+ return;
+ }
+ display(tunnel);
+ }
+ }
+
+ /**
+ * Display tunnel information on the terminal.
+ *
+ * @param tunnel pce tunnel
+ */
+ void display(Tunnel tunnel) {
+ print("\npath-id : %d \n" +
+ "source : %s \n" +
+ "destination : %s \n" +
+ "path-type : %d \n" +
+ "symbolic-path-name : %s \n" +
+ "constraints: \n" +
+ " cost : %d \n" +
+ " bandwidth : %.2f",
+ tunnel.tunnelId().id(), tunnel.src().toString(), tunnel.dst().toString(),
+ tunnel.type(), tunnel.tunnelName(), tunnel.path().cost(),
+ tunnel.annotations().value(AnnotationKeys.BANDWIDTH));
+ }
+}
diff --git a/apps/pce/src/main/java/org/onosproject/pce/cli/PceSetupPathCommand.java b/apps/pce/src/main/java/org/onosproject/pce/cli/PceSetupPathCommand.java
new file mode 100644
index 0000000..5bf13ff
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/cli/PceSetupPathCommand.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.cli;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.pce.pceservice.LspType;
+import org.onosproject.pce.pceservice.api.PceService;
+
+import org.slf4j.Logger;
+
+/**
+ * Supports creating the pce path.
+ */
+@Command(scope = "onos", name = "pce-setup-path", description = "Supports creating pce path.")
+public class PceSetupPathCommand extends AbstractShellCommand {
+ private final Logger log = getLogger(getClass());
+
+ @Argument(index = 0, name = "src", description = "source device.", required = true, multiValued = false)
+ String src = null;
+
+ @Argument(index = 1, name = "dst", description = "destination device.", required = true, multiValued = false)
+ String dst = null;
+
+ @Argument(index = 2, name = "type", description = "LSP type:" + " It includes "
+ + "PCE tunnel with signalling in network (0), "
+ + "PCE tunnel without signalling in network with segment routing (1), "
+ + "PCE tunnel without signalling in network (2).",
+ required = true, multiValued = false)
+ int type = 0;
+
+ @Argument(index = 3, name = "name", description = "symbolic-path-name.", required = true, multiValued = false)
+ String name = null;
+
+ @Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost(1) or TE cost(2)",
+ required = false, multiValued = false)
+ int cost = 2;
+
+ @Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. "
+ + "Data rate unit is in BPS.", required = false, multiValued = false)
+ double bandwidth = 0.0;
+
+ @Override
+ protected void execute() {
+ log.info("executing pce-setup-path");
+
+ PceService service = get(PceService.class);
+
+ DeviceId srcDevice = DeviceId.deviceId(src);
+ DeviceId dstDevice = DeviceId.deviceId(dst);
+ LspType lspType = LspType.values()[type];
+ List<Constraint> listConstrnt = new LinkedList<>();
+
+ // add cost
+ //TODO: need to uncomment below lines once CostConstraint is ready
+ //CostConstraint.Type costType = CostConstraint.Type.values()[cost];
+ //listConstrnt.add(CostConstraint.of(costType));
+
+ // add bandwidth
+ // bandwidth default data rate unit is in BPS
+ if (bandwidth != 0.0) {
+ //TODO: need to uncomment below line once BandwidthConstraint is ready
+ //listConstrnt.add(LocalBandwidthConstraint.of(bandwidth, DataRateUnit.valueOf("BPS")));
+ }
+
+ //TODO: need to uncomment below lines once setupPath method is modified in PceService
+ //if (null == service.setupPath(srcDevice, dstDevice, name, listConstrnt, lspType)) {
+ // error("Path creation failed.");
+ //}
+ }
+}
diff --git a/apps/pce/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java b/apps/pce/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java
new file mode 100644
index 0000000..e1dcd65
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.cli;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.pce.pceservice.api.PceService;
+
+import org.slf4j.Logger;
+
+/**
+ * Supports updating the PCE path.
+ */
+@Command(scope = "onos", name = "pce-update-path",
+ description = "Supports updating PCE path.")
+public class PceUpdatePathCommand extends AbstractShellCommand {
+ private final Logger log = getLogger(getClass());
+
+ @Argument(index = 0, name = "id", description = "Path Id.", required = true, multiValued = false)
+ String id = null;
+
+ @Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost (1) or TE cost (2).",
+ required = false, multiValued = false)
+ int cost = 0;
+
+ @Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. "
+ + "Data rate unit is in Bps.", required = false, multiValued = false)
+ double bandwidth = 0.0;
+
+ @Override
+ protected void execute() {
+ log.info("executing pce-update-path");
+
+ PceService service = get(PceService.class);
+
+ List<Constraint> constrntList = new LinkedList<>();
+ // Assign cost
+ if (cost != 0) {
+ //TODO: need to uncomment below lines once CostConstraint is ready
+ //CostConstraint.Type costType = CostConstraint.Type.values()[Integer.valueOf(cost)];
+ //constrntList.add(CostConstraint.of(costType));
+ }
+
+ // Assign bandwidth. Data rate unit is in Bps.
+ if (bandwidth != 0.0) {
+ //TODO: need to uncomment below line once BandwidthConstraint is ready
+ //constrntList.add(LocalBandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit.valueOf("BPS")));
+ }
+
+ //TODO: need to uncomment below lines once updatePath method is added to PceService
+ //if (null == service.updatePath(PcePathId.of(id), constrntList)) {
+ // error("Path updation failed.");
+ // return;
+ //}
+ }
+}
diff --git a/apps/pce/src/main/java/org/onosproject/pce/cli/package-info.java b/apps/pce/src/main/java/org/onosproject/pce/cli/package-info.java
new file mode 100644
index 0000000..d5c85c4
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/cli/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * PCE path console command-line extensions.
+ */
+package org.onosproject.pce.cli;
diff --git a/apps/pce/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java b/apps/pce/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java
new file mode 100644
index 0000000..1331255
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pce.pceservice;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.net.intent.Constraint;
+
+/**
+ * Implementation of an entity which provides functionalities of pce path.
+ */
+public final class DefaultPcePath implements PcePath {
+
+ private TunnelId id; // path id
+ private String source; // Ingress
+ private String destination; // Egress
+ private LspType lspType; // LSP type
+ private String name; // symbolic-path-name
+ private Constraint costConstraint; // cost constraint
+ private Constraint bandwidthConstraint; // bandwidth constraint
+
+ /**
+ * Initializes PCE path attributes.
+ *
+ * @param id path id
+ * @param src ingress
+ * @param dst egress
+ * @param lspType lsp type
+ * @param name symbolic-path-name
+ * @param constrnt pce constraint
+ */
+ private DefaultPcePath(TunnelId id, String src, String dst, LspType lspType,
+ String name, Constraint costConstrnt, Constraint bandwidthConstrnt) {
+
+ this.id = id;
+ this.source = src;
+ this.destination = dst;
+ this.lspType = lspType;
+ this.name = name;
+ this.costConstraint = costConstrnt;
+ this.bandwidthConstraint = bandwidthConstrnt;
+ }
+
+ @Override
+ public TunnelId id() {
+ return id;
+ }
+
+ @Override
+ public void id(TunnelId id) {
+ this.id = id;
+ }
+
+ @Override
+ public String source() {
+ return source;
+ }
+
+ @Override
+ public void source(String src) {
+ this.source = src;
+ }
+
+ @Override
+ public String destination() {
+ return destination;
+ }
+
+ @Override
+ public void destination(String dst) {
+ this.destination = dst;
+ }
+
+ @Override
+ public LspType lspType() {
+ return lspType;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public Constraint costConstraint() {
+ return costConstraint;
+ }
+
+ @Override
+ public Constraint bandwidthConstraint() {
+ return bandwidthConstraint;
+ }
+
+ @Override
+ public PcePath copy(PcePath path) {
+ if (null != path.source()) {
+ this.source = path.source();
+ }
+ if (null != path.destination()) {
+ this.destination = path.destination();
+ }
+
+ this.lspType = path.lspType();
+
+ if (null != path.name()) {
+ this.name = path.name();
+ }
+ if (null != path.costConstraint()) {
+ this.costConstraint = path.costConstraint();
+ }
+ if (null != path.bandwidthConstraint()) {
+ this.bandwidthConstraint = path.bandwidthConstraint();
+ }
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, source, destination, lspType, name, costConstraint, bandwidthConstraint);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultPcePath) {
+ DefaultPcePath that = (DefaultPcePath) obj;
+ return Objects.equals(id, that.id)
+ && Objects.equals(source, that.source)
+ && Objects.equals(destination, that.destination)
+ && Objects.equals(lspType, that.lspType)
+ && Objects.equals(name, that.name)
+ && Objects.equals(costConstraint, that.costConstraint)
+ && Objects.equals(bandwidthConstraint, that.bandwidthConstraint);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("id", id())
+ .add("source", source)
+ .add("destination", destination)
+ .add("lsptype", lspType)
+ .add("name", name)
+ .add("costConstraint", costConstraint.toString())
+ .add("bandwidthConstraint", bandwidthConstraint.toString())
+ .toString();
+ }
+
+ /**
+ * Creates an instance of the pce path builder.
+ *
+ * @return instance of builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder class for pce path.
+ */
+ public static final class Builder implements PcePath.Builder {
+ private TunnelId id;
+ private String source;
+ private String destination;
+ private LspType lspType;
+ private String name;
+ private Constraint costConstraint;
+ private Constraint bandwidthConstraint;
+
+ @Override
+ public Builder id(String id) {
+ this.id = TunnelId.valueOf(id);
+ return this;
+ }
+
+ @Override
+ public Builder source(String source) {
+ this.source = source;
+ return this;
+ }
+
+ @Override
+ public Builder destination(String destination) {
+ this.destination = destination;
+ return this;
+ }
+
+ @Override
+ public Builder lspType(String type) {
+ if (null != type) {
+ this.lspType = LspType.values()[Integer.valueOf(type) - 1];
+ }
+ return this;
+ }
+
+ @Override
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @Override
+ public Builder costConstraint(String cost) {
+ this.costConstraint = null;
+ //TODO: below lines will be uncommented once CostConstraint class is ready
+ // this.costConstraint = CostConstraint.of(cost);
+ //}
+ return this;
+ }
+
+ @Override
+ public Builder bandwidthConstraint(String bandwidth) {
+ this.bandwidthConstraint = null;
+ //TODO: below lines will be uncommented once LocalBandwidthConstraint class is ready
+ // this.bandwidthConstraint = LocalBandwidthConstraint.of(bandwidth);
+ //}
+ return this;
+ }
+
+ @Override
+ public Builder of(Tunnel tunnel) {
+ this.id = TunnelId.valueOf(tunnel.tunnelId().id());
+ this.source = tunnel.src().toString();
+ this.destination = tunnel.dst().toString();
+ //TODO: need to uncomment below line once LSP_SIG_TYPE is added to AnnotationKeys
+ this.lspType = null; // = LspType.valueOf(tunnel.annotations().value(AnnotationKeys.LSP_SIG_TYPE));
+ this.name = tunnel.tunnelName().toString();
+ this.costConstraint = null; //CostConstraint.of(tunnel.path().cost());
+ this.bandwidthConstraint = null;
+ //LocalBandwidthConstraint.of(tunnel.annotations().value(AnnotationKeys.BANDWIDTH));
+ return this;
+ }
+
+ @Override
+ public PcePath build() {
+ return new DefaultPcePath(id, source, destination, lspType, name,
+ costConstraint, bandwidthConstraint);
+ }
+ }
+}
diff --git a/apps/pce/src/main/java/org/onosproject/pce/pceservice/PcePath.java b/apps/pce/src/main/java/org/onosproject/pce/pceservice/PcePath.java
new file mode 100644
index 0000000..ec4e257
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/pceservice/PcePath.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pce.pceservice;
+
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.pce.pceservice.DefaultPcePath.Builder;
+
+/**
+ * Abstraction of an entity which provides functionalities of pce path.
+ */
+public interface PcePath {
+
+ /**
+ * Returns the attribute path id.
+ *
+ * @return path id
+ */
+ TunnelId id();
+
+ /**
+ * Sets the attribute path id.
+ *
+ * @param id path id
+ */
+ void id(TunnelId id);
+
+ /**
+ * Returns the attribute ingress.
+ *
+ * @return source
+ */
+ String source();
+
+ /**
+ * Sets the attribute ingress.
+ *
+ * @param src pce source
+ */
+ void source(String src);
+
+ /**
+ * Returns the attribute egress.
+ *
+ * @return destination
+ */
+ String destination();
+
+ /**
+ * Sets the attribute egress.
+ *
+ * @param dst pce destination.
+ */
+ void destination(String dst);
+
+ /**
+ * Returns the attribute lspType.
+ *
+ * @return lspType
+ */
+ LspType lspType();
+
+ /**
+ * Returns the attribute symbolic-path-name.
+ *
+ * @return symbolic-path-name
+ */
+ String name();
+
+ /**
+ * Returns the attribute cost constraint.
+ *
+ * @return cost constraint
+ */
+ Constraint costConstraint();
+
+ /**
+ * Returns the attribute bandwidth constraint.
+ *
+ * @return bandwidth constraint
+ */
+ Constraint bandwidthConstraint();
+
+ /**
+ * Copies only non-null or non-zero member variables.
+ *
+ * @param id path-id
+ * @return pce-path
+ */
+ PcePath copy(PcePath id);
+
+ /**
+ * Builder for pce path.
+ */
+ interface Builder {
+
+ /**
+ * Returns the builder object of path id.
+ *
+ * @param id path id
+ * @return builder object of path id
+ */
+ Builder id(String id);
+
+ /**
+ * Returns the builder object of ingress.
+ *
+ * @param source ingress
+ * @return builder object of ingress
+ */
+ Builder source(String source);
+
+ /**
+ * Returns the builder object of egress.
+ *
+ * @param destination egress
+ * @return builder object of egress
+ */
+ Builder destination(String destination);
+
+ /**
+ * Returns the builder object of lspType.
+ *
+ * @param lspType lsp type
+ * @return builder object of lsp type
+ */
+ Builder lspType(String lspType);
+
+ /**
+ * Returns the builder object of symbolic-path-name.
+ *
+ * @param n symbolic-path-name
+ * @return builder object of symbolic-path-name
+ */
+ Builder name(String n);
+
+ /**
+ * Returns the builder object of cost constraint.
+ *
+ * @param cost constraint
+ * @return builder object of cost constraint
+ */
+ Builder costConstraint(String cost);
+
+ /**
+ * Returns the builder object of bandwidth constraint.
+ *
+ * @param bandwidth constraint
+ * @return builder object of bandwidth constraint
+ */
+ Builder bandwidthConstraint(String bandwidth);
+
+ /**
+ * Copies tunnel information to local.
+ *
+ * @param tunnel pcc tunnel
+ * @return object of pce-path
+ */
+ Builder of(Tunnel tunnel);
+
+ /**
+ * Builds object of pce path.
+ *
+ * @return object of pce path.
+ */
+ PcePath build();
+ }
+}
diff --git a/apps/pce/src/main/java/org/onosproject/pce/pceservice/package-info.java b/apps/pce/src/main/java/org/onosproject/pce/pceservice/package-info.java
index ae5d9c7..8eb75fa 100644
--- a/apps/pce/src/main/java/org/onosproject/pce/pceservice/package-info.java
+++ b/apps/pce/src/main/java/org/onosproject/pce/pceservice/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-present Open Networking Laboratory
+ * Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/apps/pce/src/main/java/org/onosproject/pce/web/PceCodecRegistrator.java b/apps/pce/src/main/java/org/onosproject/pce/web/PceCodecRegistrator.java
new file mode 100644
index 0000000..5554e64
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/web/PceCodecRegistrator.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.web;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.codec.CodecService;
+import org.onosproject.pce.pceservice.PcePath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of the json codec brokering service for pce app.
+ */
+@Component(immediate = true)
+public class PceCodecRegistrator {
+
+ private static Logger log = LoggerFactory.getLogger(PceCodecRegistrator.class);
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CodecService codecService;
+
+ @Activate
+ public void activate() {
+ codecService.registerCodec(PcePath.class, new PcePathCodec());
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+ }
+}
diff --git a/apps/pce/src/main/java/org/onosproject/pce/web/PcePathCodec.java b/apps/pce/src/main/java/org/onosproject/pce/web/PcePathCodec.java
new file mode 100644
index 0000000..9c16bd0
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/web/PcePathCodec.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.pce.pceservice.PcePath;
+import org.onosproject.pce.pceservice.DefaultPcePath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * PCE path json codec.
+ */
+public final class PcePathCodec extends JsonCodec<PcePath> {
+ private final Logger log = LoggerFactory.getLogger(PcePathCodec.class);
+ private static final String SOURCE = "source";
+ private static final String DESTINATION = "destination";
+ private static final String LSP_TYPE = "pathType";
+ private static final String SYMBOLIC_PATH_NAME = "name";
+ private static final String CONSTRAINT = "constraint";
+ private static final String COST = "cost";
+ private static final String BANDWIDTH = "bandwidth";
+ private static final String PATH_ID = "pathId";
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in pce-path";
+
+ @Override
+ public PcePath decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ log.error("Empty json input");
+ return null;
+ }
+
+ // build pce-path
+ PcePath.Builder resultBuilder = new DefaultPcePath.Builder();
+
+ // retrieve source
+ JsonNode jNode = json.get(SOURCE);
+ if (jNode != null) {
+ String src = jNode.asText();
+ resultBuilder.source(src);
+ }
+
+ // retrieve destination
+ jNode = json.get(DESTINATION);
+ if (jNode != null) {
+ String dst = jNode.asText();
+ resultBuilder.destination(dst);
+ }
+
+ // retrieve lsp-type
+ jNode = json.get(LSP_TYPE);
+ if (jNode != null) {
+ String lspType = jNode.asText();
+ resultBuilder.lspType(lspType);
+ }
+
+ // retrieve symbolic-path-name
+ jNode = json.get(SYMBOLIC_PATH_NAME);
+ if (jNode != null) {
+ String name = jNode.asText();
+ resultBuilder.name(name);
+ }
+
+ // retrieve constraint
+ JsonNode constraintJNode = (JsonNode) json.path(CONSTRAINT);
+ if ((constraintJNode != null) && (!constraintJNode.isMissingNode())) {
+ // retrieve cost
+ jNode = constraintJNode.get(COST);
+ if (jNode != null) {
+ String cost = jNode.asText();
+ resultBuilder.bandwidthConstraint(cost);
+ }
+
+ // retrieve bandwidth
+ jNode = constraintJNode.get(BANDWIDTH);
+ if (jNode != null) {
+ String bandwidth = jNode.asText();
+ resultBuilder.bandwidthConstraint(bandwidth);
+ }
+ }
+
+ return resultBuilder.build();
+ }
+
+ @Override
+ public ObjectNode encode(PcePath path, CodecContext context) {
+ checkNotNull(path, "path output cannot be null");
+ ObjectNode result = context.mapper()
+ .createObjectNode()
+ .put(PATH_ID, path.id().id())
+ .put(SOURCE, path.source())
+ .put(DESTINATION, path.destination())
+ .put(LSP_TYPE, path.lspType().type())
+ .put(SYMBOLIC_PATH_NAME, path.name());
+
+ ObjectNode constraintNode = context.mapper()
+ .createObjectNode()
+ .put(COST, path.costConstraint().toString())
+ .put(BANDWIDTH, path.bandwidthConstraint().toString());
+
+ result.set(CONSTRAINT, constraintNode);
+ return result;
+ }
+}
diff --git a/apps/pce/src/main/java/org/onosproject/pce/web/PcePathWebResource.java b/apps/pce/src/main/java/org/onosproject/pce/web/PcePathWebResource.java
new file mode 100644
index 0000000..19244f7
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/web/PcePathWebResource.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.web;
+
+import static javax.ws.rs.core.Response.Status.OK;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.LinkedList;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.pce.pceservice.PcePath;
+import org.onosproject.pce.pceservice.DefaultPcePath;
+import org.onosproject.pce.pceservice.LspType;
+import org.onosproject.rest.AbstractWebResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Query and program pce path.
+ */
+
+@Path("path")
+public class PcePathWebResource extends AbstractWebResource {
+
+ private final Logger log = LoggerFactory.getLogger(PcePathWebResource.class);
+ public static final String PCE_PATH_NOT_FOUND = "Path not found";
+ public static final String PCE_PATH_ID_EXIST = "Path exists";
+ public static final String PCE_PATH_ID_NOT_EXIST = "Path does not exist for the identifier";
+
+ /**
+ * Retrieve details of all paths created.
+ *
+ * @return 200 OK
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response queryAllPath() {
+ log.debug("Query all paths.");
+ //TODO: need to uncomment below line once queryAllPath method is added to PceService
+ Iterable<Tunnel> tunnels = null; // = get(PceService.class).queryAllPath();
+ ObjectNode result = mapper().createObjectNode();
+ ArrayNode pathEntry = result.putArray("paths");
+ if (tunnels != null) {
+ for (final Tunnel tunnel : tunnels) {
+ PcePath path = DefaultPcePath.builder().of(tunnel).build();
+ pathEntry.add(codec(PcePath.class).encode(path, this));
+ }
+ }
+ return ok(result.toString()).build();
+ }
+
+ /**
+ * Retrieve details of a specified path id.
+ *
+ * @param id path id
+ * @return 200 OK, 404 if given identifier does not exist
+ */
+ @GET
+ @Path("{path_id}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response queryPath(@PathParam("path_id") String id) {
+ log.debug("Query path by identifier {}.", id);
+ //TODO: need to uncomment below lines once queryPath method is added to PceService
+ Tunnel tunnel = null; // = nullIsNotFound(get(PceService.class).queryPath(PcePathId.of(id)),
+ //PCE_PATH_NOT_FOUND);
+ PcePath path = DefaultPcePath.builder().of(tunnel).build();
+ ObjectNode result = mapper().createObjectNode();
+ result.set("path", codec(PcePath.class).encode(path, this));
+ return ok(result.toString()).build();
+ }
+
+ /**
+ * Creates a new path.
+ *
+ * @param stream pce path from json
+ * @return status of the request
+ */
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response setupPath(InputStream stream) {
+ log.debug("Setup path.");
+ try {
+ ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+ JsonNode port = jsonTree.get("path");
+ PcePath path = codec(PcePath.class).decode((ObjectNode) port, this);
+
+ DeviceId srcDevice = DeviceId.deviceId(path.source());
+ DeviceId dstDevice = DeviceId.deviceId(path.destination());
+ LspType lspType = path.lspType();
+ List<Constraint> listConstrnt = new LinkedList<Constraint>();
+
+ // add cost
+ //TODO: need to uncomment below lines once Bandwidth and Cost constraint classes are ready
+ //CostConstraint.Type costType = CostConstraint.Type.values()[Integer.valueOf(path.constraint().cost())];
+ //listConstrnt.add(CostConstraint.of(costType));
+
+ // add bandwidth. Data rate unit is in BPS.
+ //listConstrnt.add(LocalBandwidthConstraint.of(Double.valueOf(path.constraint().bandwidth()), DataRateUnit
+ // .valueOf("BPS")));
+
+ //TODO: need to uncomment below lines once setupPath method is modified in PceService
+ Boolean issuccess = true; // = (null != get(PceService.class)
+ //.setupPath(srcDevice, dstDevice, path.name(), listConstrnt, lspType)) ? true : false;
+ return Response.status(OK).entity(issuccess.toString()).build();
+ } catch (IOException e) {
+ log.error("Exception while creating path {}.", e.toString());
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Update details of a specified path id.
+ *
+ * @param id path id
+ * @param stream pce path from json
+ * @return 200 OK, 404 if given identifier does not exist
+ */
+ @PUT
+ @Path("{path_id}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response updatePath(@PathParam("path_id") String id,
+ final InputStream stream) {
+ log.debug("Update path by identifier {}.", id);
+ try {
+ ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+ JsonNode pathNode = jsonTree.get("path");
+ PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this);
+ // Assign cost
+ List<Constraint> constrntList = new LinkedList<Constraint>();
+ //TODO: need to uncomment below lines once CostConstraint class is ready
+ if (path.costConstraint() != null) {
+ //CostConstraint.Type costType = CostConstraint.Type.values()[path.constraint().cost()];
+ //constrntList.add(CostConstraint.of(costType));
+ }
+
+ // Assign bandwidth. Data rate unit is in BPS.
+ if (path.bandwidthConstraint() != null) {
+ //TODO: need to uncomment below lines once BandwidthConstraint class is ready
+ //constrntList.add(LocalBandwidthConstraint
+ // .of(path.constraint().bandwidth(), DataRateUnit.valueOf("BPS")));
+ }
+
+ //TODO: need to uncomment below line once updatePath is added to PceService
+ Boolean result = true; // = (null != (get(PceService.class).updatePath(PcePathId.of(id), constrntList)))
+ //? true : false;
+ return Response.status(OK).entity(result.toString()).build();
+ } catch (IOException e) {
+ log.error("Update path failed because of exception {}.", e.toString());
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Release a specified path.
+ *
+ * @param id path id
+ * @return 200 OK, 404 if given identifier does not exist
+ */
+ @Path("{path_id}")
+ @DELETE
+ public Response releasePath(@PathParam("path_id") String id) {
+ log.debug("Deletes path by identifier {}.", id);
+
+ //TODO: need to uncomment below lines once releasePath method is added to PceService
+ Boolean isSuccess = true; // = nullIsNotFound(get(PceService.class).releasePath(PcePathId.of(id)),
+ //PCE_PATH_NOT_FOUND);
+ if (!isSuccess) {
+ log.debug("Path identifier {} does not exist", id);
+ }
+
+ return Response.status(OK).entity(isSuccess.toString()).build();
+ }
+}
diff --git a/apps/pce/src/main/java/org/onosproject/pce/web/PceWebApplication.java b/apps/pce/src/main/java/org/onosproject/pce/web/PceWebApplication.java
new file mode 100644
index 0000000..9cae9b3
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/web/PceWebApplication.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pce.web;
+
+import org.onlab.rest.AbstractWebApplication;
+
+import java.util.Set;
+
+/**
+ * PCE rest api web application.
+ */
+public class PceWebApplication extends AbstractWebApplication {
+ @Override
+ public Set<Class<?>> getClasses() {
+ return getClasses(PcePathWebResource.class);
+ }
+}
+
diff --git a/apps/pce/src/main/java/org/onosproject/pce/web/package-info.java b/apps/pce/src/main/java/org/onosproject/pce/web/package-info.java
new file mode 100644
index 0000000..08a1b6b
--- /dev/null
+++ b/apps/pce/src/main/java/org/onosproject/pce/web/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * PCE rest application.
+ */
+package org.onosproject.pce.web;
diff --git a/apps/pce/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/apps/pce/src/main/resources/OSGI-INF/blueprint/shell-config.xml
new file mode 100644
index 0000000..8631bfc
--- /dev/null
+++ b/apps/pce/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,31 @@
+<!--
+ ~ Copyright 2016 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+ <command>
+ <action class="org.onosproject.pce.cli.PceQueryPathCommand"/>
+ </command>
+ <command>
+ <action class="org.onosproject.pce.cli.PceSetupPathCommand"/>
+ </command>
+ <command>
+ <action class="org.onosproject.pce.cli.PceUpdatePathCommand"/>
+ </command>
+ <command>
+ <action class="org.onosproject.pce.cli.PceDeletePathCommand"/>
+ </command>
+ </command-bundle>
+</blueprint>
diff --git a/apps/pce/src/main/webapp/WEB-INF/web.xml b/apps/pce/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..6f2c47a
--- /dev/null
+++ b/apps/pce/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2016 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="ONOS" version="2.5">
+ <display-name>PCE REST API v1.0</display-name>
+
+ <servlet>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.onosproject.pce.web.PceWebApplication</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
diff --git a/apps/pce/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java b/apps/pce/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java
new file mode 100644
index 0000000..2f5347d
--- /dev/null
+++ b/apps/pce/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pce.pceservice;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+import org.onosproject.incubator.net.tunnel.TunnelId;
+
+/**
+ * Unit tests for DefaultPcePath class.
+ */
+public class DefaultPcePathTest {
+ /**
+ * Checks the operation of equals() methods.
+ */
+ @Test
+ public void testEquals() {
+ // create same two pce-path objects.
+ final String cost1 = "1";
+ final String bandwidth1 = "200";
+ final String src1 = "foo";
+ final String dst1 = "bee";
+ final String type1 = "1";
+ final String name1 = "pcc";
+
+ PcePath path1 = DefaultPcePath.builder()
+ .source(src1)
+ .destination(dst1)
+ .lspType(type1)
+ .name(name1)
+ .costConstraint(cost1)
+ .bandwidthConstraint(bandwidth1)
+ .build();
+ path1.id(TunnelId.valueOf("1"));
+
+ // create same as above object
+ PcePath samePath1 = DefaultPcePath.builder()
+ .source(src1)
+ .destination(dst1)
+ .lspType(type1)
+ .name(name1)
+ .costConstraint(cost1)
+ .bandwidthConstraint(bandwidth1)
+ .build();
+ samePath1.id(TunnelId.valueOf("1"));
+
+ // Create different pce-path object.
+ final String cost2 = "1";
+ final String bandwidth2 = "200";
+ final String src2 = "google";
+ final String dst2 = "yahoo";
+ final String type2 = "2";
+ final String name2 = "pcc2";
+
+ PcePath path2 = DefaultPcePath.builder()
+ .source(src2)
+ .destination(dst2)
+ .lspType(type2)
+ .name(name2)
+ .costConstraint(cost2)
+ .bandwidthConstraint(bandwidth2)
+ .build();
+ path2.id(TunnelId.valueOf("2"));
+ //TODO: will be uncommented below line once CostConstraint and LocalBandwidthConstraint classes are ready
+ //new EqualsTester().addEqualityGroup(path1, samePath1).addEqualityGroup(path2).testEquals();
+ }
+
+ /**
+ * Checks the construction of a DefaultPcePath object.
+ */
+ @Test
+ public void testConstruction() {
+ final String cost = "1";
+ final String bandwidth = "600";
+ final String src = "indiatimes";
+ final String dst = "deccan";
+ final String type = "3";
+ final String name = "pcc4";
+
+ PcePath path = DefaultPcePath.builder()
+ .source(src)
+ .destination(dst)
+ .lspType(type)
+ .name(name)
+ .costConstraint(cost)
+ .bandwidthConstraint(bandwidth)
+ .build();
+
+ assertThat(src, is(path.source()));
+ assertThat(dst, is(path.destination()));
+ assertThat(LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR, is(path.lspType()));
+ assertThat(name, is(path.name()));
+ //TODO: will be uncommented below lines once CostConstraint and LocalBandwidthConstraint classes are ready
+ //assertThat(cost, is(path.costConstraint().toString()));
+ //assertThat(bandwidth, is(path.bandwidthConstraint().toString()));
+ }
+}
diff --git a/apps/pce/src/test/java/org/onosproject/pce/web/MockPceCodecContext.java b/apps/pce/src/test/java/org/onosproject/pce/web/MockPceCodecContext.java
new file mode 100644
index 0000000..1aa90aa
--- /dev/null
+++ b/apps/pce/src/test/java/org/onosproject/pce/web/MockPceCodecContext.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.web;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.CodecService;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.codec.impl.CodecManager;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * Mock codec context for use in codec unit tests.
+ */
+public class MockPceCodecContext implements CodecContext {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+ private final CodecManager codecManager = new CodecManager();
+ private final PceCodecRegistrator manager = new PceCodecRegistrator();
+
+ /**
+ * Constructs a new mock codec context.
+ */
+ public MockPceCodecContext() {
+ codecManager.activate();
+ manager.codecService = codecManager;
+ manager.activate();
+ }
+
+ @Override
+ public ObjectMapper mapper() {
+ return mapper;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getService(Class<T> serviceClass) {
+ // TODO
+ return null;
+ }
+
+ @Override
+ public <T> JsonCodec<T> codec(Class<T> entityClass) {
+ return codecManager.getCodec(entityClass);
+ }
+
+ /**
+ * Get the codec manager.
+ *
+ * @return instance of codec manager
+ */
+ public CodecService codecManager() {
+ return codecManager;
+ }
+}
diff --git a/apps/pce/src/test/java/org/onosproject/pce/web/PcePathCodecTest.java b/apps/pce/src/test/java/org/onosproject/pce/web/PcePathCodecTest.java
new file mode 100644
index 0000000..64f1c48
--- /dev/null
+++ b/apps/pce/src/test/java/org/onosproject/pce/web/PcePathCodecTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.web;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.pce.pceservice.PcePath;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * PCE path codec unit tests.
+ */
+public class PcePathCodecTest {
+
+ MockPceCodecContext context;
+ JsonCodec<PcePath> pcePathCodec;
+ /**
+ * Sets up for each test. Creates a context and fetches the PCE path codec.
+ */
+ @Before
+ public void setUp() {
+ context = new MockPceCodecContext();
+ pcePathCodec = context.codec(PcePath.class);
+ assertThat(pcePathCodec, notNullValue());
+ }
+
+ /**
+ * Reads in a pce-path from the given resource and decodes it.
+ *
+ * @param resourceName resource to use to read the json for the pce-path
+ * @return decoded pce-path
+ * @throws IOException if processing the resource fails
+ */
+ private PcePath getPcePath(String resourceName) throws IOException {
+ InputStream jsonStream = PcePathCodecTest.class
+ .getResourceAsStream(resourceName);
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode json = mapper.readTree(jsonStream);
+ assertThat(json, notNullValue());
+ PcePath pcePath = pcePathCodec.decode((ObjectNode) json, context);
+ assertThat(pcePath, notNullValue());
+ return pcePath;
+ }
+
+ /**
+ * Checks that a simple pce-path is decoded properly.
+ *
+ * @throws IOException if the resource cannot be processed
+ */
+ @Test
+ public void codecPcePathTest() throws IOException {
+
+ PcePath pcePath = getPcePath("pcePath.json");
+
+ assertThat(pcePath, notNullValue());
+
+ assertThat(pcePath.source().toString(), is("11.0.0.1"));
+ assertThat(pcePath.destination(), is("11.0.0.2"));
+ assertThat(pcePath.lspType().toString(), is("SR_WITHOUT_SIGNALLING"));
+ //TODO: uncomment below lines once CostConstraint and LocalBandwidthConstraint are ready
+ //assertThat(pcePath.costConstraint().toString(), is(2));
+ //assertThat(pcePath.bandwidthConstraint().toString(), is(200.0));
+ }
+}
diff --git a/apps/pce/src/test/java/org/onosproject/pce/web/PcePathResourceTest.java b/apps/pce/src/test/java/org/onosproject/pce/web/PcePathResourceTest.java
new file mode 100644
index 0000000..181f864
--- /dev/null
+++ b/apps/pce/src/test/java/org/onosproject/pce/web/PcePathResourceTest.java
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.web;
+
+//import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.createMock;
+//import static org.easymock.EasyMock.expect;
+//import static org.easymock.EasyMock.replay;
+//import static org.hamcrest.Matchers.containsString;
+//import static org.hamcrest.Matchers.is;
+//import static org.hamcrest.Matchers.notNullValue;
+//import static org.junit.Assert.assertThat;
+//import static org.junit.Assert.fail;
+
+//import javax.ws.rs.NotFoundException;
+//import javax.ws.rs.client.Entity;
+//import javax.ws.rs.client.WebTarget;
+//import javax.ws.rs.core.MediaType;
+//import javax.ws.rs.core.Response;
+//import java.io.InputStream;
+//import java.net.HttpURLConnection;
+//import java.util.HashSet;
+//import java.util.List;
+//import java.util.Objects;
+//import java.util.Optional;
+//import java.util.Set;
+
+//import com.eclipsesource.json.Json;
+//import com.eclipsesource.json.JsonObject;
+//import com.google.common.collect.ImmutableList;
+//import com.google.common.collect.Lists;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.osgi.ServiceDirectory;
+import org.onlab.osgi.TestServiceDirectory;
+import org.onlab.rest.BaseResource;
+import org.onosproject.codec.CodecService;
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.pce.pceservice.PcePath;
+import org.onosproject.pce.pceservice.LspType;
+import org.onosproject.pce.pceservice.api.PceService;
+
+/**
+ * Unit tests for pce path REST APIs.
+ */
+public class PcePathResourceTest extends PceResourceTest {
+ final PceService pceService = createMock(PceService.class);
+ final TunnelId pcePathId1 = TunnelId.valueOf("1");
+ //TODO: will be uncommented below lines once CostConstraint and LocalBandwidthConstraint classes are ready
+ final Constraint costConstraint = null; //CostConstraint.of("2");
+ final Constraint bandwidthConstraint = null; //LocalBandwidthConstraint.of("200.0");
+ final LspType lspType = LspType.WITH_SIGNALLING;
+ final MockPcePath pcePath1 = new MockPcePath(pcePathId1, "11.0.0.1", "11.0.0.2", lspType, "pcc2",
+ costConstraint, bandwidthConstraint);
+
+ /**
+ * Mock class for a pce path.
+ */
+ private static class MockPcePath implements PcePath {
+ private TunnelId id;
+ private String source;
+ private String destination;
+ private LspType lspType;
+ private String name;
+ private Constraint costConstraint;
+ private Constraint bandwidthConstraint;
+
+ /**
+ * Constructor to initialize member variables.
+ *
+ * @param id pce path id
+ * @param src source device
+ * @param dst destination device
+ * @param type lsp type
+ * @param name symbolic path name
+ * @param constrnt pce constraint
+ */
+ public MockPcePath(TunnelId id, String src, String dst, LspType type, String name,
+ Constraint costConstrnt, Constraint bandwidthConstrnt) {
+ this.id = id;
+ this.source = src;
+ this.destination = dst;
+ this.name = name;
+ this.lspType = type;
+ this.costConstraint = costConstrnt;
+ this.bandwidthConstraint = bandwidthConstrnt;
+ }
+
+ @Override
+ public TunnelId id() {
+ return id;
+ }
+
+ @Override
+ public void id(TunnelId id) {
+ this.id = id;
+ }
+
+ @Override
+ public String source() {
+ return source;
+ }
+
+ @Override
+ public void source(String src) {
+ this.source = src;
+ }
+
+ @Override
+ public String destination() {
+ return destination;
+ }
+
+ @Override
+ public void destination(String dst) {
+ this.destination = dst;
+ }
+
+ @Override
+ public LspType lspType() {
+ return lspType;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public Constraint costConstraint() {
+ return costConstraint;
+ }
+
+ @Override
+ public Constraint bandwidthConstraint() {
+ return bandwidthConstraint;
+ }
+
+ @Override
+ public PcePath copy(PcePath path) {
+ if (null != path.source()) {
+ this.source = path.source();
+ }
+ if (null != path.destination()) {
+ this.destination = path.destination();
+ }
+ if (this.lspType != path.lspType()) {
+ this.lspType = path.lspType();
+ }
+ if (null != path.name()) {
+ this.name = path.name();
+ }
+ if (null != path.costConstraint()) {
+ this.costConstraint = path.costConstraint();
+ }
+ if (null != path.bandwidthConstraint()) {
+ this.bandwidthConstraint = path.bandwidthConstraint();
+ }
+ return this;
+ }
+ }
+
+ /**
+ * Sets up the global values for all the tests.
+ */
+ @Before
+ public void setUpTest() {
+ MockPceCodecContext context = new MockPceCodecContext();
+ ServiceDirectory testDirectory = new TestServiceDirectory().add(PceService.class, pceService)
+ .add(CodecService.class, context.codecManager());
+ BaseResource.setServiceDirectory(testDirectory);
+ }
+
+ /**
+ * Cleans up.
+ */
+ @After
+ public void tearDownTest() {
+ }
+
+ /**
+ * Tests the result of the rest api GET when there are no pce paths.
+ */
+ @Test
+ public void testPcePathsEmpty() {
+ //TODO: will be uncommented below code once PceService is ready
+ //expect(pceService.queryAllPath()).andReturn(null).anyTimes();
+ //replay(pceService);
+ //final WebTarget wt = target();
+ //final String response = wt.path("path").request().get(String.class);
+ //assertThat(response, is("{\"paths\":[]}"));
+ }
+
+ /**
+ * Tests the result of a rest api GET for pce path id.
+ */
+ @Test
+ public void testGetTunnelId() {
+ //TODO: will be uncommented below code once PceService is ready
+ //final Set<PcePath> pcePaths = new HashSet<>();
+ //pcePaths.add(pcePath1);
+
+ //expect(pceService.queryPath(anyObject())).andReturn(pcePath1).anyTimes();
+ //replay(pceService);
+
+ //final WebTarget wt = target();
+ //final String response = wt.path("path/1").request().get(String.class);
+ //final JsonObject result = Json.parse(response).asObject();
+ //assertThat(result, notNullValue());
+ }
+
+ /**
+ * Tests that a fetch of a non-existent pce path object throws an exception.
+ */
+ @Test
+ public void testBadGet() {
+ //TODO: will be uncommented below code once PceService is ready
+ //expect(pceService.queryPath(anyObject()))
+ // .andReturn(null).anyTimes();
+ //replay(pceService);
+
+ //WebTarget wt = target();
+ //try {
+ // wt.path("path/1").request().get(String.class);
+ // fail("Fetch of non-existent pce path did not throw an exception");
+ //} catch (NotFoundException ex) {
+ // assertThat(ex.getMessage(),
+ // containsString("HTTP 404 Not Found"));
+ //}
+ }
+
+ /**
+ * Tests creating a pce path with POST.
+ */
+ @Test
+ public void testPost() {
+ //TODO: will be uncommented below code once PceService is ready
+ //expect(pceService.setupPath(anyObject()))
+ // .andReturn(true).anyTimes();
+ //replay(pceService);
+
+ //WebTarget wt = target();
+ //InputStream jsonStream = PcePathResourceTest.class.getResourceAsStream("post-PcePath.json");
+
+ //Response response = wt.path("path")
+ // .request(MediaType.APPLICATION_JSON_TYPE)
+ // .post(Entity.json(jsonStream));
+ //assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
+ }
+
+ /**
+ * Tests creating a pce path with PUT.
+ */
+ @Test
+ public void testPut() {
+ //TODO: will be uncommented below code once PceService is ready
+ //expect(pceService.updatePath(anyObject()))
+ // .andReturn(true).anyTimes();
+ //replay(pceService);
+
+ //WebTarget wt = target();
+ //InputStream jsonStream = PcePathResourceTest.class.getResourceAsStream("post-PcePath.json");
+
+ //Response response = wt.path("path/1")
+ // .request(MediaType.APPLICATION_JSON_TYPE)
+ // .put(Entity.json(jsonStream));
+ //assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
+ }
+
+ /**
+ * Tests deleting a pce path.
+ */
+ @Test
+ public void testDelete() {
+ //TODO: will be uncommented below code once PceService is ready
+ //expect(pceService.releasePath(anyObject()))
+ // .andReturn(true).anyTimes();
+ //replay(pceService);
+
+ //WebTarget wt = target();
+
+ //String location = "path/1";
+
+ //Response deleteResponse = wt.path(location)
+ // .request(MediaType.APPLICATION_JSON_TYPE)
+ // .delete();
+ //assertThat(deleteResponse.getStatus(),
+ // is(HttpURLConnection.HTTP_OK));
+ }
+}
diff --git a/apps/pce/src/test/java/org/onosproject/pce/web/PceResourceTest.java b/apps/pce/src/test/java/org/onosproject/pce/web/PceResourceTest.java
new file mode 100644
index 0000000..d7a29f5
--- /dev/null
+++ b/apps/pce/src/test/java/org/onosproject/pce/web/PceResourceTest.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pce.web;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+
+/**
+ * Base class for pce rest api tests. Performs common configuration operations.
+ */
+public class PceResourceTest extends JerseyTest {
+
+ /**
+ * Creates a new web-resource test.
+ */
+ public PceResourceTest() {
+ super(ResourceConfig.forApplicationClass(PceWebApplication.class));
+ }
+}
diff --git a/apps/pce/src/test/resources/org/onosproject/pce/web/pcePath.json b/apps/pce/src/test/resources/org/onosproject/pce/web/pcePath.json
new file mode 100644
index 0000000..4e6084e
--- /dev/null
+++ b/apps/pce/src/test/resources/org/onosproject/pce/web/pcePath.json
@@ -0,0 +1,11 @@
+{
+ "source":"11.0.0.1",
+ "destination":"11.0.0.2",
+ "pathType":"2",
+ "name":"pcc2",
+ "description":"path-create",
+ "constraint":
+ { "cost":2,
+ "bandwidth":200.0
+ }
+}
diff --git a/apps/pce/src/test/resources/org/onosproject/pce/web/post-PcePath.json b/apps/pce/src/test/resources/org/onosproject/pce/web/post-PcePath.json
new file mode 100644
index 0000000..fcd99e2
--- /dev/null
+++ b/apps/pce/src/test/resources/org/onosproject/pce/web/post-PcePath.json
@@ -0,0 +1,11 @@
+{"path": {"source":"11.0.0.1",
+ "destination":"11.0.0.2",
+ "pathType":"2",
+ "name":"pcc2",
+ "description":"path-create",
+ "constraint":
+ {"cost":2,
+ "bandwidth":200.0
+ }
+ }
+}