Add endpointcost-northbound-route 80/36780/3
authorneal <wukunhenggo@gmail.com>
Sun, 3 Jan 2016 06:59:33 +0000 (01:59 -0500)
committerKai GAO <gaok12@mails.tsinghua.edu.cn>
Thu, 31 Mar 2016 10:31:22 +0000 (18:31 +0800)
Patch Set 2: checkstyle fixed

Patch Set 3: Rebase and bump versions

Patch Set 4: fix bug by version

Patch Set 5: try to fix agaiZZ

Change-Id: Ic9ec69f241d7fa8a957b85d04f91e14fd01cf822
Signed-off-by: neal <wukunhenggo@gmail.com>
(cherry picked from commit 7cc585f037e221b3393c19b9b25e531f14cd5433)
Signed-off-by: jensenzhang <jingxuan.n.zhang@gmail.com>
(cherry picked from commit 8564f68)
Signed-off-by: jinmin <kimmin@tongji.edu.cn>
21 files changed:
alto-core/northbound/api/src/main/java/org/opendaylight/alto/core/northbound/api/utils/rfc7285/RFC7285CostType.java
alto-core/northbound/features/pom.xml
alto-core/northbound/features/src/main/features/features.xml
alto-core/standard-northbound-routes/endpointcost/api/pom.xml [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/api/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/AltoNbrEndpointcostUtils.java [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/api/src/main/yang/alto-nbr-endpointcost.yang [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/impl/pom.xml [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/impl/src/main/config/default-config.xml [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/impl/src/main/config/maven-metadata-local.xml [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/AltoNorthboundRouteEndpointcost.java [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/EndpointcostRouteChecker.java [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/core/northbound/route/endpointcost/impl/rev151021/AltoNorthboundRouteEndpointcostModule.java [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/core/northbound/route/endpointcost/impl/rev151021/AltoNorthboundRouteEndpointcostModuleFactory.java [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/impl/src/main/yang/alto-northbound-route-endpointcost-impl.yang [new file with mode: 0644]
alto-core/standard-northbound-routes/endpointcost/pom.xml [new file with mode: 0644]
alto-core/standard-northbound-routes/pom.xml
test/scripts/northbound/nbr-endpointcost-create [new file with mode: 0644]
test/scripts/northbound/nbr-networkmap-create
test/scripts/northbound/query-nbr-endpointcost [new file with mode: 0644]
test/scripts/northbound/template/endpointcost-filter [new file with mode: 0644]
test/scripts/northbound/template/nbr-record-endpointcost [new file with mode: 0644]

index 677fed05097f8276d99d43469323a38c25dad280..058b6cb413ec8fbd1d5d1aa431461a09dc8c2afa 100644 (file)
@@ -8,9 +8,11 @@
 
 package org.opendaylight.alto.core.northbound.api.utils.rfc7285;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import java.util.Arrays;
 
+@JsonInclude(JsonInclude.Include.NON_NULL)
 public class RFC7285CostType {
 
     @JsonProperty("cost-mode")
index 8b777ea0a3aacc494649b1d2f441188d6f5f0262..dd7c0658aa82beaa1fe0e0f53b54f649c72c53c1 100644 (file)
@@ -177,5 +177,31 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <type>xml</type>
       <scope>runtime</scope>
     </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-northbound-route-endpointcost-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-northbound-route-endpointcost-impl</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-northbound-route-endpointcost-impl</artifactId>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <classifier>config</classifier>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-endpointcost-features</artifactId>
+      <classifier>features</classifier>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
   </dependencies>
 </project>
index 36bfb442ae3bc550b754d2fe5c92882bc2b1d871..a3e5b036dc548f7300375fdfcba190980bcb67d6 100644 (file)
@@ -18,6 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 
   <repository>mvn:org.opendaylight.alto.core/alto-service-model-networkmap-features/${project.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.alto.core/alto-service-model-costmap-features/${project.version}/xml/features</repository>
+    <repository>mvn:org.opendaylight.alto.core/alto-service-model-endpointcost-features/${project.version}/xml/features</repository>
 
   <feature name='odl-alto-northbound-api' version='${project.version}' description='OpenDaylight :: alto-northbound :: api'>
     <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
@@ -51,6 +52,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
           mvn:org.opendaylight.alto.core/alto-northbound-route-costmap-impl/${project.version}/xml/config
       </configfile>
 
+      <feature version='${project.version}'>odl-alto-service-model-endpointcost</feature>
+      <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-northbound-rest' version='${project.version}' description='OpenDaylight :: alto-northbound :: REST'>
     <feature version="${project.version}">odl-alto-northbound</feature>
diff --git a/alto-core/standard-northbound-routes/endpointcost/api/pom.xml b/alto-core/standard-northbound-routes/endpointcost/api/pom.xml
new file mode 100644 (file)
index 0000000..5f9a521
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright © 2015 Yale University and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.5.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-northbound-route-endpointcost-api</artifactId>
+  <version>0.3.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-endpointcost-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlets</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-server</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>2.5</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.mdsal.model</groupId>
+      <artifactId>ietf-inet-types-2013-07-15</artifactId>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/alto-core/standard-northbound-routes/endpointcost/api/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/AltoNbrEndpointcostUtils.java b/alto-core/standard-northbound-routes/endpointcost/api/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/AltoNbrEndpointcostUtils.java
new file mode 100644 (file)
index 0000000..bab3186
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015 Yale University and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.alto.core.northbound.route.endpointcost;
+
+/**
+ * Created by wukunheng00 on 12/3/15.
+ */
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.rev151021.Records;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.rev151021.records.Record;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.rev151021.records.RecordKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class AltoNbrEndpointcostUtils {
+
+    public static InstanceIdentifier<Record> getRecordIID(String path) {
+        RecordKey key = new RecordKey(new Uri(path));
+        return InstanceIdentifier.builder(Records.class).child(Record.class, key).build();
+    }
+}
+
diff --git a/alto-core/standard-northbound-routes/endpointcost/api/src/main/yang/alto-nbr-endpointcost.yang b/alto-core/standard-northbound-routes/endpointcost/api/src/main/yang/alto-nbr-endpointcost.yang
new file mode 100644 (file)
index 0000000..bee788c
--- /dev/null
@@ -0,0 +1,36 @@
+module alto-nbr-endpointcost {
+    yang-version 1;
+
+    namespace "urn:opendaylight:alto:core:northbound:route:endpointcost";
+
+    prefix "alto-nbr-endpointcost";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import ietf-inet-types { prefix ietf-inet; revision-date 2013-07-15; }
+    import alto-model-endpointcost { prefix endpointcost-model; revision-date 2015-10-21; }
+
+    organization "Yale University";
+
+    contact "alto-dev@lists.opendaylight.org";
+
+    revision "2015-10-21" {
+        description "Initial revision of alto-northbound model";
+    }
+
+    container "records" {
+        list "record" {
+            key "path";
+
+            leaf "path" {
+                type ietf-inet:uri;
+            }
+
+            leaf "resource-iid" {
+                type instance-identifier;
+            }
+
+
+        }
+    }
+
+}
diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/pom.xml b/alto-core/standard-northbound-routes/endpointcost/impl/pom.xml
new file mode 100644 (file)
index 0000000..10429f1
--- /dev/null
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright © 2015 Yale University and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.5.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-northbound-route-endpointcost-impl</artifactId>
+  <version>0.3.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>config-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-northbound-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-endpointcost-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-northbound-route-endpointcost-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.mdsal.model</groupId>
+      <artifactId>ietf-inet-types-2013-07-15</artifactId>
+    </dependency>
+
+    <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-annotations</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.datatype</groupId>
+      <artifactId>jackson-datatype-json-org</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.jaxrs</groupId>
+      <artifactId>jackson-jaxrs-base</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.jaxrs</groupId>
+      <artifactId>jackson-jaxrs-json-provider</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.module</groupId>
+      <artifactId>jackson-module-jaxb-annotations</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlets</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-server</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>2.5</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>${bundle.plugin.version}</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Import-Package>*,com.sun.jersey.spi.container.servlet, org.eclipse.jetty.servlets</Import-Package>
+            <Web-ContextPath>/alto</Web-ContextPath>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/config/default-config.xml b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..6ec577e
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright © 2015 Yale University and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<snapshot>
+  <required-capabilities>
+      <capability>urn:opendaylight:alto:core:northbound:route:endpointcost:impl?module=alto-northbound-route-endpointcost-impl&amp;revision=2015-10-21</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+      <capability>urn:opendaylight:alto:core:northbound?module=alto-northbound&amp;revision=2015-10-21</capability>
+  </required-capabilities>
+  <configuration>
+
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+        <module>
+          <type xmlns:prefix="urn:opendaylight:alto:core:northbound:route:endpointcost:impl">prefix:alto-northbound-route-endpointcost-impl</type>
+          <name>alto-northbound-route-endpointcost</name>
+          <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+          <alto-northbound-router>
+            <type xmlns:alto-northbound-router="urn:opendaylight:alto:core:northbound">alto-northbound-router:alto-northbound-router</type>
+            <name>alto-northbound-router</name>
+          </alto-northbound-router>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/config/maven-metadata-local.xml b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/config/maven-metadata-local.xml
new file mode 100644 (file)
index 0000000..8896458
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata modelVersion="1.1.0">
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-northbound-impl</artifactId>
+  <version>0.3.0-SNAPSHOT</version>
+  <versioning>
+    <snapshot>
+      <localCopy>true</localCopy>
+    </snapshot>
+    <lastUpdated>20151105030453</lastUpdated>
+    <snapshotVersions>
+      <snapshotVersion>
+        <classifier>config</classifier>
+        <extension>xml</extension>
+        <value>0.3.0-SNAPSHOT</value>
+        <updated>20151105030453</updated>
+      </snapshotVersion>
+    </snapshotVersions>
+  </versioning>
+</metadata>
diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/AltoNorthboundRouteEndpointcost.java b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/AltoNorthboundRouteEndpointcost.java
new file mode 100644 (file)
index 0000000..150d33f
--- /dev/null
@@ -0,0 +1,423 @@
+/*
+ * Copyright (c) 2015 Yale University and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.alto.core.northbound.route.endpointcost.impl;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.google.common.base.Optional;
+import org.opendaylight.alto.core.northbound.api.AltoNorthboundRoute;
+import org.opendaylight.alto.core.northbound.api.AltoNorthboundRouter;
+import org.opendaylight.alto.core.northbound.api.utils.rfc7285.RFC7285CostType;
+import org.opendaylight.alto.core.northbound.api.utils.rfc7285.RFC7285Endpoint;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.rev151021.Records;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.rev151021.records.Record;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.rev151021.records.RecordKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.context.Resource;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.context.resource.ContextTag;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.context.resource.ContextTagKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.types.rev150921.CostMetric;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.AltoModelEndpointcostService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.QueryInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.QueryInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.QueryOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.ResourceTypeEndpointcost;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.alto.request.endpointcost.request.EndpointcostRequest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.alto.request.endpointcost.request.EndpointcostRequestBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.alto.response.endpointcost.response.EndpointcostResponse;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.cost.type.container.CostType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.cost.type.container.CostTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.endpointcost.request.data.EndpointcostParams;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.endpointcost.request.data.EndpointcostParamsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.endpointcost.response.data.EndpointcostData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.Ipv4AddressData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.Ipv6AddressData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpoint.filter.data.EndpointFilterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpoint.filter.data.endpoint.filter.Destination;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpoint.filter.data.endpoint.filter.DestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpoint.filter.data.endpoint.filter.Source;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpoint.filter.data.endpoint.filter.SourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpointcostmap.response.data.EndpointCostMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpointcostmap.response.data.endpoint.cost.map.EndpointCost;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpointcostmap.response.data.endpoint.cost.map.endpoint.cost.Cost;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.input.request.endpointcost.request.endpointcost.params.filter.EndpointFilterData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.input.request.endpointcost.request.endpointcost.params.filter.EndpointFilterDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.input.request.endpointcost.request.endpointcost.params.filter.endpoint.filter.data.endpoint.filter.source.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.input.request.endpointcost.request.endpointcost.params.filter.endpoint.filter.data.endpoint.filter.source.address.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.endpointcost.data.EndpointCostmapData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.typed.address.data.Address;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+public class AltoNorthboundRouteEndpointcost implements BindingAwareProvider, AutoCloseable, AltoNorthboundRoute {
+    public static final String ENDPOINTCOST_ROUTE = "endpointcost";
+
+    public static final String ALTO_ENDPOINTCOST_FILTER = "application/alto-endpointcostfilter+json";
+    public static final String ALTO_ENDPOINTCOST = "application/alto-endpointcost+json";
+
+    public static final String FIELD_ENDPOINTS = "endpoints";
+    public static final String FIELD_COST_TYPE = "cost-type";
+    public static final String FIELD_COST_MODE = "cost-mode";
+    public static final String FIELD_COST_METRIC = "cost-metric";
+    public static final String FIELD_SOURCE = "srcs";
+    public static final String FIELD_DESTINSTION = "dsts";
+
+    private ObjectMapper mapper = new ObjectMapper();
+    private static final Logger LOG = LoggerFactory.getLogger(AltoNorthboundRouteEndpointcost.class);
+    private static DataBroker m_dataBroker = null;
+    private AltoNorthboundRouter m_router = null;
+
+    private  static AltoModelEndpointcostService mapService = null;
+    @Override
+    public void onSessionInitiated(ProviderContext session) {
+        m_dataBroker = session.getSALService(DataBroker.class);
+        if (m_dataBroker == null) {
+            LOG.error("Failed to init: data broker is null");
+        }
+
+        mapService = session.getRpcService(AltoModelEndpointcostService.class);
+        LOG.info("AltoNorthboundRouteEndpointcost initiated");
+
+    }
+
+    public void register(AltoNorthboundRouter router) {
+        m_router = router;
+        m_router.addRoute("endpointcost", new AltoNorthboundRouteEndpointcost());
+    }
+
+    @Override
+    public void close() {
+        m_router.removeRoute("endpointcost");
+    }
+
+    @Path("{path}")
+    @GET
+    @Produces({ALTO_ENDPOINTCOST, ALTO_ERROR})
+    public Response getFullMap(@PathParam("path") String path) throws JsonProcessingException{
+        QueryInput input = prepareDefaultInput(path);
+        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}")
+    @POST
+    @Consumes({ALTO_ENDPOINTCOST_FILTER})
+    @Produces({ALTO_ENDPOINTCOST, ALTO_ERROR})
+    public Response getFilteredMap(@PathParam("path") String path, String filter) throws JsonProcessingException {
+        Response error;
+
+        String cost_mode = null;
+        String cost_metric = null;
+        List<String> endpoints_source = null;
+        List<String> endpoints_destination = null;
+
+
+        try {
+            JsonNode filterNode = mapper.readTree(filter);
+
+            JsonNode _endpoints = filterNode.get(FIELD_ENDPOINTS);
+
+            error = EndpointcostRouteChecker.checkMissing(_endpoints, FIELD_ENDPOINTS, filter);
+            if (error != null)
+                return error;
+
+            error = EndpointcostRouteChecker.checkList(_endpoints, FIELD_ENDPOINTS, filter);
+            if (error != null)
+                return error;
+
+            //need check endpoints_source
+            JsonNode _endpoints_source = _endpoints.get(FIELD_SOURCE);
+            error = EndpointcostRouteChecker.checkList(_endpoints_source, FIELD_SOURCE, filter);
+            if (error != null){
+                return error;
+            }
+            endpoints_source = arrayNode2List(FIELD_SOURCE, (ArrayNode)_endpoints_source);
+
+            //need check endpoints_destination
+            JsonNode _endpoints_destination = _endpoints.get(FIELD_DESTINSTION);
+            error = EndpointcostRouteChecker.checkList(_endpoints_destination, FIELD_DESTINSTION, filter);
+            if (error != null){
+                return error;
+            }
+            endpoints_destination = arrayNode2List(FIELD_DESTINSTION, (ArrayNode) _endpoints_destination);
+
+            JsonNode _cost_type = filterNode.get(FIELD_COST_TYPE);
+            if(_cost_type == null){
+                error = null;
+                return error;
+            }else {
+                cost_mode = _cost_type.get(FIELD_COST_MODE).asText();
+                cost_metric = _cost_type.get(FIELD_COST_METRIC).asText();
+            }
+
+
+        } catch (JsonProcessingException e) {
+            throw e;
+        } catch (Exception e) {
+            return Response.status(500).build();
+        }
+
+        //TODO
+        QueryInput input = prepareInput(path, cost_mode, cost_metric, endpoints_source, endpoints_destination);
+        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();
+    }
+
+    protected List<String> arrayNode2List(String field, ArrayNode node) {
+        HashSet<String> retval = new HashSet<String>();
+
+        for (Iterator<JsonNode> itr = node.elements(); itr.hasNext(); ) {
+            JsonNode data = itr.next();
+
+            retval.add(data.asText());
+        }
+        return new LinkedList<String>(retval);
+    }
+
+    protected QueryInput prepareDefaultInput(String rid) {
+        /*
+         * Set pids as empty so all PID should be returned.
+         *
+         * Set address-types as missing so all address types should be returned.
+         *
+         * See https://tools.ietf.org/html/rfc7285#section-11.3.1.3
+         *
+         * */
+        return prepareInput(rid, null, null, new LinkedList<String>(), new LinkedList<String>());
+    }
+
+    protected QueryInput prepareInput(String path, String cost_mode, String cost_metric, List<String> endpoints_source, List<String> endpoints_destination) {
+        //TODO
+        QueryInputBuilder queryInputBuilder = new QueryInputBuilder();
+
+        //set request
+        EndpointcostRequestBuilder endpointcostRequestBuilder = new EndpointcostRequestBuilder();
+        EndpointcostParamsBuilder endpointcostParamsBuilder = new EndpointcostParamsBuilder();
+
+        CostTypeBuilder costTypeBuilder = new CostTypeBuilder();
+        costTypeBuilder.setCostMetric(new CostMetric(cost_metric));
+        costTypeBuilder.setCostMode(cost_mode);
+
+        EndpointFilterBuilder endpointFilterBuilder = new EndpointFilterBuilder();
+
+        List<Source> sources = new ArrayList<Source>();
+        List<Destination> destinations = new ArrayList<Destination>();
+
+        for(String source : endpoints_source){
+            SourceBuilder sourceBuilder = new SourceBuilder();
+            String[] tmp= source.split(":");
+            Ipv4Builder ipv4 = new Ipv4Builder();
+            Ipv6Builder ipv6 = new Ipv6Builder();
+            if(tmp[0].equals("ipv4")){
+                ipv4.setIpv4(new Ipv4Address(tmp[1]));
+                sourceBuilder.setAddress(ipv4.build());
+            }else if(tmp[0].equals("ipv6")){
+                ipv6.setIpv6(new Ipv6Address(tmp[1]));
+                sourceBuilder.setAddress(ipv6.build());
+            }
+            sources.add(sourceBuilder.build());
+        }
+        for(String destination : endpoints_destination){
+            DestinationBuilder destinationBuilder = new DestinationBuilder();
+            String[] tmp= destination.split(":");
+            Ipv4Builder ipv4 = new Ipv4Builder();
+            Ipv6Builder ipv6 = new Ipv6Builder();
+            if(tmp[0].equals("ipv4")){
+                ipv4.setIpv4(new Ipv4Address(tmp[1]));
+                destinationBuilder.setAddress(ipv4.build());
+            }else if(tmp[0].equals("ipv4")){
+                ipv6.setIpv6(new Ipv6Address(tmp[1]));
+                destinationBuilder.setAddress(ipv6.build());
+            }else return null;
+            destinations.add(destinationBuilder.build());
+        }
+        endpointFilterBuilder.setSource(sources);
+        endpointFilterBuilder.setDestination(destinations);
+        EndpointFilterDataBuilder endpointFilterDataBuilder = new EndpointFilterDataBuilder();
+        endpointFilterDataBuilder.setEndpointFilter(endpointFilterBuilder.build());
+
+        endpointcostParamsBuilder.setCostType(costTypeBuilder.build());
+        endpointcostParamsBuilder.setFilter(endpointFilterDataBuilder.build());
+        endpointcostRequestBuilder.setEndpointcostParams(endpointcostParamsBuilder.build());
+
+        //create servicereference by getting contexttag from resourcepool
+        ReadOnlyTransaction rtx = m_dataBroker.newReadOnlyTransaction();
+        InstanceIdentifier<ContextTag> ctagIID = getResourceByPath(path, rtx);
+        if(ctagIID == null){
+            return null;
+        }
+
+        queryInputBuilder.setRequest(endpointcostRequestBuilder.build());
+        queryInputBuilder.setServiceReference(ctagIID);
+        queryInputBuilder.setType(ResourceTypeEndpointcost.class);
+        return queryInputBuilder.build();
+    }
+
+    public InstanceIdentifier<ContextTag> getResourceByPath(String path, ReadTransaction transaction){
+        //get iid from (list Records)
+        InstanceIdentifier<Record> recordIID = InstanceIdentifier.builder(Records.class).child(Record.class, new RecordKey(new Uri(path))).build();
+
+        Future<Optional<Record>> recordFuture = transaction.read(LogicalDatastoreType.CONFIGURATION, recordIID);
+        Optional<Record> optional = null;
+        try{
+             optional = recordFuture.get();
+        }catch(Exception e){
+            LOG.error("Reading Record failed", e);
+            return null;
+        }
+        //get resourceIID from nbr-costmap.yang
+        InstanceIdentifier<?> record2resourceIID = null;
+        if(optional.isPresent())
+            record2resourceIID = optional.get().getResourceIid();
+        InstanceIdentifier<Resource> resourceIID = (InstanceIdentifier<Resource>)record2resourceIID;
+        Future<Optional<Resource>> resourceFuture = transaction.read(LogicalDatastoreType.OPERATIONAL, resourceIID);
+
+        Optional<Resource> optional1 = null;
+        try{
+            optional1 = resourceFuture.get();
+        }
+        catch(Exception e){
+            LOG.error("Read resource failed:", e);
+            return null;
+        }
+        Resource resource = null;
+        if(optional1.isPresent())
+            resource = optional1.get();
+        InstanceIdentifier<ContextTag> finalresourceIID = resourceIID.child(ContextTag.class, new ContextTagKey(resource.getDefaultTag()));
+        return finalresourceIID;
+    }
+
+
+
+    protected RFC7285Endpoint.CostResponse.Meta buildMeta(RFC7285CostType rfccostType) {
+        RFC7285Endpoint.CostResponse.Meta meta = new RFC7285Endpoint.CostResponse.Meta();
+        meta.costType = rfccostType;
+        return meta;
+    }
+
+    //Cost.toString is a String like Ordinal [_cost=2, augmentation=[]],and I need to extrat "_cost=2" from this String
+    protected String getCostValue(Cost cost){
+        String costValue = null;
+        String costString = cost.toString();
+        String[] a1 = costString.split(",");
+        String[] a2 = a1[0].split("=");
+        costValue = a2[1];
+        return costValue;
+    }
+    protected  String getAddressValue(Address address){
+        String addressValue = null;
+        if(address instanceof Ipv4AddressData){
+            Ipv4AddressData ipv4 = (Ipv4AddressData)address;
+            addressValue ="ipv4:" + ipv4.getIpv4().getValue();
+        }else if(address instanceof Ipv6AddressData){
+            Ipv6AddressData ipv6 = (Ipv6AddressData)address;
+            addressValue = "ipv6:"+ipv6.getIpv6().getValue();
+        }
+        return addressValue;
+    }
+
+    protected Response buildOutput(QueryInput input, QueryOutput output) throws JsonProcessingException{
+
+        //get costtype and endpoint source
+        EndpointcostRequest request = (EndpointcostRequest) input.getRequest();
+        EndpointcostParams params = request.getEndpointcostParams();
+        EndpointFilterData filterData = (EndpointFilterData) params.getFilter();
+
+        CostType costType = params.getCostType();
+        String cost_metric = costType.getCostMetric().getValue();
+        String cost_mode = costType.getCostMode();
+
+        List<Source> endpoints_source = filterData.getEndpointFilter().getSource();
+
+        //translate costtype to rfccosttype
+        RFC7285CostType rfccostType = new RFC7285CostType();
+        rfccostType.metric = cost_metric;
+        rfccostType.mode = cost_mode;
+
+        EndpointcostResponse ecResponse = (EndpointcostResponse)output.getResponse();
+        EndpointcostData ecData = ecResponse.getEndpointcostData();
+        EndpointCostmapData ecmData = null;
+        if (ecData instanceof EndpointCostmapData) {
+            ecmData = (EndpointCostmapData) ecResponse.getEndpointcostData();
+        }else return Response.ok("there is not endpointcostmap").build();
+
+        EndpointCostMap endpointCostMap = ecmData.getEndpointCostMap();
+        List<EndpointCost> endpointCostList =  endpointCostMap.getEndpointCost();
+
+        Map<String, Map<String, Object>> answer = new LinkedHashMap<String, Map<String, Object>>();
+
+        for(Source endpointsource : endpoints_source) {
+            Map<String, Object> dst2cost = new HashMap<>();
+            String endpointSourceAddressValue = getAddressValue(endpointsource.getAddress());
+            for (EndpointCost endpointCost : endpointCostList) {
+                String costSourceAddressValue = getAddressValue(endpointCost.getSource().getAddress());
+                String costDestinactionAddressValue = getAddressValue(endpointCost.getDestination().getAddress());
+                if(endpointSourceAddressValue.equals(costSourceAddressValue))
+                    dst2cost.put(costDestinactionAddressValue, getCostValue(endpointCost.getCost()));
+            }
+            answer.put(endpointSourceAddressValue, dst2cost);
+        }
+
+        RFC7285Endpoint.CostResponse rfcEndpointcost = new RFC7285Endpoint.CostResponse();
+        rfcEndpointcost.meta = buildMeta(rfccostType);
+        rfcEndpointcost.answer = answer;
+
+        String responseString = mapper.writeValueAsString(rfcEndpointcost);
+        return Response.ok(responseString, ALTO_ENDPOINTCOST).build();
+    }
+}
diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/EndpointcostRouteChecker.java b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/alto/core/northbound/route/endpointcost/impl/EndpointcostRouteChecker.java
new file mode 100644 (file)
index 0000000..8f0500c
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 Yale University and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.alto.core.northbound.route.endpointcost.impl;
+
+import javax.ws.rs.core.Response;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+public class EndpointcostRouteChecker {
+
+    public static Response checkMissing(JsonNode target, String field, String origin) {
+        if (target == null) {
+            // TODO :: report missing field, something like
+            // return new AltoMissingFieldError(field, origin);
+            return null;
+        }
+        return null;
+    }
+
+    public static Response checkList(JsonNode list, String field, String origin) {
+        if (!list.isArray()) {
+            // TODO :: report invalid field type, something like
+            // return new AltoInvalidFieldType(field, "array", origin);
+            return null;
+        }
+        return null;
+    }
+
+}
diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/core/northbound/route/endpointcost/impl/rev151021/AltoNorthboundRouteEndpointcostModule.java b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/core/northbound/route/endpointcost/impl/rev151021/AltoNorthboundRouteEndpointcostModule.java
new file mode 100644 (file)
index 0000000..252936d
--- /dev/null
@@ -0,0 +1,27 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.impl.rev151021;
+
+import org.opendaylight.alto.core.northbound.route.endpointcost.impl.AltoNorthboundRouteEndpointcost;
+
+public class AltoNorthboundRouteEndpointcostModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.impl.rev151021.AbstractAltoNorthboundRouteEndpointcostModule {
+    public AltoNorthboundRouteEndpointcostModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public AltoNorthboundRouteEndpointcostModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.impl.rev151021.AltoNorthboundRouteEndpointcostModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        AltoNorthboundRouteEndpointcost endpointcost = new AltoNorthboundRouteEndpointcost();
+        getBrokerDependency().registerProvider(endpointcost);
+        endpointcost.register(getAltoNorthboundRouterDependency());
+        return endpointcost;
+    }
+
+}
diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/core/northbound/route/endpointcost/impl/rev151021/AltoNorthboundRouteEndpointcostModuleFactory.java b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/core/northbound/route/endpointcost/impl/rev151021/AltoNorthboundRouteEndpointcostModuleFactory.java
new file mode 100644 (file)
index 0000000..cec93fa
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: alto-northbound-route-endpointcost-impl yang module local name: alto-northbound-route-endpointcost-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Sat Jan 02 16:06:35 CST 2016
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.impl.rev151021;
+public class AltoNorthboundRouteEndpointcostModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.northbound.route.endpointcost.impl.rev151021.AbstractAltoNorthboundRouteEndpointcostModuleFactory {
+
+}
diff --git a/alto-core/standard-northbound-routes/endpointcost/impl/src/main/yang/alto-northbound-route-endpointcost-impl.yang b/alto-core/standard-northbound-routes/endpointcost/impl/src/main/yang/alto-northbound-route-endpointcost-impl.yang
new file mode 100644 (file)
index 0000000..3ca7d2d
--- /dev/null
@@ -0,0 +1,45 @@
+module alto-northbound-route-endpointcost-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:alto:core:northbound:route:endpointcost:impl";
+    prefix "alto-northbound-router-endpointcost-impl";
+
+    import alto-northbound { prefix alto-northbound; revision-date 2015-10-21; }
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+
+    description
+        "Service definition for northbound project";
+
+    revision "2015-10-21" {
+        description
+            "Initial revision";
+    }
+
+    identity alto-northbound-route-endpointcost-impl {
+        base config:module-type;
+        config:java-name-prefix AltoNorthboundRouteEndpointcost;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case alto-northbound-route-endpointcost {
+            when "/config:modules/config:module/config:type = 'alto-northbound-route-endpointcost-impl'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+
+            container alto-northbound-router {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity alto-northbound:alto-northbound-router;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/alto-core/standard-northbound-routes/endpointcost/pom.xml b/alto-core/standard-northbound-routes/endpointcost/pom.xml
new file mode 100644 (file)
index 0000000..a94bece
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright © 2015 Copyright (c) Yale University and others. All rights reserved.
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
+--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <parent>
+    <groupId>org.opendaylight.odlparent</groupId>
+    <artifactId>odlparent</artifactId>
+    <version>1.7.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>routes-endpointcost-aggregator</artifactId>
+  <version>0.3.0-SNAPSHOT</version>
+  <name>alto-northbound-route-endpointcost-aggregator</name>
+  <packaging>pom</packaging>
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
+
+  <profiles>
+    <profile>
+      <id>minimal</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <modules>
+        <module>api</module>
+        <module>impl</module>
+      </modules>
+    </profile>
+
+    <profile>
+      <id>alto-dev</id>
+      <modules>
+        <module>api</module>
+        <module>impl</module>
+      </modules>
+    </profile>
+
+    <profile>
+      <id>alto-test</id>
+      <modules>
+        <module>api</module>
+        <module>impl</module>
+      </modules>
+    </profile>
+  </profiles>
+  <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
index cd9cdfea2343d5bc76ad898b8d5957c9ca2036ce..a6510a69d31a6093d61dfc538f61e95bdbefd10e 100644 (file)
@@ -32,6 +32,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <modules>
         <module>networkmap</module>
         <module>costmap</module>
+        <module>endpointcost</module>
       </modules>
     </profile>
 
@@ -41,6 +42,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
         <module>example</module>
         <module>networkmap</module>
         <module>costmap</module>
+        <module>endpointcost</module>
       </modules>
     </profile>
 
@@ -48,6 +50,9 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <id>alto-test</id>
       <modules>
         <module>example</module>
+        <module>networkmap</module>
+        <module>costmap</module>
+        <module>endpointcost</module>
       </modules>
     </profile>
   </profiles>
diff --git a/test/scripts/northbound/nbr-endpointcost-create b/test/scripts/northbound/nbr-endpointcost-create
new file mode 100644 (file)
index 0000000..e17a288
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+ENDPOINTCOST_PATH=$1
+RESOURCE_ID=$2
+if [ $3 ]; then
+       CONTEXT_ID=$3
+else
+       CONTEXT_ID="00000000-0000-0000-0000-000000000000"
+fi
+
+DATA=$(cat ./template/nbr-record-endpointcost \
+               | sed 's/\$1/'$ENDPOINTCOST_PATH'/g' \
+               | sed 's/\$2/'$CONTEXT_ID'/g' \
+               | sed 's/\$3/'$RESOURCE_ID'/g')
+
+# echo $DATA | python -m json.tool
+
+curl -X PUT -u admin:admin -H "Content-Type: application/json" \
+       -d "$DATA" \
+       http://localhost:8181/restconf/config/alto-nbr-endpointcost:records/record/$ENDPOINTCOST_PATH
index 13f0b24b2970bdcec9ad8d6df445ad5760c71d1c..fc09f1943fc849b0353f9e10455cfbd12952c51c 100755 (executable)
@@ -8,7 +8,7 @@ else
        CONTEXT_ID="00000000-0000-0000-0000-000000000000"
 fi
 
-DATA=$(cat ./northbound/template/nbr-record-networkmap \
+DATA=$(cat ./template/nbr-record-networkmap \
                | sed 's/\$1/'$NETWORKMAP_PATH'/g' \
                | sed 's/\$2/'$CONTEXT_ID'/g' \
                | sed 's/\$3/'$RESOURCE_ID'/g')
diff --git a/test/scripts/northbound/query-nbr-endpointcost b/test/scripts/northbound/query-nbr-endpointcost
new file mode 100644 (file)
index 0000000..48eb946
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+ENDPOINTCOST_PATH=$1
+
+DATA=$(cat ./template/endpointcost-filter)
+
+
+
+curl -X POST -u admin:admin -H "Content-Type: application/alto-endpointcostfilter+json" \
+       -d "$DATA" \
+       http://localhost:8080/alto/endpointcost/$ENDPOINTCOST_PATH | python -m json.tool
diff --git a/test/scripts/northbound/template/endpointcost-filter b/test/scripts/northbound/template/endpointcost-filter
new file mode 100644 (file)
index 0000000..7c582ee
--- /dev/null
@@ -0,0 +1,12 @@
+{
+       "cost-type": {"cost-mode" : "ordinal",
+       "cost-metric" : "routingcost"},
+       "endpoints" : {
+               "srcs": [ "ipv4:192.0.2.2" ],
+               "dsts": [
+                       "ipv4:192.0.2.89",
+                       "ipv4:198.51.100.34",
+                       "ipv4:203.0.113.45"
+               ]
+       }
+}
diff --git a/test/scripts/northbound/template/nbr-record-endpointcost b/test/scripts/northbound/template/nbr-record-endpointcost
new file mode 100644 (file)
index 0000000..0ff0305
--- /dev/null
@@ -0,0 +1,6 @@
+{
+       "record": {
+               "path": "$1",
+               "resource-iid": "/alto-resourcepool:context[alto-resourcepool:context-id='$2']/alto-resourcepool:resource[alto-resourcepool:resource-id='$3']"
+       }
+}