Implement the model for ECS 20/28920/2
authorKai GAO <gaok12@mails.tsinghua.edu.cn>
Thu, 29 Oct 2015 02:24:16 +0000 (10:24 +0800)
committerKai GAO <gaok12@mails.tsinghua.edu.cn>
Mon, 2 Nov 2015 12:31:50 +0000 (20:31 +0800)
Patch set 2: rewrite the model to avoid "when" statement

See https://tools.ietf.org/html/rfc6020#section-7.13.2 and
https://tools.ietf.org/html/rfc6020#section-7.13.3.

Change-Id: I35b3994d6dbd3a16c6faca1086d99d7106d7ae91
Signed-off-by: Kai GAO <gaok12@mails.tsinghua.edu.cn>
22 files changed:
README.md
alto-core/resourcepool/api/src/main/yang/alto-resourcepool.yang
alto-core/standard-service-models/model-endpointcost/api/pom.xml [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/api/src/main/yang/alto-model-endpointcost-rfc7285.yang [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/api/src/main/yang/alto-model-endpointcost.yang [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/artifacts/pom.xml [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/features/pom.xml [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/features/src/main/features/features.xml [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/impl/pom.xml [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/impl/src/main/config/default-config.xml [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/impl/src/main/config/maven-metadata-local.xml [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/impl/src/main/java/org/opendaylight/alto/core/impl/endpointcost/test/AltoEndpointCostProvider.java [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModule.java [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModuleFactory.java [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/impl/src/main/yang/alto-endpoint-test-impl.yang [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModuleFactoryTest.java [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModuleTest.java [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/it/pom.xml [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/it/src/test/java/org/opendaylight/alto/core/it/AltoEndpointcostIT.java [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/karaf/pom.xml [new file with mode: 0644]
alto-core/standard-service-models/model-endpointcost/pom.xml [new file with mode: 0644]
alto-core/standard-service-models/pom.xml

index 29d3afa10018451cee93333fbb6b7fec648128be..4ba0630e85e50f376261b1eb61c048f952afe596 100644 (file)
--- a/README.md
+++ b/README.md
@@ -6,3 +6,54 @@
 
 [routed-rpc]: https://ask.opendaylight.org/question/99/how-does-request-routing-works/
 [routed-rpc-example]: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blob;f=opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceTest.jav=d49d6f0e25e271e43c8550feb5eef63d9630118b=HEAD4a
+
+# Test service models for ALTO
+
+~~~
+{
+    "input": {
+        "service-reference":"/alto-resourcepool:resource-pool/alto-resourcepool:resource[alto-resourcepool:resource-id='test-model-base']"
+    }
+}
+
+
+{
+    "input": {
+        "service-reference":"/alto-resourcepool:resource-pool/alto-resourcepool:resource[alto-resourcepool:resource-id='test-model-networkmap']",
+        "type":"alto-model-networkmap:resource-type-networkmap",
+        "networkmap-filter": {
+            "pid": ["PID1", "PID2", "PID3"],
+            "address-type": [
+                "alto-model-networkmap:address-type-ipv4",
+                "alto-model-networkmap:address-type-ipv6"
+            ]
+        }
+    }
+}
+
+
+{
+    "input": {
+        "service-reference":"/alto-resourcepool:resource-pool/alto-resourcepool:resource[alto-resourcepool:resource-id='test-model-endpointcost']",
+        "type":"alto-model-endpointcost:resource-type-endpointcost",
+        "endpointcost-request": {
+            "cost-type": {
+                "cost-mode": "ordinal",
+                "cost-metric": "routingcost"
+            },
+            "endpoint-filter": {
+                "source": [
+                    {"ipv4": "192.168.0.1"},
+                    {"ipv4": "192.168.0.2"}
+                ],
+                "destination": [
+                    {"ipv4": "192.168.1.1"},
+                    {"ipv4": "192.168.1.2"}
+                ]
+            }
+        }
+    }
+}
+~~~
+
+
index 18e49075b2b5e2590129e88e509b6b78218a9f95..454d89660bc8bf95bd480412fad201f15c70da10 100644 (file)
@@ -41,32 +41,15 @@ module alto-resourcepool {
     }
 
     grouping "capability-spec" {
-        container "spec" {
-            leaf "category" {
-                type identityref {
-                    base "capability-category";
-                }
+        leaf "category" {
+            type identityref {
+                base "capability-category";
             }
         }
-    }
 
-    /* Examples to extend the capability spec
-    grouping "cost-type-spec" {
-        uses "capability-spec" {
-            augment "spec" {
-                container "cost-type" {
-                    leaf "cost-metric" {
-                        type string;
-                    }
-
-                    leaf "cost-mode" {
-                        type string;
-                    }
-                }
-            }
+        choice "spec" {
         }
     }
-    */
 
     grouping "resource-desc" {
         leaf "resource-id" {
diff --git a/alto-core/standard-service-models/model-endpointcost/api/pom.xml b/alto-core/standard-service-models/model-endpointcost/api/pom.xml
new file mode 100644 (file)
index 0000000..69e0f5a
--- /dev/null
@@ -0,0 +1,58 @@
+<?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.mdsal</groupId>
+    <artifactId>binding-parent</artifactId>
+    <version>0.8.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-service-model-endpointcost-api</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-basic-types</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-resourcepool-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-service-model-base-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.alto.core</groupId>
+      <artifactId>alto-service-model-networkmap-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.mdsal.model</groupId>
+      <artifactId>yang-ext</artifactId>
+    </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-service-models/model-endpointcost/api/src/main/yang/alto-model-endpointcost-rfc7285.yang b/alto-core/standard-service-models/model-endpointcost/api/src/main/yang/alto-model-endpointcost-rfc7285.yang
new file mode 100644 (file)
index 0000000..e6bddfa
--- /dev/null
@@ -0,0 +1,160 @@
+module alto-model-endpointcost-rfc7285 {
+    yang-version 1;
+
+    namespace "urn:opendaylight:alto:service:model:endpointcost:rfc7285";
+
+    prefix "alto-model-endpointcost-rfc7285";
+
+    import "alto-basic-types" {
+        prefix "alto-types";
+    }
+
+    import "alto-resourcepool" {
+        prefix "alto-resourcpool";
+    }
+
+    import "alto-model-base" {
+        prefix "base";
+    }
+
+    import "alto-model-networkmap" {
+        prefix "networkmap";
+    }
+
+    import "alto-model-endpointcost" {
+        prefix "endpointcost";
+    }
+
+    import "ietf-inet-types" {
+        prefix "ietf-inet";
+    }
+
+    organization "Yale University";
+
+    contact "alto-dev@lists.opendaylight.org";
+
+    revision "2015-10-21" {
+        description "Initial revision of alto endpointcost";
+    }
+
+    grouping "typed-address-data" {
+        choice "address" {
+        }
+    }
+
+    grouping "endpoint-filter-data" {
+        container "endpoint-filter" {
+            list "source" {
+                uses "typed-address-data";
+            }
+
+            list "destination" {
+                uses "typed-address-data";
+            }
+        }
+    }
+
+    identity "filter-type-endpointfilter" {
+        base "endpointcost:filter-type-base";
+    }
+
+    augment "/base:query/base:input/base:request/endpointcost:endpointcost-request-data/endpointcost:endpointcost-request/endpointcost:filter" {
+        case "endpoint-filter-data" {
+            uses "endpoint-filter-data";
+        }
+    }
+
+    identity "endpointcost-response-type-endpointcostmap" {
+        base "endpointcost:endpointcost-response-type-base";
+    }
+
+    grouping "endpointcostmap-response-data" {
+        container "endpoint-cost-map" {
+            list "endpoint-cost-list" {
+                uses "typed-address-data";
+
+                list "endpoint-destination-cost" {
+                    uses "typed-address-data";
+
+                    choice "cost" {
+                    }
+                }
+            }
+        }
+    }
+
+    augment "/base:query/base:output/base:response/endpointcost:endpointcost-response-data/endpointcost:endpointcost-response/endpointcost:data/" {
+        case "endpoint-cost-map-data" {
+            uses "endpointcostmap-response-data";
+        }
+    }
+
+    grouping "ipv4-address-data" {
+        leaf "ipv4" {
+            type ietf-inet:ipv4-address;
+        }
+    }
+
+    grouping "ipv6-address-data" {
+        leaf "ipv6" {
+            type ietf-inet:ipv6-address;
+        }
+    }
+
+    augment "/base:query/base:input/base:request/endpointcost:endpointcost-request-data/endpointcost:endpointcost-request/endpointcost:filter/endpoint-filter-data/endpoint-filter/source/address" {
+        case ipv4 {
+            uses "ipv4-address-data";
+        }
+
+        case ipv6 {
+            uses "ipv6-address-data";
+        }
+    }
+
+    augment "/base:query/base:input/base:request/endpointcost:endpointcost-request-data/endpointcost:endpointcost-request/endpointcost:filter/endpoint-filter-data/endpoint-filter/destination/address" {
+        case ipv4 {
+            uses "ipv4-address-data";
+        }
+
+        case ipv6 {
+            uses "ipv6-address-data";
+        }
+    }
+
+
+    augment "/base:query/base:output/base:response/endpointcost:endpointcost-response-data/endpointcost:endpointcost-response/endpointcost:data/endpoint-cost-map-data/endpoint-cost-map/endpoint-cost-list/address" {
+        case ipv4 {
+            uses "ipv4-address-data";
+        }
+
+        case ipv6 {
+            uses "ipv6-address-data";
+        }
+    }
+
+    augment "/base:query/base:output/base:response/endpointcost:endpointcost-response-data/endpointcost:endpointcost-response/endpointcost:data/endpoint-cost-map-data/endpoint-cost-map/endpoint-cost-list/endpoint-destination-cost/address" {
+        case ipv4 {
+            uses "ipv4-address-data";
+        }
+
+        case ipv6 {
+            uses "ipv6-address-data";
+        }
+    }
+
+    augment "/base:query/base:output/base:response/endpointcost:endpointcost-response-data/endpointcost:endpointcost-response/endpointcost:data/endpoint-cost-map-data/endpoint-cost-map/endpoint-cost-list/endpoint-destination-cost/cost" {
+        case numerical {
+            leaf "cost" {
+                type decimal64 {
+                    fraction-digits 4;
+                }
+            }
+        }
+
+       case ordinal {
+            leaf "cost" {
+                type int32;
+            }
+        }
+    }
+}
diff --git a/alto-core/standard-service-models/model-endpointcost/api/src/main/yang/alto-model-endpointcost.yang b/alto-core/standard-service-models/model-endpointcost/api/src/main/yang/alto-model-endpointcost.yang
new file mode 100644 (file)
index 0000000..67e9ced
--- /dev/null
@@ -0,0 +1,116 @@
+module alto-model-endpointcost {
+    yang-version 1;
+
+    namespace "urn:opendaylight:alto:service:model:endpointcost";
+
+    prefix "alto-model-endpointcost";
+
+    import "alto-basic-types" {
+        prefix "alto-types";
+    }
+
+    import "alto-resourcepool" {
+        prefix "alto-resourcpool";
+    }
+
+    import "alto-model-base" {
+        prefix "base";
+    }
+
+    import "alto-model-networkmap" {
+        prefix "networkmap";
+    }
+
+    import "ietf-inet-types" {
+        prefix "ietf-inet";
+    }
+
+    organization "Yale University";
+
+    contact "alto-dev@lists.opendaylight.org";
+
+    revision "2015-10-21" {
+        description "Initial revision of alto endpointcost";
+    }
+
+    identity "resource-type-endpointcost" {
+        base "alto-resourcepool:resource-type";
+        description
+            "The resource type for endpoint cost service";
+    }
+
+    grouping "cost-type-data" {
+        container "cost-type" {
+            leaf "cost-metric" {
+                type alto-types:cost-metric;
+            }
+
+            leaf "cost-mode" {
+                mandatory true;
+                type string;
+            }
+        }
+    }
+
+    identity "filter-type-base" {
+        description
+            "Base type for endpoint cost filters";
+    }
+
+    grouping "endpointcost-request-data" {
+        container "endpointcost-request" {
+            uses "cost-type-data";
+
+            leaf-list "constraints" {
+                type string;
+            }
+
+            choice "filter" {
+            }
+        }
+    }
+
+    identity "endpointcost-response-type-base" {
+        description
+            "Base identity for endpoint cost response";
+    }
+
+    grouping "endpointcost-response-data" {
+        container "endpointcost-response" {
+            uses "cost-type-data";
+
+            choice "data" {
+            }
+        }
+    }
+
+    augment "/base:query/base:input/base:request" {
+        case "endpointcost-request-data" {
+            uses "endpointcost-request-data";
+        }
+    }
+
+    augment "/base:query/base:output/base:response" {
+        case "endpointcost-response-data" {
+            uses "endpointcost-response-data";
+        }
+    }
+
+    augment "/alto-resourcepool:resource-pool/alto-resourcepool:resource/alto-resourcepool:capability/alto-resourcepool:spec/" {
+        case "cost-type-spec" {
+            uses "cost-type-data";
+        }
+    }
+
+    augment "/alto-resourcepool:verify-resource/alto-resourcepool:input/alto-resourcepool:capability/alto-resourcepool:spec/" {
+        case "cost-type-spec" {
+            uses "cost-type-data";
+        }
+    }
+
+    augment "/alto-resourcepool:add-resource/alto-resourcepool:input/alto-resourcepool:capability/alto-resourcepool:spec/" {
+        case "cost-type-spec" {
+            uses "cost-type-data";
+        }
+    }
+}
diff --git a/alto-core/standard-service-models/model-endpointcost/artifacts/pom.xml b/alto-core/standard-service-models/model-endpointcost/artifacts/pom.xml
new file mode 100644 (file)
index 0000000..024efdc
--- /dev/null
@@ -0,0 +1,39 @@
+<?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">
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-service-model-endpointcost-artifacts</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>${project.groupId}</groupId>
+        <artifactId>alto-service-model-endpointcost-api</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>${project.groupId}</groupId>
+        <artifactId>alto-service-model-endpointcost-impl</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>${project.groupId}</groupId>
+        <artifactId>alto-service-model-endpointcost-features</artifactId>
+        <version>${project.version}</version>
+        <classifier>features</classifier>
+        <type>xml</type>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+</project>
diff --git a/alto-core/standard-service-models/model-endpointcost/features/pom.xml b/alto-core/standard-service-models/model-endpointcost/features/pom.xml
new file mode 100644 (file)
index 0000000..91580a0
--- /dev/null
@@ -0,0 +1,123 @@
+<?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 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>features-parent</artifactId>
+    <version>1.6.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-service-model-endpointcost-features</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <name>${project.artifactId}</name>
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
+  <properties>
+    <mdsal.model.version>0.8.0-SNAPSHOT</mdsal.model.version>
+    <mdsal.version>1.3.0-SNAPSHOT</mdsal.version>
+    <restconf.version>1.3.0-SNAPSHOT</restconf.version>
+    <yangtools.version>0.8.0-SNAPSHOT</yangtools.version>
+    <dlux.version>0.3.0-SNAPSHOT</dlux.version>
+    <configfile.directory>etc/opendaylight/karaf</configfile.directory>
+  </properties>
+  <dependencyManagement>
+    <dependencies>
+      <!-- project specific dependencies -->
+      <dependency>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>mdsal-artifacts</artifactId>
+        <version>${mdsal.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.opendaylight.netconf</groupId>
+        <artifactId>restconf-artifacts</artifactId>
+        <version>${restconf.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>features-yangtools</artifactId>
+      <classifier>features</classifier>
+      <version>${yangtools.version}</version>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.mdsal.model</groupId>
+      <artifactId>features-mdsal-model</artifactId>
+      <version>${mdsal.model.version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>features-mdsal</artifactId>
+      <classifier>features</classifier>
+      <version>${mdsal.version}</version>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.netconf</groupId>
+      <artifactId>features-restconf</artifactId>
+      <classifier>features</classifier>
+      <version>${restconf.version}</version>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.dlux</groupId>
+      <artifactId>features-dlux</artifactId>
+      <classifier>features</classifier>
+      <version>${dlux.version}</version>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-endpointcost-impl</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-endpointcost-impl</artifactId>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <classifier>config</classifier>
+    </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-service-model-base-features</artifactId>
+      <classifier>features</classifier>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-base-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/alto-core/standard-service-models/model-endpointcost/features/src/main/features/features.xml b/alto-core/standard-service-models/model-endpointcost/features/src/main/features/features.xml
new file mode 100644 (file)
index 0000000..f6b64a6
--- /dev/null
@@ -0,0 +1,47 @@
+<?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
+-->
+<features name="odl-alto-service-model-endpointcost-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+  <repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
+  <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
+  <repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/${mdsal.model.version}/xml/features</repository>
+  <repository>mvn:org.opendaylight.netconf/features-restconf/${restconf.version}/xml/features</repository>
+  <repository>mvn:org.opendaylight.dlux/features-dlux/${dlux.version}/xml/features</repository>
+  <repository>mvn:org.opendaylight.alto.core/alto-service-model-base-features/${project.version}/xml/features</repository>
+  <repository>mvn:org.opendaylight.alto.core/alto-service-model-networkmap-features/${project.version}/xml/features</repository>
+
+  <feature name='odl-alto-service-model-endpointcost-api' version='${project.version}' description='OpenDaylight :: alto-service-model-endpointcost :: api'>
+    <feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
+    <feature version='${project.version}'>odl-alto-service-model-base</feature>
+    <feature version='${project.version}'>odl-alto-service-model-networkmap-api</feature>
+    <bundle>mvn:org.opendaylight.alto.core/alto-service-model-endpointcost-api/${project.version}</bundle>
+  </feature>
+
+  <feature name='odl-alto-service-model-endpointcost' version='${project.version}' description='OpenDaylight :: alto-service-model-endpointcost'>
+    <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
+    <feature version='${project.version}'>odl-alto-service-model-endpointcost-api</feature>
+    <bundle>mvn:org.opendaylight.alto.core/alto-service-model-endpointcost-impl/${project.version}</bundle>
+    <configfile finalname="${configfile.directory}/alto-service-model-endpointcost.xml">mvn:org.opendaylight.alto.core/alto-service-model-endpointcost-impl/${project.version}/xml/config</configfile>
+  </feature>
+
+  <feature name='odl-alto-service-model-endpointcost-rest' version='${project.version}' description='OpenDaylight :: alto-service-model-endpointcost :: REST'>
+    <feature version="${project.version}">odl-alto-service-model-endpointcost</feature>
+    <feature version="${restconf.version}">odl-restconf</feature>
+  </feature>
+
+  <feature name='odl-alto-service-model-endpointcost-ui' version='${project.version}' description='OpenDaylight :: alto-service-model-endpointcost :: UI'>
+    <feature version="${project.version}">odl-alto-service-model-endpointcost-rest</feature>
+    <feature version="${restconf.version}">odl-mdsal-apidocs</feature>
+    <feature version="${mdsal.version}">odl-mdsal-xsql</feature>
+    <feature version="${dlux.version}">odl-dlux-yangui</feature>
+  </feature>
+
+</features>
diff --git a/alto-core/standard-service-models/model-endpointcost/impl/pom.xml b/alto-core/standard-service-models/model-endpointcost/impl/pom.xml
new file mode 100644 (file)
index 0000000..a43e0d1
--- /dev/null
@@ -0,0 +1,63 @@
+<?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.4.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-service-model-endpointcost-impl</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-base-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-resourcepool-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-networkmap-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-endpointcost-api</artifactId>
+      <version>${project.version}</version>
+    </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>
+  </dependencies>
+
+</project>
diff --git a/alto-core/standard-service-models/model-endpointcost/impl/src/main/config/default-config.xml b/alto-core/standard-service-models/model-endpointcost/impl/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..cad56de
--- /dev/null
@@ -0,0 +1,30 @@
+<?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:service:model:test:endpointcost?module=alto-endpointcost-test-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>
+  </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:service:model:test:endpointcost">prefix:alto-model-endpointcost-test</type>
+          <name>alto-endpointcost-test</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>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/alto-core/standard-service-models/model-endpointcost/impl/src/main/config/maven-metadata-local.xml b/alto-core/standard-service-models/model-endpointcost/impl/src/main/config/maven-metadata-local.xml
new file mode 100644 (file)
index 0000000..02c8797
--- /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-service-model-endpointcost-impl</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <versioning>
+    <snapshot>
+      <localCopy>true</localCopy>
+    </snapshot>
+    <lastUpdated>20151028073152</lastUpdated>
+    <snapshotVersions>
+      <snapshotVersion>
+        <classifier>config</classifier>
+        <extension>xml</extension>
+        <value>0.2.0-SNAPSHOT</value>
+        <updated>20151028073152</updated>
+      </snapshotVersion>
+    </snapshotVersions>
+  </versioning>
+</metadata>
diff --git a/alto-core/standard-service-models/model-endpointcost/impl/src/main/java/org/opendaylight/alto/core/impl/endpointcost/test/AltoEndpointCostProvider.java b/alto-core/standard-service-models/model-endpointcost/impl/src/main/java/org/opendaylight/alto/core/impl/endpointcost/test/AltoEndpointCostProvider.java
new file mode 100644 (file)
index 0000000..23e367a
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ * 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
+ */
+package org.opendaylight.alto.core.impl.endpointcost.test;
+
+import java.math.BigDecimal;
+import java.util.concurrent.Future;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.AddResourceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.AltoResourcepoolService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.ResourcePool;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.ServiceContext;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.resource.desc.Capability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.resource.desc.CapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.resource.pool.Resource;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.resource.pool.ResourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.resourcepool.rev150921.resource.pool.ResourceKey;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.types.rev150921.CostMetric;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.core.types.rev150921.ResourceId;
+
+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.cost.type.data.CostType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.cost.type.data.CostTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.endpointcost.request.data.EndpointcostRequest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.endpointcost.response.data.EndpointcostResponseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.query.input.request.EndpointcostRequestData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.query.output.response.EndpointcostResponseDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rev151021.verify.resource.input.capability.spec.CostTypeSpecBuilder;
+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.TypedAddressData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpoint.filter.data.EndpointFilter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpointcostmap.response.data.EndpointCostMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpointcostmap.response.data.endpoint.cost.map.EndpointCostList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpointcostmap.response.data.endpoint.cost.map.EndpointCostListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpointcostmap.response.data.endpoint.cost.map.endpoint.cost.list.EndpointDestinationCost;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpointcostmap.response.data.endpoint.cost.map.endpoint.cost.list.EndpointDestinationCostBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.endpointcostmap.response.data.endpoint.cost.map.endpoint.cost.list.endpoint.destination.cost.Cost;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.input.request.endpointcost.request.data.endpointcost.request.filter.EndpointFilterData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.EndpointCostMapDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.typed.address.data.Address;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.rev151021.AltoModelBaseService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.rev151021.QueryInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.rev151021.QueryOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.rev151021.QueryOutputBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AltoEndpointCostProvider implements BindingAwareProvider, AutoCloseable, AltoModelBaseService {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AltoEndpointCostProvider.class);
+
+    private DataBroker m_dataBrokerService = null;
+    private RoutedRpcRegistration<AltoModelBaseService> m_serviceReg = null;
+    private AltoResourcepoolService m_resourcepoolService = null;
+
+    private static final ResourceId TEST_ENDPOINTCOST_RID = new ResourceId("test-model-endpointcost");
+    private static final CostMetric COST_METRIC_ROUTINGCOST = new CostMetric("routingcost");
+    private InstanceIdentifier<Resource> m_testIID = null;
+
+    protected InstanceIdentifier<Resource> getResourceIID(ResourceId rid) {
+        ResourceKey key = new ResourceKey(rid);
+        return InstanceIdentifier.builder(ResourcePool.class).child(Resource.class, key).build();
+    }
+
+    @Override
+    public void onSessionInitiated(ProviderContext session) {
+        LOG.info("AltoModelEndpointCostProvider Session Initiated");
+
+        m_dataBrokerService = session.getSALService(DataBroker.class);
+        m_serviceReg = session.addRoutedRpcImplementation(AltoModelBaseService.class, this);
+
+        CostTypeBuilder ctBuilder = new CostTypeBuilder();
+        ctBuilder.setCostMetric(COST_METRIC_ROUTINGCOST);
+        ctBuilder.setCostMode("ordinal");
+
+        CostTypeSpecBuilder ctsBuilder = new CostTypeSpecBuilder();
+        ctsBuilder.setCostType(ctBuilder.build());
+
+        CapabilityBuilder capBuilder = new CapabilityBuilder();
+        capBuilder.setSpec(ctsBuilder.build());
+
+        LinkedList<Capability> capabilityList = new LinkedList<Capability>();
+        capabilityList.add(capBuilder.build());
+
+        ResourceBuilder builder = new ResourceBuilder();
+        builder.setResourceId(TEST_ENDPOINTCOST_RID).setType(ResourceTypeEndpointcost.class);
+        builder.setCapability(capabilityList);
+
+        AddResourceInputBuilder inputBuilder = new AddResourceInputBuilder();
+        inputBuilder.fieldsFrom(builder.build());
+
+        try {
+            AltoResourcepoolService resourcepool;
+            resourcepool = session.getRpcService(AltoResourcepoolService.class);
+
+            RpcResult<Void> result;
+            result = resourcepool.addResource(inputBuilder.build()).get();
+
+            assert result.isSuccessful();
+
+            m_testIID = getResourceIID(TEST_ENDPOINTCOST_RID);
+            m_serviceReg.registerPath(ServiceContext.class, m_testIID);
+        } catch (Exception e) {
+        }
+    }
+
+    @Override
+    public void close() throws Exception {
+        LOG.info("AltoModelBaseProvider Closed");
+    }
+
+    protected Cost createNumericalCost(double cost) {
+        org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.endpoint.destination.cost.cost.NumericalBuilder builder;
+        builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.endpoint.destination.cost.cost.NumericalBuilder();
+
+        builder.setCost(new BigDecimal(cost));
+        return builder.build();
+    }
+
+    protected Cost createOrdinalCost(int order) {
+        org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.endpoint.destination.cost.cost.OrdinalBuilder builder;
+        builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.endpoint.destination.cost.cost.OrdinalBuilder();
+
+        builder.setCost(order);
+        return builder.build();
+    }
+
+    protected Address createSourceAddress(Address from) {
+        if (from instanceof Ipv4AddressData) {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.address.Ipv4Builder builder;
+            builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.address.Ipv4Builder();
+
+            builder.fieldsFrom((Ipv4AddressData)from);
+            return builder.build();
+        } else if (from instanceof Ipv6AddressData) {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.address.Ipv6Builder builder;
+            builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.address.Ipv6Builder();
+
+            builder.fieldsFrom((Ipv6AddressData)from);
+            return builder.build();
+}
+        return null;
+    }
+
+    protected Address createDestinationAddress(Address from) {
+        if (from instanceof Ipv4AddressData) {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.endpoint.destination.cost.address.Ipv4Builder builder;
+            builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.endpoint.destination.cost.address.Ipv4Builder();
+
+            builder.fieldsFrom((Ipv4AddressData)from);
+            return builder.build();
+        } else if (from instanceof Ipv6AddressData) {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.endpoint.destination.cost.address.Ipv6Builder builder;
+            builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.endpointcost.rfc7285.rev151021.query.output.response.endpointcost.response.data.endpointcost.response.data.endpoint.cost.map.data.endpoint.cost.map.endpoint.cost.list.endpoint.destination.cost.address.Ipv6Builder();
+
+            builder.fieldsFrom((Ipv6AddressData)from);
+            return builder.build();
+        }
+        return null;
+    }
+
+    @Override
+    public Future<RpcResult<QueryOutput>> query(QueryInput input) {
+        if (!input.getType().equals(ResourceTypeEndpointcost.class)) {
+            return RpcResultBuilder.<QueryOutput>failed().buildFuture();
+        }
+        EndpointcostRequestData requestData = (EndpointcostRequestData)input.getRequest();
+        EndpointcostRequest request = requestData.getEndpointcostRequest();
+        CostType costType = request.getCostType();
+
+        if (!(request.getFilter() instanceof EndpointFilterData)) {
+            return RpcResultBuilder.<QueryOutput>failed().buildFuture();
+        }
+        if (!costType.getCostMode().equals("ordinal")) {
+            LOG.warn(costType.getCostMode().toString());
+            return RpcResultBuilder.<QueryOutput>failed().buildFuture();
+        }
+        if (!costType.getCostMetric().equals(COST_METRIC_ROUTINGCOST)) {
+            LOG.warn(costType.getCostMetric().toString());
+            return RpcResultBuilder.<QueryOutput>failed().buildFuture();
+        }
+
+        EndpointFilter filter = ((EndpointFilterData)request.getFilter()).getEndpointFilter();
+        List<? extends TypedAddressData> source = filter.getSource();
+        List<? extends TypedAddressData> destination = filter.getDestination();
+
+        int order = 0;
+        LinkedList<EndpointCostList> eclList = new LinkedList<EndpointCostList>();
+        for (TypedAddressData src: source) {
+            LinkedList<EndpointDestinationCost> edcList = new LinkedList<EndpointDestinationCost>();
+            for (TypedAddressData dst: destination) {
+                EndpointDestinationCostBuilder edcBuilder = new EndpointDestinationCostBuilder();
+
+                edcBuilder.setAddress(createDestinationAddress(dst.getAddress()));
+                edcBuilder.setCost(createOrdinalCost(++order));
+
+                edcList.add(edcBuilder.build());
+            }
+
+            EndpointCostListBuilder eclBuilder = new EndpointCostListBuilder();
+            eclBuilder.setAddress(createSourceAddress(src.getAddress()));
+            eclBuilder.setEndpointDestinationCost(edcList);
+
+            eclList.add(eclBuilder.build());
+        }
+
+        EndpointCostMapBuilder ecmBuilder = new EndpointCostMapBuilder();
+        ecmBuilder.setEndpointCostList(eclList);
+
+        EndpointCostMapDataBuilder ecmdBuilder = new EndpointCostMapDataBuilder();
+        ecmdBuilder.setEndpointCostMap(ecmBuilder.build());
+
+        EndpointcostResponseBuilder ecsBuilder = new EndpointcostResponseBuilder();
+        ecsBuilder.setCostType(costType);
+        ecsBuilder.setData(ecmdBuilder.build());
+
+        EndpointcostResponseDataBuilder ecrdBuilder = new EndpointcostResponseDataBuilder();
+        ecrdBuilder.setEndpointcostResponse(ecsBuilder.build());
+
+        QueryOutputBuilder builder = new QueryOutputBuilder();
+        builder.setType(ResourceTypeEndpointcost.class).setResponse(ecrdBuilder.build());
+        return RpcResultBuilder.<QueryOutput>success(builder.build()).buildFuture();
+    }
+
+}
diff --git a/alto-core/standard-service-models/model-endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModule.java b/alto-core/standard-service-models/model-endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModule.java
new file mode 100644 (file)
index 0000000..8b83686
--- /dev/null
@@ -0,0 +1,27 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.test.endpointcost.rev151021;
+
+import org.opendaylight.alto.core.impl.endpointcost.test.AltoEndpointCostProvider;
+
+public class AltoEndpointCostModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.test.endpointcost.rev151021.AbstractAltoEndpointCostModule {
+    public AltoEndpointCostModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public AltoEndpointCostModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.test.endpointcost.rev151021.AltoEndpointCostModule 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() {
+        AltoEndpointCostProvider provider = new AltoEndpointCostProvider();
+
+        getBrokerDependency().registerProvider(provider);
+        return provider;
+    }
+
+}
diff --git a/alto-core/standard-service-models/model-endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModuleFactory.java b/alto-core/standard-service-models/model-endpointcost/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModuleFactory.java
new file mode 100644 (file)
index 0000000..beaac02
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: alto-endpointcost-test-impl yang module local name: alto-model-endpointcost-test
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Oct 28 21:04:15 CST 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.test.endpointcost.rev151021;
+public class AltoEndpointCostModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.test.endpointcost.rev151021.AbstractAltoEndpointCostModuleFactory {
+
+}
diff --git a/alto-core/standard-service-models/model-endpointcost/impl/src/main/yang/alto-endpoint-test-impl.yang b/alto-core/standard-service-models/model-endpointcost/impl/src/main/yang/alto-endpoint-test-impl.yang
new file mode 100644 (file)
index 0000000..afee1fa
--- /dev/null
@@ -0,0 +1,35 @@
+module alto-endpointcost-test-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:alto:service:model:test:endpointcost";
+    prefix "alto-model-endpointcost-test-impl";
+
+    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 endpointcost project";
+
+    revision "2015-10-21" {
+        description
+            "Initial revision";
+    }
+
+    identity alto-model-endpointcost-test {
+        base config:module-type;
+        config:java-name-prefix AltoEndpointCost;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case alto-model-endpointcost-test-impl {
+            when "/config:modules/config:module/config:type = 'alto-model-endpointcost-test'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/alto-core/standard-service-models/model-endpointcost/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModuleFactoryTest.java b/alto-core/standard-service-models/model-endpointcost/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModuleFactoryTest.java
new file mode 100644 (file)
index 0000000..64c8684
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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
+ */
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.test.endpointcost.rev151021;
+
+import org.junit.Test;
+
+public class AltoEndpointCostModuleFactoryTest {
+    @Test
+    public void testFactoryConstructor() {
+        // ensure no exceptions on construction
+        new AltoEndpointCostModuleFactory();
+    }
+}
diff --git a/alto-core/standard-service-models/model-endpointcost/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModuleTest.java b/alto-core/standard-service-models/model-endpointcost/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/alto/service/model/test/endpointcost/rev151021/AltoEndpointCostModuleTest.java
new file mode 100644 (file)
index 0000000..ce088dd
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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
+ */
+package org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.model.test.endpointcost.rev151021;
+
+import org.junit.Test;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.JmxAttribute;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.alto.core.impl.endpointcost.test.AltoEndpointCostProvider;
+
+import javax.management.ObjectName;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class AltoEndpointCostModuleTest {
+    @Test
+    public void testCustomValidation() {
+        AltoEndpointCostModule module = new AltoEndpointCostModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
+
+        // ensure no exceptions on validation
+        // currently this method is empty
+        module.customValidation();
+    }
+
+    @Test
+    public void testCreateInstance() throws Exception {
+        // configure mocks
+        DependencyResolver dependencyResolver = mock(DependencyResolver.class);
+        BindingAwareBroker broker = mock(BindingAwareBroker.class);
+        when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
+
+        // create instance of module with injected mocks
+        AltoEndpointCostModule module = new AltoEndpointCostModule(mock(ModuleIdentifier.class), dependencyResolver);
+
+        // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
+        AutoCloseable closeable = module.getInstance();
+
+        // verify that the module registered the returned provider with the broker
+        verify(broker).registerProvider((AltoEndpointCostProvider)closeable);
+
+        // ensure no exceptions on close
+        closeable.close();
+    }
+}
diff --git a/alto-core/standard-service-models/model-endpointcost/it/pom.xml b/alto-core/standard-service-models/model-endpointcost/it/pom.xml
new file mode 100644 (file)
index 0000000..8460bb0
--- /dev/null
@@ -0,0 +1,41 @@
+<?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>mdsal-it-parent</artifactId>
+    <version>1.3.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-service-model-endpointcost-it</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <properties>
+    <skipITs>false</skipITs>
+    <karaf.distro.groupId>org.opendaylight.alto.core</karaf.distro.groupId>
+    <karaf.distro.artifactId>alto-service-model-endpointcost-karaf</karaf.distro.artifactId>
+    <karaf.distro.version>0.2.0-SNAPSHOT</karaf.distro.version>
+    <karaf.distro.type>zip</karaf.distro.type>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-endpointcost-features</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/alto-core/standard-service-models/model-endpointcost/it/src/test/java/org/opendaylight/alto/core/it/AltoEndpointcostIT.java b/alto-core/standard-service-models/model-endpointcost/it/src/test/java/org/opendaylight/alto/core/it/AltoEndpointcostIT.java
new file mode 100644 (file)
index 0000000..533f25c
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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
+ */
+package org.opendaylight.alto.core.it;
+
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.options.MavenUrlReference;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class AltoEndpointcostIT extends AbstractMdsalTestBase {
+    private static final Logger LOG = LoggerFactory.getLogger(AltoEndpointcostIT.class);
+
+    @Override
+    public String getModuleName() {
+        return "alto-model-endpointcost-test";
+    }
+
+    @Override
+    public String getInstanceName() {
+        return "alto-endpointcost-test";
+    }
+
+    @Override
+    public MavenUrlReference getFeatureRepo() {
+        return maven()
+                .groupId("org.opendaylight.alto.core")
+                .artifactId("alto-service-model-endpointcost-features")
+                .classifier("features")
+                .type("xml")
+                .versionAsInProject();
+    }
+
+    @Override
+    public String getFeatureName() {
+        return "odl-alto-service-model-endpointcost-ui";
+    }
+
+    @Override
+    public Option getLoggingOption() {
+        Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+                logConfiguration(AltoEndpointcostIT.class),
+                LogLevel.INFO.name());
+        option = composite(option, super.getLoggingOption());
+        return option;
+    }
+
+    @Test
+    public void testendpointcostFeatureLoad() {
+        Assert.assertTrue(true);
+    }
+}
diff --git a/alto-core/standard-service-models/model-endpointcost/karaf/pom.xml b/alto-core/standard-service-models/model-endpointcost/karaf/pom.xml
new file mode 100644 (file)
index 0000000..42a71cf
--- /dev/null
@@ -0,0 +1,66 @@
+<?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 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.controller</groupId>
+    <artifactId>karaf-parent</artifactId>
+    <version>1.6.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-service-model-endpointcost-karaf</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <name>${project.artifactId}</name>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
+  <properties>
+    <karaf.localFeature>odl-alto-service-model-endpointcost-ui</karaf.localFeature>
+  </properties>
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>${project.groupId}</groupId>
+        <artifactId>alto-service-model-endpointcost-artifacts</artifactId>
+        <version>${project.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  <dependencies>
+    <dependency>
+      <!-- scope is compile so all features (there is only one) are installed
+      into startup.properties and the feature repo itself is not installed -->
+      <groupId>org.apache.karaf.features</groupId>
+      <artifactId>framework</artifactId>
+      <type>kar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-service-model-endpointcost-features</artifactId>
+      <classifier>features</classifier>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
+  </dependencies>
+  <!-- DO NOT install or deploy the karaf artifact -->
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/alto-core/standard-service-models/model-endpointcost/pom.xml b/alto-core/standard-service-models/model-endpointcost/pom.xml
new file mode 100644 (file)
index 0000000..b635bf1
--- /dev/null
@@ -0,0 +1,79 @@
+<?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 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.6.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.alto.core</groupId>
+  <artifactId>alto-service-model-endpointcost-aggregator</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <name>alto-service-model-endpointcost</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>
+      </modules>
+    </profile>
+
+    <profile>
+      <id>alto-dev</id>
+      <modules>
+        <module>api</module>
+        <module>impl</module>
+        <module>features</module>
+        <module>artifacts</module>
+      </modules>
+    </profile>
+
+    <profile>
+      <id>alto-test</id>
+      <modules>
+        <module>api</module>
+        <module>impl</module>
+        <module>features</module>
+        <module>artifacts</module>
+        <module>karaf</module>
+        <module>it</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 12fac3e6e2c19e3c533cd2af525ba86bb013f6f2..f28f1ae8100fda2b1abb138cd036d8cbf227a18c 100644 (file)
@@ -25,6 +25,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <modules>
     <module>model-base</module>
     <module>model-networkmap</module>
+    <module>model-endpointcost</module>
   </modules>
   <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
   <build>