Bug 5350: Add feature for manual-maps 32/36932/2
authorjensenzhang <jingxuan.n.zhang@gmail.com>
Thu, 25 Feb 2016 14:19:09 +0000 (22:19 +0800)
committerKai GAO <gaok12@mails.tsinghua.edu.cn>
Thu, 31 Mar 2016 10:32:24 +0000 (18:32 +0800)
Add the missing feature for manual-maps service. And do some minor
changes:

 - Refine the northbound-route for costmap.

 - Add some test scripts for manual-maps service.

Change-Id: Ifa2a9a1b921f101425af7036f7835a9683f2b816
Signed-off-by: jensenzhang <jingxuan.n.zhang@gmail.com>
alto-basic/manual-maps/api/src/main/yang/alto-costmap-config.yang
alto-basic/manual-maps/impl/src/main/java/org/opendaylight/alto/basic/impl/AltoManualCostmapServiceImpl.java
alto-core/standard-northbound-routes/costmap/impl/src/main/java/org/opendaylight/alto/core/northbound/route/costmap/impl/AltoNorthboundRouteCostmap.java
alto-release-features/pom.xml
alto-release-features/src/main/features/features.xml
test/scripts/manualmaps/create_costmap [new file with mode: 0755]
test/scripts/manualmaps/template/template_costmap [new file with mode: 0644]
test/scripts/northbound/nbr-costmap-create [changed mode: 0644->0755]
test/scripts/northbound/query-nbr-costmap [changed mode: 0644->0755]

index 543dd332a64d32c1ecdb30bae8776d82058b2f17..8463faa7114f098153705c69ad8a97a73badbbb4 100644 (file)
@@ -56,14 +56,14 @@ module alto-costmap-config {
                 key "dst";
                 choice cost {
                     case type-numerical {
-                        leaf cost-value {
+                        leaf numerical-cost-value {
                             type decimal64 {
                                 fraction-digits 4;
                             }
                         }
                     }
                     case type-ordinal {
-                        leaf cost-value {
+                        leaf ordinal-cost-value {
                             type int32;
                         }
                     }
index 3fe9e3234e4f15f5bc48d1a8681afd6127ca8540..10c0f22c5291e6ae00053030400a4e5fdcb78903 100644 (file)
@@ -128,11 +128,11 @@ public class AltoManualCostmapServiceImpl implements AltoModelCostmapService {
                 Cost cost = dstCosts.getCost();
                 if (cost instanceof TypeNumerical) {
                     costmapDestinationBuilder.setCost(new NumericalBuilder()
-                            .setCost(((TypeNumerical) cost).getCostValue())
+                            .setCost(((TypeNumerical) cost).getNumericalCostValue())
                             .build());
                 } else if (cost instanceof TypeOrdinal) {
                     costmapDestinationBuilder.setCost(new OrdinalBuilder()
-                            .setCost(((TypeOrdinal) cost).getCostValue())
+                            .setCost(((TypeOrdinal) cost).getOrdinalCostValue())
                             .build());
                 }
                 costmapDestinations.add(costmapDestinationBuilder.build());
index 7f8895a72206a3df35fddaa8e5bf049a32793f78..269db2a0d6f7ce5d1585cbcf9ad65bd46301c15a 100644 (file)
@@ -114,7 +114,48 @@ public class AltoNorthboundRouteCostmap implements BindingAwareProvider, AutoClo
     @GET
     @Produces({ALTO_COSTMAP, ALTO_ERROR})
     public Response getFullMap(@PathParam("path") String path) throws JsonProcessingException{
-        QueryInput input = prepareDefaultInput(path);
+        QueryInput input = prepareDefaultInput(path, "numerical", "hopcount");
+        Future<RpcResult<QueryOutput>> outputFuture = mapService.query(input);
+        QueryOutput output = null;
+        try {
+            output = outputFuture.get().getResult();
+        } catch (Exception e) {
+            LOG.warn("get output failed:" , e);
+        }
+        Response response = buildOutput(input, output);
+        if(response != null)
+            return response;
+        else
+            return Response.status(404).build();
+    }
+
+    @Path("{path}/{mode}")
+    @GET
+    @Produces({ALTO_COSTMAP, ALTO_ERROR})
+    public Response getFullMap(@PathParam("path") String path,
+                               @PathParam("mode") String mode) throws JsonProcessingException{
+        QueryInput input = prepareDefaultInput(path, mode, "hopcount");
+        Future<RpcResult<QueryOutput>> outputFuture = mapService.query(input);
+        QueryOutput output = null;
+        try {
+            output = outputFuture.get().getResult();
+        } catch (Exception e) {
+            LOG.warn("get output failed:" , e);
+        }
+        Response response = buildOutput(input, output);
+        if(response != null)
+            return response;
+        else
+            return Response.status(404).build();
+    }
+
+    @Path("{path}/{mode}/{metric}")
+    @GET
+    @Produces({ALTO_COSTMAP, ALTO_ERROR})
+    public Response getFullMap(@PathParam("path") String path,
+                               @PathParam("mode") String mode,
+                               @PathParam("metric") String metric) throws JsonProcessingException{
+        QueryInput input = prepareDefaultInput(path, mode, metric);
         Future<RpcResult<QueryOutput>> outputFuture = mapService.query(input);
         QueryOutput output = null;
         try {
@@ -214,16 +255,14 @@ public class AltoNorthboundRouteCostmap implements BindingAwareProvider, AutoClo
         return new LinkedList<String>(retval);
     }
 
-    protected QueryInput prepareDefaultInput(String rid) {
+    protected QueryInput prepareDefaultInput(String rid, String cost_mode, String cost_metric) {
         /*
-         * Set pids as empty so all PID should be returned.
-         *
-         * Set address-types as missing so all address types should be returned.
+         * Set source and destination pids as empty so all PID pairs should be returned.
          *
-         * See https://tools.ietf.org/html/rfc7285#section-11.3.1.3
+         * See https://tools.ietf.org/html/rfc7285#section-11.3.2.3
          *
          * */
-        return prepareInput(rid, null, null, new LinkedList<String>(), new LinkedList<String>());
+        return prepareInput(rid, cost_mode, cost_metric, new LinkedList<String>(), new LinkedList<String>());
     }
 
     protected QueryInput prepareInput(String path, String cost_mode, String cost_metric, List<String> pid_source, List<String> pid_destination) {
index df4f1e6759df9b0d6a4cc2cf2ea49f0163160f19..ced9df105802f1c3f93fb7bcd40b1540624e6288 100644 (file)
@@ -163,6 +163,46 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <classifier>config</classifier>
     </dependency>
 
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-northbound-route-costmap-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-northbound-route-costmap-impl</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-northbound-route-costmap-impl</artifactId>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <classifier>config</classifier>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-northbound-route-endpointcost-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-northbound-route-endpointcost-impl</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-northbound-route-endpointcost-impl</artifactId>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <classifier>config</classifier>
+    </dependency>
+
     <dependency>
       <groupId>org.opendaylight.alto.core</groupId>
       <artifactId>alto-service-model-ird-api</artifactId>
@@ -199,12 +239,38 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <version>${project.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-service-model-config-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
     <dependency>
       <groupId>org.opendaylight.alto.basic</groupId>
       <artifactId>alto-simple-ird-impl</artifactId>
       <version>${project.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.opendaylight.alto.basic</groupId>
+      <artifactId>alto-manual-maps-impl</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.basic</groupId>
+      <artifactId>alto-manual-maps-impl</artifactId>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <classifier>config</classifier>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.basic</groupId>
+      <artifactId>alto-manual-maps-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
     <dependency>
       <groupId>org.opendaylight.alto.basic</groupId>
       <artifactId>alto-simple-ird-impl</artifactId>
index 781a9aa470a1c95f75bf8488bdce23e9d6d6143c..3c3dd8f189fedb915fda890bd10c76e3da77e295 100644 (file)
@@ -108,6 +108,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <configfile finalname="${configfile.directory}/alto-northbound-route-networkmap.xml">
         mvn:org.opendaylight.alto.core/alto-northbound-route-networkmap-impl/${project.version}/xml/config
     </configfile>
+
+    <bundle>mvn:org.opendaylight.alto.core/alto-northbound-route-costmap-api/${project.version}</bundle>
+    <bundle>mvn:org.opendaylight.alto.core/alto-northbound-route-costmap-impl/${project.version}</bundle>
+    <configfile finalname="${configfile.directory}/alto-northbound-route-costmap.xml">
+      mvn:org.opendaylight.alto.core/alto-northbound-route-costmap-impl/${project.version}/xml/config
+    </configfile>
+
+    <bundle>mvn:org.opendaylight.alto.core/alto-northbound-route-endpointcost-api/${project.version}</bundle>
+    <bundle>mvn:org.opendaylight.alto.core/alto-northbound-route-endpointcost-impl/${project.version}</bundle>
+    <configfile finalname="${configfile.directory}/alto-northbound-route-endpointcost.xml">
+      mvn:org.opendaylight.alto.core/alto-northbound-route-endpointcost-impl/${project.version}/xml/config
+    </configfile>
   </feature>
 
   <feature name='odl-alto-standard-resource-translator' version='${project.version}'
@@ -133,7 +145,19 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 
   <feature name='odl-alto-manual-maps' version='${project.version}'
             description='OpenDaylight :: alto :: manual-maps'>
-    <!-- TODO -->
+    <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
+    <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
+
+    <feature version='${project.version}'>odl-alto-northbound</feature>
+    <feature version='${project.version}'>odl-alto-resourcepool</feature>
+    <feature version='${project.version}'>odl-alto-standard-service-models</feature>
+
+    <bundle>mvn:org.opendaylight.alto.core/alto-service-model-config-api/${project.version}</bundle>
+    <bundle>mvn:org.opendaylight.alto.basic/alto-manual-maps-api/${project.version}</bundle>
+    <bundle>mvn:org.opendaylight.alto.basic/alto-manual-maps-impl/${project.version}</bundle>
+    <configfile finalname="${configfile.directory}/alto-manual-maps.xml">
+      mvn:org.opendaylight.alto.basic/alto-manual-maps-impl/${project.version}/xml/config
+    </configfile>
   </feature>
 
   <feature name='odl-alto-hosttracker' version='${project.version}'
diff --git a/test/scripts/manualmaps/create_costmap b/test/scripts/manualmaps/create_costmap
new file mode 100755 (executable)
index 0000000..c2d01fd
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+RESOURCE_ID=$1
+TAG=$2
+if [ $3 ]; then
+       CONTEXT_ID=$3
+else
+       CONTEXT_ID="00000000-0000-0000-0000-000000000000"
+fi
+URL="http://localhost:8181/restconf/config/alto-manual-maps:config-context/"$CONTEXT_ID"/resource-cost-map/"$RESOURCE_ID
+
+echo $URL
+
+DATA=$(cat ./manualmaps/template/template_costmap \
+    | sed 's/\$1/'$RESOURCE_ID'/g' \
+    | sed 's/\$2/'$TAG'/g')
+
+echo $DATA
+
+curl -X PUT -u admin:admin -v \
+    -H "Content-Type: application/json" -d "$(echo $DATA)"\
+    $URL
diff --git a/test/scripts/manualmaps/template/template_costmap b/test/scripts/manualmaps/template/template_costmap
new file mode 100644 (file)
index 0000000..59a96f5
--- /dev/null
@@ -0,0 +1,25 @@
+{
+  "resource-cost-map": {
+    "resource-id": "$1",
+    "tag": "$2",
+    "meta": {
+      "dependent-vtags": [
+        {
+          "resource-id": "test-manual-networkmaps",
+          "tag": "455e4fcb78c3b0fb69f993d49b197f0e"
+        }
+      ]
+    },
+    "map": [
+      {
+        "src": "PID0",
+        "dst-costs": [
+          {
+            "dst": "PID1",
+            "numerical-cost-value": 2
+          }
+        ]
+      }
+    ]
+  }
+}
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)