Several modifications: 82/18182/1
authorGao Kai <gaok12@mails.tsinghua.edu.cn>
Mon, 13 Apr 2015 09:13:42 +0000 (17:13 +0800)
committerGao Kai <gaok12@mails.tsinghua.edu.cn>
Mon, 13 Apr 2015 09:21:43 +0000 (17:21 +0800)
- Provide a wrapper to help resolve name conflicts
- Decouple the northbound and the MD-SAL

Next target:

- Provide convertors between RFC7285 types and MD-SAL types
- Test northbound with FakeAltoService
- Implement getXXX() for the real AltoServiceProvider for static data
  loaded from CLI

NOTICE:

The change made in commit ff3c92bc85ef7e8ea199928f51ff2a1b486c0cc0 is
temporarily ignored because it slows down the local building process.
MUST apply the change again before the final release.

Change-Id: Iff860e409d1247fd71091e8574771a0e801c9353
Signed-off-by: Gao Kai <gaok12@mails.tsinghua.edu.cn>
46 files changed:
.gitignore
alto-artifacts/pom.xml [deleted file]
alto-commons/pom.xml
alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/Model2RFCConvertor.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/RFC2ModelConvertor.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/mapper/AltoYangMapper.java [deleted file]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/JSONMapper.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/MediaType.java [moved from alto-commons/src/main/java/org/opendaylight/alto/commons/types/alto/model/rev150404/MediaType.java with 100% similarity]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelType.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/AltoNetworkMap.java [deleted file]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/CostType.java
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/Endpoint.java
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/FormatValidator.java
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/JSONMapper.java [moved from alto-commons/src/main/java/org/opendaylight/alto/commons/types/mapper/JSONMapper.java with 65% similarity]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/NetworkMap.java [new file with mode: 0644]
alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285Type.java [new file with mode: 0644]
alto-karaf/pom.xml [deleted file]
alto-model/pom.xml
alto-northbound/pom.xml
alto-northbound/src/main/java/org/opendaylight/alto/northbound/AltoNorthbound.java
alto-northbound/src/main/java/org/opendaylight/alto/northbound/exception/AltoBadFormatException.java [new file with mode: 0644]
alto-northbound/src/main/java/org/opendaylight/alto/northbound/exception/AltoBasicException.java [new file with mode: 0644]
alto-northbound/src/main/java/org/opendaylight/alto/northbound/exception/AltoNorthboundExceptionHandler.java [new file with mode: 0644]
alto-provider/pom.xml
alto-provider/src/main/java/org/opendaylight/alto/provider/AltoProvider.java
alto-provider/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/controller/config/alto/provider/impl/rev141119/modules/module/state/AltoProviderImpl.java
alto-provider/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/controller/config/alto/provider/impl/rev141119/modules/module/state/AltoProviderImplBuilder.java
alto-provider/src/main/yang/alto-provider-impl.yang
alto-services/api/pom.xml [new file with mode: 0644]
alto-services/api/rfc7285/pom.xml [moved from alto-services/pom.xml with 69% similarity]
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/AltoService.java [new file with mode: 0644]
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/CostMapService.java [new file with mode: 0644]
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/EndpointCostService.java [new file with mode: 0644]
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/EndpointPropertyService.java [new file with mode: 0644]
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/IRDService.java [new file with mode: 0644]
alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/NetworkMapService.java [new file with mode: 0644]
alto-services/ext/fake/pom.xml [new file with mode: 0644]
alto-services/ext/fake/src/main/java/org/opendaylight/alto/services/ext/fake/FakeAltoService.java [new file with mode: 0644]
alto-services/ext/fs-map/pom.xml [new file with mode: 0644]
alto-services/ext/fs-map/src/main/java/org/opendaylight/alto/services/ext/fsmap/FileSystemNetworkMapGenerator.java [new file with mode: 0644]
alto-services/ext/pom.xml [new file with mode: 0644]
alto-services/provider/pom.xml [new file with mode: 0644]
alto-services/src/main/java/org/opendaylight/alto/services/AltoService.java [deleted file]
features/pom.xml
features/src/main/resources/features.xml
pom.xml

index 24c86eddd6c375ec1f0456017f65cfb27c0ca46e..de24afe051f2c9a5b9353aa5a69ccbc5854addea 100644 (file)
@@ -29,3 +29,4 @@ maven-eclipse.xml
 .metadata
 *.swp
 **/*.swp
+**/*.checkstyle
diff --git a/alto-artifacts/pom.xml b/alto-artifacts/pom.xml
deleted file mode 100644 (file)
index dfc59d1..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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
--->
-
-<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>
-
-  <parent>
-    <groupId>org.opendaylight.alto</groupId>
-    <artifactId>alto-parent</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
-    <relativePath>../</relativePath>
-  </parent>
-
-  <groupId>org.opendaylight.alto</groupId>
-  <artifactId>alto-artifacts</artifactId>
-  <packaging>pom</packaging>
-
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>${project.groupId}</groupId>
-        <artifactId>alto-model</artifactId>
-        <version>${project.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>${project.groupId}</groupId>
-        <artifactId>alto-provider</artifactId>
-        <version>${project.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>${project.groupId}</groupId>
-        <artifactId>alto-features</artifactId>
-        <version>${project.version}</version>
-        <classifier>features</classifier>
-        <type>xml</type>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-</project>
index af864c480ee7885fd8812cbd50eb39c83c24fad7..1621940e6ed0442cfaf47287f7ee4fbc1ab76e34 100644 (file)
     <relativePath>..</relativePath>
   </parent>
 
-  <properties>
-    <checkstyle.skip>true</checkstyle.skip>
-  </properties>
-
   <groupId>org.opendaylight.alto</groupId>
   <artifactId>alto-commons</artifactId>
   <packaging>bundle</packaging>
@@ -24,8 +20,6 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-checkstyle-plugin</artifactId>
-        <version>${checkstyle.version}</version>
-
         <executions>
           <execution>
             <phase>process-sources</phase>
@@ -56,7 +50,6 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
-        <version>${bundle.plugin.version}</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>
@@ -78,7 +71,6 @@
   </build>
 
   <dependencies>
-
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>alto-model</artifactId>
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-annotations</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
+      </dependency>
 
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-databind</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
+      </dependency>
 
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-core</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
+      </dependency>
   </dependencies>
 </project>
 
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/Model2RFCConvertor.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/Model2RFCConvertor.java
new file mode 100644 (file)
index 0000000..ecf7d66
--- /dev/null
@@ -0,0 +1,30 @@
+package org.opendaylight.alto.commons.types.convertor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupKey;
+
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Type;
+import org.opendaylight.alto.commons.types.model150404.ModelType;
+
+public class Model2RFCConvertor {
+
+    public static final String IPV4 = "ipv4";
+    public static final String IPV6 = "ipv6";
+
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/RFC2ModelConvertor.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/convertor/RFC2ModelConvertor.java
new file mode 100644 (file)
index 0000000..b4f17db
--- /dev/null
@@ -0,0 +1,86 @@
+package org.opendaylight.alto.commons.types.convertor;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Arrays;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupKey;
+
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Type;
+import org.opendaylight.alto.commons.types.model150404.ModelType;
+
+public class RFC2ModelConvertor {
+
+    public static final String IPV4 = "ipv4";
+    public static final String IPV6 = "ipv6";
+
+    public ModelType.NetworkMap convert(RFC7285Type.NetworkMap nmap) {
+        ResourceId rid = new ResourceId(nmap.meta.vtag.rid);
+        TagString tag = new TagString(nmap.meta.vtag.tag);
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map> mapData
+                = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map>(convert(nmap.map));
+        ModelType.NetworkMap result = (ModelType.NetworkMap)(new NetworkMapBuilder()
+                                        .setResourceId(rid)
+                                        .setTag(tag)
+                                        .setMap(mapData).build());
+        return result;
+    }
+
+    public List<ModelType.NetworkMapData> convert(Map<String, RFC7285Type.Endpoint.AddressGroup> mapData) {
+        List<ModelType.NetworkMapData> result = new ArrayList<ModelType.NetworkMapData>();
+        for (Map.Entry<String, RFC7285Type.Endpoint.AddressGroup> entry: mapData.entrySet()) {
+            String pid = entry.getKey();
+            RFC7285Type.Endpoint.AddressGroup addresses = entry.getValue();
+
+            result.add(convert(pid, addresses));
+        }
+        return result;
+    }
+
+    public ModelType.NetworkMapData convert(String pid, RFC7285Type.Endpoint.AddressGroup data) {
+        PidName _pid = new PidName(pid);
+        return (ModelType.NetworkMapData)new MapBuilder()
+                    .setPid(_pid)
+                    .setKey(new MapKey(_pid))
+                    .setEndpointAddressGroup(convert(data))
+                    .build();
+    }
+
+    public List<EndpointAddressGroup> convert(RFC7285Type.Endpoint.AddressGroup addressGroup) {
+        EndpointAddressGroup result[] = {
+            buildAddressGroup(EndpointAddressType.Enumeration.Ipv4, str2IpPrefix(addressGroup.ipv4)),
+            buildAddressGroup(EndpointAddressType.Enumeration.Ipv6, str2IpPrefix(addressGroup.ipv6)),
+        };
+
+        return Arrays.asList(result); 
+    }
+
+    private EndpointAddressGroup buildAddressGroup(EndpointAddressType.Enumeration type, List<IpPrefix> prefixes) {
+        EndpointAddressType _type = new EndpointAddressType(type);
+        return new EndpointAddressGroupBuilder()
+                    .setAddressType(_type)
+                    .setEndpointPrefix(prefixes).build();
+    }
+
+    private List<IpPrefix> str2IpPrefix(List<String> ipList) {
+        List<IpPrefix> prefixList = new ArrayList<IpPrefix>();
+        for (String ip : ipList) {
+            prefixList.add(IpPrefixBuilder.getDefaultInstance(ip));
+        }
+        return prefixList;
+    }
+
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/mapper/AltoYangMapper.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/mapper/AltoYangMapper.java
deleted file mode 100644 (file)
index 12c8a2c..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.opendaylight.alto.commons.types.mapper;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.alto.commons.types.rfc7285.AltoNetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupKey;
-
-public class AltoYangMapper {
-  public static final String IPV4 = "ipv4";
-  public static final String IPV6 = "ipv6";
-  
-  public AltoYangMapper() {};
-  
-  public NetworkMap asNetworkMap(AltoNetworkMap base) {
-    ResourceId rid = new ResourceId(base.meta.vtag.rid);
-    
-    NetworkMapBuilder networkMapBuilder =  new NetworkMapBuilder();
-    networkMapBuilder.setTag(new TagString(base.meta.vtag.tag));
-    networkMapBuilder.setResourceId(rid);
-    networkMapBuilder.setKey(new NetworkMapKey(rid));
-    networkMapBuilder.setMap(asNetworkMapDataList(base.map));
-    
-    return networkMapBuilder.build();
-  }
-
-  public List<Map> asNetworkMapDataList(java.util.Map<String, Endpoint.AddressGroup> mapData) {
-    List<Map> resultMapData = new ArrayList<Map>();
-    for (String key : mapData.keySet()) {
-      resultMapData.add(asNetworkMapData(key, mapData.get(key)));
-    }
-    return resultMapData;
-  }
-  
-  public Map asNetworkMapData(String key, Endpoint.AddressGroup data) {
-    PidName pid = new PidName(key);
-    return new MapBuilder()
-        .setPid(pid)
-        .setKey(new MapKey(pid))
-        .setEndpointAddressGroup(asEndpointAddressGroupList(data))
-        .build();
-  }
-
-  public List<EndpointAddressGroup> asEndpointAddressGroupList(Endpoint.AddressGroup addressGroup) {
-    List<EndpointAddressGroup> endpointAddressGroup = new ArrayList<EndpointAddressGroup>();
-    java.util.Map<String, Object> addressGroupMap = addressGroup.any();
-    for (String key : addressGroupMap.keySet()) {
-      endpointAddressGroup.add(constructEndpointAddressGroupElement(key, addressGroupMap));
-    }
-    return endpointAddressGroup; 
-  }
-
-  @SuppressWarnings("unchecked")
-  private EndpointAddressGroup constructEndpointAddressGroupElement(String key, java.util.Map<String, Object> addressGroupMap){  
-    EndpointAddressGroupBuilder addressGroupBuilder = new EndpointAddressGroupBuilder();
-    EndpointAddressType type = null;
-    if (IPV4.equals(key)) {
-      type = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4);
-    } else if (IPV6.equals(key)) {
-      type = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv6);
-    }
-    
-    addressGroupBuilder.setAddressType(type);
-    addressGroupBuilder.setKey(new EndpointAddressGroupKey(type));
-    addressGroupBuilder.setEndpointPrefix(constructIpPrefixList((List<String>)addressGroupMap.get(key)));
-    return addressGroupBuilder.build();
-  }
-
-  private List<IpPrefix> constructIpPrefixList(List<String> ipList) {
-    List<IpPrefix> ipPrefixList = new ArrayList<IpPrefix>();
-    for (String ip : ipList) {
-      ipPrefixList.add(IpPrefixBuilder.getDefaultInstance(ip));
-    }
-    return ipPrefixList;
-  }
-}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/JSONMapper.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/JSONMapper.java
new file mode 100644 (file)
index 0000000..5ef69a0
--- /dev/null
@@ -0,0 +1,33 @@
+package org.opendaylight.alto.commons.types.model150404;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.alto.commons.types.rfc7285.RFC7285Type;
+import org.opendaylight.alto.commons.types.convertor.RFC2ModelConvertor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupKey;
+
+public class JSONMapper {
+
+    private RFC7285Type.JSONMapper rfc7285Mapper = new RFC7285Type.JSONMapper();
+    private RFC2ModelConvertor convertor = new RFC2ModelConvertor();
+
+    public NetworkMap asNetworkMap(String rfc7285json) throws Exception {
+        return (NetworkMap)convertor.convert((RFC7285Type.NetworkMap)rfc7285Mapper.asNetworkMap(rfc7285json));
+    }
+
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelType.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/model150404/ModelType.java
new file mode 100644 (file)
index 0000000..ebab7e8
--- /dev/null
@@ -0,0 +1,14 @@
+package org.opendaylight.alto.commons.types.model150404;
+
+public class ModelType {
+
+    public static interface NetworkMap
+                       extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap {}
+
+    public static interface NetworkMapData
+            extends org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map {
+    }
+
+    public static class JSONMapper
+            extends org.opendaylight.alto.commons.types.model150404.JSONMapper {}
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/AltoNetworkMap.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/AltoNetworkMap.java
deleted file mode 100644 (file)
index 2b4fc56..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.opendaylight.alto.commons.types.rfc7285;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.MapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.PidName;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.TagString;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Network Map: defined in RFC 7285 section 11.2.1
- * */
-public class AltoNetworkMap {
-
-    public AltoNetworkMap() {}
-
-    public AltoNetworkMap(NetworkMap base) {
-      this.meta = new AltoNetworkMap.Meta(
-          new VersionTag(base.getResourceId().getValue(), base.getTag().getValue()));
-      
-      this.map = new LinkedHashMap<String, Endpoint.AddressGroup>();
-      List<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map> baseMaps = base.getMap();
-      for (org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map map : baseMaps) {
-        String key = map.getKey().getPid().getValue();
-        this.map.put(key, new Endpoint.AddressGroup(map.getEndpointAddressGroup()));
-      }
-    }
-
-    public static class Meta extends Extensible {
-        public Meta() {}
-        
-        public Meta(VersionTag vtag) {
-          this.vtag = vtag;
-        }
-
-        @JsonProperty("vtag")
-        public VersionTag vtag;
-
-    }
-
-    /**
-     * used for filtered-network-map, RFC7285 secion 11.3.1
-     * */
-    public static class Filter {
-
-        @JsonProperty("pids")
-        public List<String> pids;
-
-    }
-
-    @JsonProperty("meta")
-    public Meta meta;
-
-    @JsonProperty("network-map")
-    public Map<String, Endpoint.AddressGroup> map
-                    = new LinkedHashMap<String, Endpoint.AddressGroup>();
-    
-    public NetworkMap asYangNetworkMap() {
-      ResourceId rid = new ResourceId(this.meta.vtag.rid);
-      return new NetworkMapBuilder()
-          .setTag(new TagString(this.meta.vtag.tag))
-          .setResourceId(rid)
-          .setKey(new NetworkMapKey(rid))
-          .setMap(asNetworkMapDataList(this.map))
-          .build();
-    }
-    
-    private List<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map> asNetworkMapDataList(
-        java.util.Map<String, Endpoint.AddressGroup> mapData) {
-      List<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map> resultMapData = 
-          new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map>();
-      for (String key : mapData.keySet()) {
-        resultMapData.add(asNetworkMapData(key, mapData.get(key)));
-      }
-      return resultMapData;
-    }
-    
-    private org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.network.map.Map asNetworkMapData(
-        String key, Endpoint.AddressGroup data) {
-      PidName pid = new PidName(key);
-      return new MapBuilder()
-          .setPid(pid)
-          .setKey(new MapKey(pid))
-          .setEndpointAddressGroup(data.asYangEndpointAddressGroupList())
-          .build();
-    }
-
-}
index a0d38a37279249c673916fa3c88f341b090584d4..0ef11c6dd55dbe1b0785657c1eff04d9ac780ad6 100644 (file)
@@ -5,15 +5,29 @@ import java.util.Arrays;
 
 public class CostType {
 
-    @JsonProperty("cost-metric")
-    public String metric;
-
     @JsonProperty("cost-mode")
     public String mode;
 
+    @JsonProperty("cost-metric")
+    public String metric;
+
     @JsonProperty("description")
     public String description;
 
+    public CostType() {
+    }
+
+    public CostType(String mode, String metric) {
+        this.mode = mode;
+        this.metric = metric;
+    }
+
+    public CostType(String mode, String metric, String description) {
+        this.mode = mode;
+        this.metric = metric;
+        this.description = description;
+    }
+
     @Override
     public int hashCode() {
         String[] members = { metric, mode };
index 3a99912832dcd2fa0eeea03241b42f0a55432475..e31e49ce6e2ae8bba3d76883b5d3a4241ba23c8c 100644 (file)
 package org.opendaylight.alto.commons.types.rfc7285;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.LinkedHashMap;
 
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.EndpointAddressType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroup;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.endpoint.address.group.EndpointAddressGroupKey;
-
 public class Endpoint {
   
-  
-  public static class AddressGroup extends Extensible {
-
-    @JsonIgnore
-    public static final String IPV4_LABEL = "ipv4";
-    
-    @JsonIgnore
-    public static final String IPV6_LABEL = "ipv6";
-    
-    @JsonProperty(IPV4_LABEL)
-    public List<String> ipv4 = new ArrayList<String>();
-
-    @JsonProperty(IPV6_LABEL)
-    public List<String> ipv6 = new ArrayList<String>();
-
-    public AddressGroup() {}
-
-    public AddressGroup(List<EndpointAddressGroup> base) {
-      for (EndpointAddressGroup group : base) {
-        switch (group.getAddressType().getEnumeration()) {
-        case Ipv4:
-          this.ipv4 = asStringIpPrefixList(EndpointAddressType.Enumeration.Ipv4, group.getEndpointPrefix());
-          break;
-        case Ipv6:
-          this.ipv6 = asStringIpPrefixList(EndpointAddressType.Enumeration.Ipv6, group.getEndpointPrefix());
-          break;
-        default:
-          break;
-        }
-      }
-    }
+    public static class AddressGroup extends Extensible {
 
-    private List<String> asStringIpPrefixList(EndpointAddressType.Enumeration type, List<IpPrefix> base) {
-      List<String> addressPrefixes = new ArrayList<String>();
-      for (IpPrefix prefix : base) {
-        switch (type) {
-        case Ipv4:
-          addressPrefixes.add(prefix.getIpv4Prefix().getValue());
-          break;
-        case Ipv6:
-          addressPrefixes.add(prefix.getIpv6Prefix().getValue());
-          break;
-        default:
-          break;
-        }
-      }
-      return addressPrefixes;
-    }
-    
-    public List<EndpointAddressGroup> asYangEndpointAddressGroupList() {
-      List<EndpointAddressGroup> endpointAddressGroup = new ArrayList<EndpointAddressGroup>();
-      if (this.ipv4.size() > 0) {
-        endpointAddressGroup.add(asYangEndpointAddressGroup(IPV4_LABEL, this.ipv4));
-      }
-      if (this.ipv6.size() > 0) {
-        endpointAddressGroup.add(asYangEndpointAddressGroup(IPV6_LABEL, this.ipv6));
-      }
-      return endpointAddressGroup; 
-    }
+        @JsonIgnore
+        public static final String IPV4_LABEL = "ipv4";
 
-    private EndpointAddressGroup asYangEndpointAddressGroup(String key, List<String> ipList){  
-      EndpointAddressType type = null;
-      if (IPV4_LABEL.equals(key)) {
-        type = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv4);
-      } else if (IPV6_LABEL.equals(key)) {
-        type = new EndpointAddressType(EndpointAddressType.Enumeration.Ipv6);
-      }
-      
-      return new EndpointAddressGroupBuilder().setAddressType(type)
-          .setKey(new EndpointAddressGroupKey(type))
-          .setEndpointPrefix(asYangIpPrefix(ipList))
-          .build();
-    }
+        @JsonIgnore
+        public static final String IPV6_LABEL = "ipv6";
+
+        @JsonProperty(IPV4_LABEL)
+        public List<String> ipv4 = new ArrayList<String>();
+
+        @JsonProperty(IPV6_LABEL)
+        public List<String> ipv6 = new ArrayList<String>();
 
-    private List<IpPrefix> asYangIpPrefix(List<String> ipList) {
-      List<IpPrefix> ipPrefixList = new ArrayList<IpPrefix>();
-      for (String ip : ipList) {
-        ipPrefixList.add(IpPrefixBuilder.getDefaultInstance(ip));
-      }
-      return ipPrefixList;
     }
-  }
 
-  public static class PropertyRequest {
+    public static class PropertyRequest {
 
-    @JsonProperty("properties")
-    public List<String> properties;
+        @JsonProperty("properties")
+        public List<String> properties;
 
-    @JsonProperty("endpoints")
-    public List<String> endpoints;
-  }
+        @JsonProperty("endpoints")
+        public List<String> endpoints;
+    }
 
-  public static class PropertyRespond {
+    public static class PropertyResponse {
 
-    public static class Meta extends Extensible {
+        public static class Meta extends Extensible {
 
-      @JsonProperty("dependent-vtags")
-      public List<VersionTag> netmap_tags;
+            @JsonProperty("dependent-vtags")
+            public List<VersionTag> netmap_tags;
 
-    }
+        }
 
-    @JsonProperty("meta")
-    public Meta meta;
+        @JsonProperty("meta")
+        public Meta meta;
 
-    @JsonProperty("endpoint-properties")
-    public Map<String, Map<String, Object>> answer = new LinkedHashMap<String, Map<String, Object>>();
-  }
+        @JsonProperty("endpoint-properties")
+        public Map<String, Map<String, Object>> answer
+                            = new LinkedHashMap<String, Map<String, Object>>();
+    }
 
-  public static class CostRequest {
+    public static class CostRequest {
 
-    @JsonProperty("cost-type")
-    public CostType costType;
+        @JsonProperty("cost-type")
+        public CostType costType;
 
-    @JsonProperty("endpoints")
-    public QueryPairs endpoints;
-  }
+        @JsonProperty("endpoints")
+        public QueryPairs endpoints;
+    }
 
-  public static class CostRespond {
+    public static class CostResponse {
 
-    public static class Meta extends Extensible {
+        public static class Meta extends Extensible {
 
-      @JsonProperty("cost-type")
-      public CostType costType;
+            @JsonProperty("cost-type")
+            public CostType costType;
 
-    }
+        }
 
-    @JsonProperty("meta")
-    public Meta meta;
+        @JsonProperty("meta")
+        public Meta meta;
 
-    @JsonProperty("endpoint-cost-map")
-    public Map<String, Map<String, Object>> answer = new LinkedHashMap<String, Map<String, Object>>();
-  }
+        @JsonProperty("endpoint-cost-map")
+        public Map<String, Map<String, Object>> answer
+                            = new LinkedHashMap<String, Map<String, Object>>();
+    }
 }
index dec92059ca89c0cfbfc436259207881f6be98b09..b3346f73c2e90f251479229af6c805b8bb1a29fd 100644 (file)
@@ -13,6 +13,9 @@ public class FormatValidator {
     private static final String VALID_CHARSET_WITH_DOT = VALID_CHARSET + "\\.";
     private static final Pattern VALID_ID_PATTERN_WITH_DOT
                             = Pattern.compile("^["+VALID_CHARSET_WITH_DOT+"]{1,64}$");
+    private static final String VALID_TAG_CHARSET = "!-~";
+    private static final Pattern VALID_TAG_PATTERN 
+                            = Pattern.compile("^["+VALID_TAG_CHARSET+"]{1,64}$}");
 
     public static boolean validId(String id) {
         return VALID_ID_PATTERN.matcher(id).matches();
@@ -44,6 +47,12 @@ public class FormatValidator {
         return validIdWithDots(id);
     }
 
+    /**
+     * RFC 7285 section 10.3
+     * */
+    public static boolean validTag(String tag) {
+        return VALID_TAG_PATTERN.matcher(tag).matches();
+    }
     /**
      * RFC 7285 section 10.8.1
      * */
similarity index 65%
rename from alto-commons/src/main/java/org/opendaylight/alto/commons/types/mapper/JSONMapper.java
rename to alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/JSONMapper.java
index 246a8923257eb00cc86d3a4a412ca4e5077294a9..fd0c410c1b1677e9052647cca9b38d5fbeaecb78 100644 (file)
@@ -1,12 +1,4 @@
-package org.opendaylight.alto.commons.types.mapper;
-
-import org.opendaylight.alto.commons.types.rfc7285.AltoNetworkMap;
-import org.opendaylight.alto.commons.types.rfc7285.CostMap;
-import org.opendaylight.alto.commons.types.rfc7285.CostType;
-import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
-import org.opendaylight.alto.commons.types.rfc7285.Extensible;
-import org.opendaylight.alto.commons.types.rfc7285.IRD;
-import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+package org.opendaylight.alto.commons.types.rfc7285;
 
 import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -26,16 +18,16 @@ public class JSONMapper {
         return mapper.readValue(json, Endpoint.PropertyRequest.class);
     }
 
-    public Endpoint.PropertyRespond asPropertyRespond(String json) throws Exception {
-        return mapper.readValue(json, Endpoint.PropertyRespond.class);
+    public Endpoint.PropertyResponse asPropertyResponse(String json) throws Exception {
+        return mapper.readValue(json, Endpoint.PropertyResponse.class);
     }
 
     public Endpoint.CostRequest asCostRequest(String json) throws Exception {
         return mapper.readValue(json, Endpoint.CostRequest.class);
     }
 
-    public Endpoint.CostRespond asCostRespond(String json) throws Exception {
-        return mapper.readValue(json, Endpoint.CostRespond.class);
+    public Endpoint.CostResponse asCostResponse(String json) throws Exception {
+        return mapper.readValue(json, Endpoint.CostResponse.class);
     }
 
     public CostMap asCostMap(String json) throws Exception {
@@ -58,8 +50,16 @@ public class JSONMapper {
         return mapper.readValue(json, IRD.class);
     }
 
-    public AltoNetworkMap asNetworkMap(String json) throws Exception {
-        return mapper.readValue(json, AltoNetworkMap.class);
+    public NetworkMap asNetworkMap(String json) throws Exception {
+        return mapper.readValue(json, NetworkMap.class);
+    }
+
+    public NetworkMap.Filter asNetworkMapFilter(String json) throws Exception {
+        return mapper.readValue(json, NetworkMap.Filter.class);
+    }
+
+    public CostMap.Filter asCostMapFilter(String json) throws Exception {
+        return mapper.readValue(json, CostMap.Filter.class); 
     }
 
     public VersionTag asVersionTag(String json) throws Exception {
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/NetworkMap.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/NetworkMap.java
new file mode 100644 (file)
index 0000000..c9e3d98
--- /dev/null
@@ -0,0 +1,37 @@
+package org.opendaylight.alto.commons.types.rfc7285;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Network Map: defined in RFC 7285 section 11.2.1
+ * */
+public class NetworkMap {
+
+    public static class Meta extends Extensible {
+
+        @JsonProperty("vtag")
+        public VersionTag vtag;
+
+    }
+
+    /**
+     * used for filtered-network-map, RFC7285 secion 11.3.1
+     * */
+    public static class Filter {
+
+        @JsonProperty("pids")
+        public List<String> pids;
+
+    }
+
+    @JsonProperty("meta")
+    public Meta meta;
+
+    @JsonProperty("network-map")
+    public Map<String, Endpoint.AddressGroup> map
+                    = new LinkedHashMap<String, Endpoint.AddressGroup>();
+}
diff --git a/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285Type.java b/alto-commons/src/main/java/org/opendaylight/alto/commons/types/rfc7285/RFC7285Type.java
new file mode 100644 (file)
index 0000000..21a555d
--- /dev/null
@@ -0,0 +1,28 @@
+package org.opendaylight.alto.commons.types.rfc7285;
+
+public class RFC7285Type {
+
+    public static class NetworkMap
+            extends org.opendaylight.alto.commons.types.rfc7285.NetworkMap {}
+
+    public static class CostMap
+            extends org.opendaylight.alto.commons.types.rfc7285.CostMap {}
+
+    public static class CostType
+                       extends org.opendaylight.alto.commons.types.rfc7285.CostType {}
+
+    public static class Endpoint
+                       extends org.opendaylight.alto.commons.types.rfc7285.Endpoint {}
+
+    public static class IRD
+                       extends org.opendaylight.alto.commons.types.rfc7285.IRD {}
+
+    public static class MediaType
+                       extends org.opendaylight.alto.commons.types.rfc7285.MediaType {}
+
+    public static class JSONMapper
+                       extends org.opendaylight.alto.commons.types.rfc7285.JSONMapper {}
+
+    public static class VersionTag
+            extends org.opendaylight.alto.commons.types.rfc7285.VersionTag {}
+}
diff --git a/alto-karaf/pom.xml b/alto-karaf/pom.xml
deleted file mode 100644 (file)
index 92eb9f5..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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 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.5.0-SNAPSHOT</version>
-    <relativePath/>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.opendaylight.alto</groupId>
-  <artifactId>alto-karaf</artifactId>
-  <version>1.0.0-SNAPSHOT</version>
-  <name>${project.artifactId}</name>
-  <prerequisites>
-    <maven>3.1.1</maven>
-  </prerequisites>
-  <properties>
-    <karaf.localFeature>odl-alto-provider-ui</karaf.localFeature>
-  </properties>
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>${project.groupId}</groupId>
-        <artifactId>alto-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-features</artifactId>
-      <classifier>features</classifier>
-      <type>xml</type>
-      <scope>runtime</scope>
-    </dependency>
-  </dependencies>
-</project>
index 39306981eb235ca5fe722d24f8ca40a7234b84cf..097d2cad0d003f4eeb42ffac3171f52fbbf7a49d 100644 (file)
 <?xml version="1.0" encoding="UTF-8"?>
 <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>
-    <parent>
-        <groupId>org.opendaylight.alto</groupId>
-        <artifactId>alto-parent</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
-        <relativePath>../</relativePath>
-    </parent>
+  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>
+  <parent>
+    <groupId>org.opendaylight.alto</groupId>
+    <artifactId>alto-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>../</relativePath>
+  </parent>
 
-    <artifactId>alto-model</artifactId>
-    <packaging>bundle</packaging>
+  <artifactId>alto-model</artifactId>
+  <packaging>bundle</packaging>
 
-    <properties>
-        <jmxGeneratorPath>${project.build.directory}/generated-sources/config</jmxGeneratorPath>
-    </properties>
+  <properties>
+    <jmxGeneratorPath>${project.build.directory}/generated-sources/config</jmxGeneratorPath>
+  </properties>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <version>${checkstyle.version}</version>
-                <executions>
-                    <execution>
-                        <phase>process-sources</phase>
-                        <goals>
-                            <goal>check</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <failsOnError>true</failsOnError>
-                    <configLocation>controller/checkstyle.xml</configLocation>
-                    <consoleOutput>true</consoleOutput>
-                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
-                    <sourceDirectory>${project.basedir}</sourceDirectory>
-                    <includes>**\/*.yang</includes>
-                    <excludes>**\/target\/,**\/bin\/,**\/third-party,**\/yang-gen-sal</excludes>
-                </configuration>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>target/generated-sources/sal</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
 
-                <dependencies>
-                  <dependency>
-                    <groupId>org.opendaylight.controller</groupId>
-                    <artifactId>checkstyle</artifactId>
-                    <version>${controller.checkstyle.version}</version>
-                  </dependency>
-                </dependencies>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>${compiler.version}</version>
-                <inherited>true</inherited>
-                <configuration>
-                    <source>1.7</source>
-                    <target>1.7</target>
-                </configuration>
-            </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <failsOnError>true</failsOnError>
+          <configLocation>controller/checkstyle.xml</configLocation>
+          <consoleOutput>true</consoleOutput>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <sourceDirectory>${project.basedir}</sourceDirectory>
+          <includes>**\/*.yang</includes>
+          <excludes>**\/target\/,**\/bin\/,**\/third-party,**\/yang-gen-sal</excludes>
+        </configuration>
 
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <version>${bundle.plugin.version}</version>
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Export-Package>
-                            org.opendaylight.yang.gen.v1.urn.opendaylight.alto.*;
-                        </Export-Package>
-                        <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
-                    </instructions>
-                </configuration>
-            </plugin>
+        <dependencies>
+          <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>${controller.checkstyle.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
 
-            <plugin>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>generate-sources</goal>
-                        </goals>
-                        <configuration>
-                            <codeGenerators>
-                                <generator>
-                                    <codeGeneratorClass>
-                                        org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-                                    </codeGeneratorClass>
-                                    <outputBaseDir>${project.build.directory}/generated-sources/config</outputBaseDir>
-                                    <additionalConfiguration>
-                                        <namespaceToPackage1>
-                                            urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
-                                        </namespaceToPackage1>
-                                    </additionalConfiguration>
-                                </generator>
-                                <generator>
-                                    <codeGeneratorClass>
-                                        org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
-                                    </codeGeneratorClass>
-                                    <outputBaseDir>${project.build.directory}/generated-sources/sal</outputBaseDir>
-                                </generator>
-                                <generator>
-                                    <codeGeneratorClass>
-                                        org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl
-                                    </codeGeneratorClass>
-                                    <outputBaseDir>${project.build.directory}/site/models</outputBaseDir>
-                                </generator>
-                            </codeGenerators>
-                            <inspectDependencies>true</inspectDependencies>
-                        </configuration>
-                    </execution>
-                </executions>
-                <dependencies>
-                    <dependency>
-                        <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>yang-jmx-generator-plugin</artifactId>
-                        <version>0.3.0-SNAPSHOT</version>
-                    </dependency>
-                    <dependency>
-                        <groupId>org.opendaylight.yangtools</groupId>
-                        <artifactId>maven-sal-api-gen-plugin</artifactId>
-                        <version>${yangtools.version}</version>
-                        <type>jar</type>
-                    </dependency>
-                </dependencies>
-            </plugin>
-        </plugins>
-    </build>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <inherited>true</inherited>
+        <configuration>
+          <source>1.7</source>
+          <target>1.7</target>
+        </configuration>
+      </plugin>
 
-    <dependencies>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>18.0</version>
-        </dependency>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              org.opendaylight.yang.gen.v1.urn.opendaylight.alto.*;
+            </Export-Package>
+            <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+          </instructions>
+        </configuration>
+      </plugin>
 
-        <dependency>
-            <groupId>org.opendaylight.yangtools.model</groupId>
-            <artifactId>ietf-inet-types</artifactId>
-            <version>${ietf.model.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools.model</groupId>
-            <artifactId>ietf-yang-types-20130715</artifactId>
-            <version>${ietf.yang.types.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.ovsdb</groupId>
-            <artifactId>southbound-api</artifactId>
-            <version>${ovsdb.southbound.version}</version>
-        </dependency>
-    </dependencies>
+      <plugin>
+        <groupId>org.opendaylight.yangtools</groupId>
+        <artifactId>yang-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>generate-sources</goal>
+            </goals>
+
+            <configuration>
+              <codeGenerators>
+                <generator>
+                  <codeGeneratorClass>
+                    org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+                  </codeGeneratorClass>
+                  <outputBaseDir>${project.build.directory}/generated-sources/config</outputBaseDir>
+                  <additionalConfiguration>
+                    <namespaceToPackage1>
+                      urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
+                    </namespaceToPackage1>
+                  </additionalConfiguration>
+                </generator>
+                <generator>
+                  <codeGeneratorClass>
+                    org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
+                  </codeGeneratorClass>
+                  <outputBaseDir>${project.build.directory}/generated-sources/sal</outputBaseDir>
+                </generator>
+                <generator>
+                  <codeGeneratorClass>
+                    org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl
+                  </codeGeneratorClass>
+                  <outputBaseDir>${project.build.directory}/site/models</outputBaseDir>
+                </generator>
+              </codeGenerators>
+              <inspectDependencies>true</inspectDependencies>
+            </configuration>
+          </execution>
+        </executions>
+        <dependencies>
+          <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>yang-jmx-generator-plugin</artifactId>
+            <version>0.3.0-SNAPSHOT</version>
+          </dependency>
+          <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>maven-sal-api-gen-plugin</artifactId>
+            <version>${yangtools.version}</version>
+            <type>jar</type>
+          </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-inet-types</artifactId>
+      <version>${ietf.model.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-yang-types-20130715</artifactId>
+      <version>${ietf.yang.types.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.ovsdb</groupId>
+      <artifactId>southbound-api</artifactId>
+      <version>${ovsdb.southbound.version}</version>
+    </dependency>
+  </dependencies>
 </project>
 
index e901510a780d76278740714de6f5f46de101b56c..c5ad42b8c996872b773a0d314b2aad168e792423 100644 (file)
@@ -9,9 +9,7 @@
     <version>1.0.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
-  <groupId>org.opendaylight.alto</groupId>
   <artifactId>alto-northbound</artifactId>
-  <version>1.0.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <build>
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
-        <version>${bundle.plugin.version}</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>
             <Import-Package>
               org.opendaylight.yang.gen.v1.urn.opendaylight.alto.*,
-              org.opendaylight.alto.services,
+              org.opendaylight.alto.services.ext.fake,
+              org.opendaylight.alto.services.api.rfc7285,
               org.opendaylight.alto.commons.*,
               org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
               org.apache.commons.logging,
@@ -67,8 +65,6 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-checkstyle-plugin</artifactId>
-        <version>${checkstyle.version}</version>
-
         <executions>
           <execution>
             <phase>process-sources</phase>
@@ -95,7 +91,6 @@
           </dependency>
         </dependencies>
       </plugin>
-
     </plugins>
   </build>
 
     <dependency>
       <groupId>org.opendaylight.controller.thirdparty</groupId>
       <artifactId>com.sun.jersey.jersey-servlet</artifactId>
-      <version>${jersey.servlet.version}</version>
-    </dependency>
+      </dependency>
 
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
     <dependency>
       <groupId>org.codehaus.enunciate</groupId>
       <artifactId>enunciate-core-annotations</artifactId>
-      <version>${enunciate.version}</version>
-    </dependency>
+      </dependency>
 
     <dependency>
       <groupId>org.opendaylight.controller.thirdparty</groupId>
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-annotations</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
+      </dependency>
 
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-databind</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
+      </dependency>
 
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-core</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
+      </dependency>
 
     <dependency>
       <groupId>${project.groupId}</groupId>
 
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>alto-services</artifactId>
+      <artifactId>service-api-rfc7285</artifactId>
       <version>${project.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>services.ext.fake</artifactId>
+      <version>${project.version}</version>
+    </dependency>
   </dependencies>
 </project>
 
index 77ca10e309b07ae5d47fd1bdaa6382a12b87ec15..1af1236d46920860f1554cb6ba725fd15c4f04d3 100644 (file)
 package org.opendaylight.alto.northbound;
 
 import javax.ws.rs.GET;
+import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
 
-import org.opendaylight.alto.commons.types.mapper.JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.FormatValidator;
 import org.opendaylight.alto.commons.types.rfc7285.MediaType;
-import org.opendaylight.alto.services.AltoService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.IRD;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
+import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.CostType;
+import org.opendaylight.alto.commons.types.rfc7285.IRD;
+import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.CostMap;
+import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
+
+import org.opendaylight.alto.services.api.rfc7285.AltoService;
+
+import org.opendaylight.alto.services.ext.fake.FakeAltoService;
+
+import org.opendaylight.alto.northbound.exception.AltoBasicException;
+import org.opendaylight.alto.northbound.exception.AltoBadFormatException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Path("/")
 public class AltoNorthbound {
-  private AltoService altoService = new AltoService();
-  private JSONMapper mapper = new JSONMapper();
-  
-  @GET
-  @Produces({ MediaType.ALTO_DIRECTORY, MediaType.ALTO_ERROR })
-  public Response retrieveIRD() {
-    try {
-      IRD ird = altoService.getIRD();
-      return Response.ok(ird, MediaType.ALTO_DIRECTORY).build();
-    } catch (Exception e) {
-    }
-    return Response.ok("", MediaType.ALTO_ERROR).build();
-  }
-
-  @Path("/networkmap/{networkmap_id}")
-  @GET
-  @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR })
-  public Response retrieveNetworkMap(
-      @PathParam(value = "networkmap_id") String nmap_id) {
-    NetworkMap networkMap = altoService.getNetworkMap(new ResourceId(nmap_id));
-    try {
-      return Response.ok("", MediaType.ALTO_NETWORKMAP).build();
-    } catch (Exception e) { 
-      return Response.ok("", MediaType.ALTO_ERROR).build();
-    }
-  }
+
+    private static final Logger logger = LoggerFactory.getLogger(AltoNorthbound.class);
+
+    private AltoService altoService = new FakeAltoService();
+    private JSONMapper mapper = new JSONMapper();
+
+    private void checkAltoService() throws Exception {
+        if (altoService == null)
+            throw new AltoBasicException(Status.SERVICE_UNAVAILABLE, null);
+    }
+
+    private void checkResourceId(String rid) throws AltoBadFormatException {
+        if (!FormatValidator.validResourceId(rid))
+            throw new AltoBadFormatException("resource-id", rid);
+    }
+
+    private void checkTag(String tag) throws AltoBadFormatException {
+        if (!FormatValidator.validTag(tag))
+            throw new AltoBadFormatException("tag", tag);
+    }
+
+    private Response fail(Response.Status status, Object data) {
+        try {
+            String output = (data == null ? "" : mapper.asJSON(data));
+            return Response.status(status)
+                        .entity(output)
+                        .type(MediaType.ALTO_ERROR).build();
+        } catch (Exception e) {
+            logger.error("Failed to parse object to json: {}", data.toString());
+            return Response.status(status)
+                        .type(MediaType.ALTO_ERROR).build();
+        }
+    }
+
+    private Response success(Object data, String mediaType) {
+        try {
+            String output = mapper.asJSON(data);
+            return Response.ok(output, mediaType).build();
+        } catch (Exception e) {
+            logger.error("Failed to parse object to json: {}", data.toString());
+            return fail(Status.INTERNAL_SERVER_ERROR, null);
+        }
+    }
+
+    @GET
+    @Produces({ MediaType.ALTO_DIRECTORY, MediaType.ALTO_ERROR })
+    public Response retrieveIRD() throws Exception {
+        checkAltoService();
+
+        IRD ird = altoService.getDefaultIRD();
+        if (ird == null)
+            return fail(Status.NOT_FOUND, null);
+        return success(ird, MediaType.ALTO_DIRECTORY);
+    }
+
+    @Path("/ird/{id}")
+    @GET
+    @Produces({ MediaType.ALTO_DIRECTORY, MediaType.ALTO_ERROR })
+    public Response retrieveIRD(
+            @PathParam("id") String id) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+
+        IRD ird = altoService.getIRD(id);
+        if (ird == null)
+            return fail(Status.NOT_FOUND, id);
+        return success(ird, MediaType.ALTO_DIRECTORY);
+    }
+
+    @Path("/networkmap")
+    @GET
+    @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR })
+    public Response retrieveDefaultNetworkMap() throws Exception {
+        checkAltoService();
+        
+        NetworkMap map = altoService.getDefaultNetworkMap();
+        if (map == null)
+            return fail(Status.NOT_FOUND, null);
+        return success(map, MediaType.ALTO_NETWORKMAP);
+    }
+
+    @Path("/networkmap/{id}")
+    @GET
+    @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR })
+    public Response retrieveNetworkMap(
+            @PathParam("id") String id) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+
+        NetworkMap map = altoService.getNetworkMap(id);
+        if (map == null)
+            return fail(Status.NOT_FOUND, id);
+        return success(map, MediaType.ALTO_NETWORKMAP);
+    }
+
+    @Path("/networkmap/{id}/{tag}")
+    @GET
+    @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR })
+    public Response retrieveNetworkMap(
+            @PathParam("id") String id,
+            @PathParam("tag") String tag) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+        checkTag(tag);
+
+        VersionTag vtag = new VersionTag(id, tag);
+        NetworkMap map = altoService.getNetworkMap(vtag);
+        if (map == null)
+            return fail(Status.NOT_FOUND, vtag);
+        return success(map, MediaType.ALTO_NETWORKMAP);
+    }
+                                     
+    @Path("/costmap/{id}")
+    @GET
+    @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
+    public Response retrieveCostMap(@PathParam("id") String id) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+
+        CostMap map = altoService.getCostMap(id);
+        if (map == null)
+            return fail(Status.NOT_FOUND, id);
+        return success(map, MediaType.ALTO_COSTMAP);
+    }
+
+    @Path("/costmap/{id}/{tag}")
+    @GET
+    @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
+    public Response retrieveCostMap(
+            @PathParam("id") String id,
+            @PathParam("tag") String tag) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+        checkTag(tag);
+
+        VersionTag vtag = new VersionTag(id, tag);
+        CostMap map = altoService.getCostMap(vtag);
+        if (map == null)
+            return fail(Status.NOT_FOUND, vtag);
+        return success(map, MediaType.ALTO_COSTMAP);
+    }
+
+    @Path("/costmap/{id}/{mode}/{metric}")
+    @GET
+    @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
+    public Response retrieveCostMap(
+            @PathParam("id") String id,
+            @PathParam("mode") String mode,
+            @PathParam("metric") String metric) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+
+        CostType costType = new CostType(mode, metric);
+        if (!altoService.supportCostType(id, costType))
+            return fail(Status.NOT_FOUND, costType);
+        CostMap map = altoService.getCostMap(id, costType);
+        if (map == null)
+            return fail(Status.NOT_FOUND, id);
+        return success(map, MediaType.ALTO_COSTMAP);
+    }
+
+    @Path("/costmap/{id}/{tag}/{mode}/{metric}")
+    @GET
+    @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
+    public Response retrieveCostMap(
+            @PathParam("id") String id,
+            @PathParam("tag") String tag,
+            @PathParam("mode") String mode,
+            @PathParam("metric") String metric) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+        checkTag(tag);
+
+        VersionTag vtag = new VersionTag(id, tag);
+        CostType costType = new CostType(mode, metric);
+        if (!altoService.supportCostType(vtag, costType))
+            return fail(Status.NOT_FOUND, costType);
+        CostMap map = altoService.getCostMap(vtag, costType);
+        if (map == null)
+            return fail(Status.NOT_FOUND, vtag);
+        return success(map, MediaType.ALTO_COSTMAP);
+    }
+
+    @Path("/filtered/networkmap/{id}")
+    @POST
+    @Consumes({ MediaType.ALTO_NETWORKMAP_FILTER})
+    @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR})
+    public Response retrieveFilteredNetworkMap(
+            @PathParam("id") String id, String filterJSON) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+
+        NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
+
+        if (!altoService.validateNetworkMapFilter(id, filter))
+            return fail(Status.BAD_REQUEST, filter);
+        NetworkMap map = altoService.getNetworkMap(id, filter);
+        if (map == null)
+            return fail(Status.NOT_FOUND, id);
+        return success(map, MediaType.ALTO_NETWORKMAP);
+    }
+    @Path("/filtered/networkmap/{id}/{tag}")
+    @POST
+    @Consumes({ MediaType.ALTO_NETWORKMAP_FILTER})
+    @Produces({ MediaType.ALTO_NETWORKMAP, MediaType.ALTO_ERROR})
+    public Response retrieveFilteredNetworkMap(
+            @PathParam("id") String id,
+            @PathParam("tag") String tag,
+            String filterJSON) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+        checkTag(tag);
+
+        VersionTag vtag = new VersionTag(id, tag);
+        NetworkMap.Filter filter = mapper.asNetworkMapFilter(filterJSON);
+        if (!altoService.validateNetworkMapFilter(vtag, filter))
+            return fail(Status.BAD_REQUEST, filter);
+
+        NetworkMap map = altoService.getNetworkMap(vtag, filter);
+        if (map == null)
+            return fail(Status.NOT_FOUND, vtag);
+        return success(map, MediaType.ALTO_NETWORKMAP);
+    }   
+
+    @Path("/filtered/costmap/{id}")
+    @POST
+    @Consumes({ MediaType.ALTO_COSTMAP_FILTER })
+    @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
+    public Response retrieveFilteredCostMap(
+            @PathParam("id") String id, String filterJSON) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+
+        CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
+        if (!altoService.validateCostMapFilter(id, filter))
+            return fail(Status.BAD_REQUEST, filter);
+
+        CostMap map = altoService.getCostMap(id, filter);
+        if (map == null)
+            return fail(Status.NOT_FOUND, id);
+        return success(map, MediaType.ALTO_COSTMAP);
+    }
+
+    @Path("/filtered/costmap/{id}/{tag}")
+    @POST
+    @Consumes({ MediaType.ALTO_COSTMAP_FILTER })
+    @Produces({ MediaType.ALTO_COSTMAP, MediaType.ALTO_ERROR})
+    public Response retrieveFilteredCostMap(
+            @PathParam("id") String id,
+            @PathParam("tag") String tag, String filterJSON) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+        checkTag(tag);
+
+        VersionTag vtag = new VersionTag(id, tag);
+        CostMap.Filter filter = mapper.asCostMapFilter(filterJSON);
+        if (!altoService.validateCostMapFilter(vtag, filter))
+            return fail(Status.BAD_REQUEST, filter);
+
+        CostMap map = altoService.getCostMap(vtag, filter);
+        if (map == null)
+            return fail(Status.NOT_FOUND, vtag);
+        return success(map, MediaType.ALTO_COSTMAP);
+    }
+
+    @Path("/endpointprop/lookup/{id}")
+    @POST
+    @Consumes({ MediaType.ALTO_ENDPOINT_PROPPARAMS })
+    @Produces({ MediaType.ALTO_ENDPOINT_PROP, MediaType.ALTO_ERROR })
+    public Response retrieveEndpointPropMap(
+            @PathParam("id") String id,
+            String params) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+
+        Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
+        Endpoint.PropertyResponse response = altoService.getEndpointProperty(id, request);
+        if (response == null)
+            return fail(Status.NOT_FOUND, request);
+        return success(response, MediaType.ALTO_ENDPOINT_PROP);
+    }
+
+    @Path("/endpointprop/lookup/{id}/{tag}")
+    @POST
+    @Consumes({ MediaType.ALTO_ENDPOINT_PROPPARAMS })
+    @Produces({ MediaType.ALTO_ENDPOINT_PROP, MediaType.ALTO_ERROR })
+    public Response retrieveEndpointPropMap(
+            @PathParam("id") String id,
+            @PathParam("tag") String tag,
+            String params) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+        checkTag(tag);
+
+        VersionTag vtag = new VersionTag(id, tag);
+        Endpoint.PropertyRequest request = mapper.asPropertyRequest(params);
+        Endpoint.PropertyResponse response = altoService.getEndpointProperty(vtag, request);
+        if (response == null)
+            return fail(Status.NOT_FOUND, request);
+        return success(response, MediaType.ALTO_ENDPOINT_PROP);
+    }
+
+    @Path("/endpointcost/lookup/{id}")
+    @POST
+    @Consumes({ MediaType.ALTO_ENDPOINT_COSTPARAMS })
+    @Produces({ MediaType.ALTO_ENDPOINT_COST, MediaType.ALTO_ERROR })
+    public Response retrieveEndpointCostMap(
+            @PathParam("id") String id,
+            String params) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+
+        Endpoint.CostRequest request = mapper.asCostRequest(params);
+        Endpoint.CostResponse response = altoService.getEndpointCost(id, request);
+        if (response == null)
+            return fail(Status.NOT_FOUND, request);
+        return success(response, MediaType.ALTO_ENDPOINT_COST);
+    }
+
+    @Path("/endpointcost/lookup/{id}/{tag}")
+    @POST
+    @Consumes({ MediaType.ALTO_ENDPOINT_COSTPARAMS })
+    @Produces({ MediaType.ALTO_ENDPOINT_COST, MediaType.ALTO_ERROR })
+    public Response retrieveEndpointCostMap(
+            @PathParam("id") String id,
+            @PathParam("tag") String tag,
+            String params) throws Exception {
+        checkAltoService();
+        checkResourceId(id);
+        checkTag(tag);
+
+        VersionTag vtag = new VersionTag(id, tag);
+        Endpoint.CostRequest request = mapper.asCostRequest(params);
+        Endpoint.CostResponse response = altoService.getEndpointCost(vtag, request);
+        if (response == null)
+            return fail(Status.NOT_FOUND, request);
+        return success(response, MediaType.ALTO_ENDPOINT_COST);
+    }
 }
diff --git a/alto-northbound/src/main/java/org/opendaylight/alto/northbound/exception/AltoBadFormatException.java b/alto-northbound/src/main/java/org/opendaylight/alto/northbound/exception/AltoBadFormatException.java
new file mode 100644 (file)
index 0000000..99b9bb4
--- /dev/null
@@ -0,0 +1,12 @@
+package org.opendaylight.alto.northbound.exception;
+
+import javax.ws.rs.core.Response.Status;
+
+public class AltoBadFormatException extends AltoBasicException {
+
+    public static final String TEMPLATE = "Bad %s format: %s";
+
+    public AltoBadFormatException(String field, String value) {
+        super(Status.BAD_REQUEST, String.format(TEMPLATE, field, value));
+    }
+}
diff --git a/alto-northbound/src/main/java/org/opendaylight/alto/northbound/exception/AltoBasicException.java b/alto-northbound/src/main/java/org/opendaylight/alto/northbound/exception/AltoBasicException.java
new file mode 100644 (file)
index 0000000..4a99743
--- /dev/null
@@ -0,0 +1,20 @@
+package org.opendaylight.alto.northbound.exception;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.opendaylight.alto.commons.types.rfc7285.MediaType;
+
+public class AltoBasicException extends WebApplicationException {
+
+    public static final String MEDIA_TYPE = MediaType.ALTO_ERROR;
+
+    public AltoBasicException(int status, Object cause) {
+        super(Response.status(status).entity(cause).type(MEDIA_TYPE).build());
+    }
+
+    public AltoBasicException(Response.Status status, Object cause) {
+        super(Response.status(status).entity(cause).type(MEDIA_TYPE).build());
+    }
+}
diff --git a/alto-northbound/src/main/java/org/opendaylight/alto/northbound/exception/AltoNorthboundExceptionHandler.java b/alto-northbound/src/main/java/org/opendaylight/alto/northbound/exception/AltoNorthboundExceptionHandler.java
new file mode 100644 (file)
index 0000000..3df70b7
--- /dev/null
@@ -0,0 +1,21 @@
+package org.opendaylight.alto.northbound.exception;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import org.opendaylight.alto.commons.types.rfc7285.MediaType;
+
+@Provider
+public class AltoNorthboundExceptionHandler
+                implements ExceptionMapper<Exception> {
+    @Override
+    public Response toResponse(Exception e) {
+        if (e instanceof AltoBasicException)
+            return ((AltoBasicException)e).getResponse();
+        return Response.status(Status.INTERNAL_SERVER_ERROR)
+                        .entity(e.getMessage())
+                        .type(MediaType.ALTO_ERROR).build();
+    }
+}
index 612f0589973bbdc152e44ca88075b2360fb8857a..d473a6e17816fe2c686f1da413a1bfe81d1b78cb 100644 (file)
@@ -4,6 +4,8 @@
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
+  <modelVersion>4.0.0</modelVersion>
+
   <parent>
     <groupId>org.opendaylight.alto</groupId>
     <artifactId>alto-parent</artifactId>
@@ -11,7 +13,6 @@
     <relativePath>../</relativePath>
   </parent>
 
-  <modelVersion>4.0.0</modelVersion>
   <artifactId>alto-provider</artifactId>
   <packaging>bundle</packaging>
 
       <artifactId>config-api</artifactId>
       <version>${config.version}</version>
     </dependency>
+
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-binding-api</artifactId>
       <version>${mdsal.version}</version>
     </dependency>
+
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-binding-config</artifactId>
       <version>${mdsal.version}</version>
     </dependency>
+
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-common-util</artifactId>
       <version>${mdsal.version}</version>
     </dependency>
+
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
-      <version>${osgi.core.version}</version>
     </dependency>
 
     <!-- dependencies to use AbstractDataBrokerTest -->
@@ -59,6 +63,7 @@
       <version>1.2.0-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-binding-broker-impl</artifactId>
       <version>1.2.0-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
+
     <dependency>
         <artifactId>junit</artifactId>
         <groupId>junit</groupId>
-        <version>[4.8.1, 4.11]</version>
         <scope>test</scope>
     </dependency>
-    <!-- used to mock up classes
-     <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-all</artifactId>
-      <scope>test</scope>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-commons</artifactId>
+      <version>${project.version}</version>
     </dependency>
-    -->
 
   </dependencies>
 
     <tag>HEAD</tag>
     <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
   </scm>
-
 </project>
index f71a4a027ac8a41aa1cbd2457a34cbff445ea32b..bf303d0c991839089d070ee0efb7abdbf864efa6 100644 (file)
@@ -28,80 +28,75 @@ import org.slf4j.LoggerFactory;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 
-public class AltoProvider implements AltoServiceService, DataChangeListener,
-  AltoProviderRuntimeMXBean, AutoCloseable {
+public class AltoProvider implements
+            AltoServiceService, DataChangeListener,
+            AltoProviderRuntimeMXBean, AutoCloseable {
 
-  private static final Logger log = LoggerFactory.getLogger(AltoProvider.class);
+    private static final Logger log = LoggerFactory.getLogger(AltoProvider.class);
 
-  public static final InstanceIdentifier<Resources> ALTO_IID = InstanceIdentifier
-      .builder(Resources.class).build();
+    public static final InstanceIdentifier<Resources> ALTO_IID
+                        = InstanceIdentifier.builder(Resources.class).build();
   
-  private DataBroker dataProvider;
-  private final ExecutorService executor;
+    private DataBroker dataProvider;
+    private final ExecutorService executor;
   
-  public AltoProvider() {
-    this.executor = Executors.newFixedThreadPool(1);
-  }
+    public AltoProvider() {
+        this.executor = Executors.newFixedThreadPool(1);
+    }
 
-  public void setDataProvider(final DataBroker salDataProvider) {
-    this.dataProvider = salDataProvider;
-    log.info(this.getClass().getName() + " data provider initiated");
-  }
-  
-  @Override
-  public void onDataChanged(
-      final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-    DataObject dataObject = change.getUpdatedSubtree();
-    if (dataObject instanceof Resources) {
-      Resources altoResources = (Resources) dataObject;
-      log.info("onDataChanged - new ALTO config: {}", altoResources);
+    public void setDataProvider(final DataBroker salDataProvider) {
+        this.dataProvider = salDataProvider;
+        log.info(this.getClass().getName() + " data provider initiated");
+    }
+
+    @Override
+    public void onDataChanged(
+            final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+        DataObject dataObject = change.getUpdatedSubtree();
+        if (dataObject instanceof Resources) {
+            Resources altoResources = (Resources) dataObject;
+            log.info("onDataChanged - new ALTO config: {}", altoResources);
+        }
     }
-  }
 
-  @Override
-  public Future<RpcResult<EndpointCostServiceOutput>> endpointCostService(
-      EndpointCostServiceInput input) {
-    // TODO Auto-generated method stub
-    return null;
-  }
+    @Override
+    public Future<RpcResult<EndpointCostServiceOutput>> endpointCostService(
+            EndpointCostServiceInput input) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-  @Override
-  public Future<RpcResult<FilteredCostMapServiceOutput>> filteredCostMapService(
-      FilteredCostMapServiceInput input) {
-    // TODO Auto-generated method stub
-    return null;
-  }
+    @Override
+    public Future<RpcResult<FilteredCostMapServiceOutput>> filteredCostMapService(
+            FilteredCostMapServiceInput input) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-  @Override
-  public Future<RpcResult<FilteredNetworkMapServiceOutput>> filteredNetworkMapService(
-      final FilteredNetworkMapServiceInput input) {
-    // TODO Auto-generated method stub
-    return null;
-  }
+    @Override
+    public Future<RpcResult<FilteredNetworkMapServiceOutput>> filteredNetworkMapService(
+            final FilteredNetworkMapServiceInput input) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-  @Override
-  public Long getToastsMade() {
-    // TODO Auto-generated method stub
-    return null;
-  }
-  
-  @Override
-  public void close() throws ExecutionException, InterruptedException {
-    executor.shutdown();
-    if (dataProvider != null) {
-      WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
-      tx.delete(LogicalDatastoreType.CONFIGURATION, ALTO_IID);
-      Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
-        @Override
-        public void onSuccess(final Void result) {
-          log.debug("Delete ALTO commit result: " + result);
-        }
+    @Override
+    public void close() throws ExecutionException, InterruptedException {
+        executor.shutdown();
+        if (dataProvider != null) {
+            WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
+            tx.delete(LogicalDatastoreType.CONFIGURATION, ALTO_IID);
+            Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+                @Override
+                public void onSuccess(final Void result) {
+                    log.debug("Delete ALTO commit result: " + result);
+                }
 
-        @Override
-        public void onFailure(final Throwable t) {
-          log.error("Delete of ALTO failed", t);
+            @Override
+            public void onFailure(final Throwable t) {
+                log.error("Delete of ALTO failed", t);
+            }
+            });
         }
-      });
     }
-  }
 }
index bc38848dac9dcf9ebd6bc3a664d99822a520d127..5042c6c9ea887180121712cd0bc47e989be5c7e6 100644 (file)
@@ -10,9 +10,6 @@ import org.opendaylight.yangtools.yang.binding.Augmentable;
  * &lt;br&gt;(Source path: &lt;i&gt;META-INF/yang/alto-provider-impl.yang&lt;/i&gt;):
  * &lt;pre&gt;
  * case alto-provider-impl {
- *     leaf toasts-made {
- *         type uint32;
- *     }
  * }
  * &lt;/pre&gt;
  * The schema path to identify an instance is
@@ -30,7 +27,6 @@ public interface AltoProviderImpl
 
     public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.cachedReference(org.opendaylight.yangtools.yang.common.QName.create("urn:opendaylight:params:xml:ns:yang:controller:config:alto-provider:impl","2014-11-19","alto-provider-impl"));
 
-    java.lang.Long getToastsMade();
 
 }
 
index 0755ca858a44830d5f560cab7241f36530387b97..f351eaa69dc646ccd73df473035a7b13499c9d05 100644 (file)
@@ -1,13 +1,9 @@
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state;
-import com.google.common.collect.Range;
 import java.util.Collections;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import java.util.HashMap;
 import org.opendaylight.yangtools.concepts.Builder;
-import com.google.common.collect.ImmutableList;
-import java.math.BigInteger;
-import java.util.List;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
 
@@ -19,8 +15,6 @@ import org.opendaylight.yangtools.yang.binding.Augmentation;
  */
 public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl> {
 
-    private java.lang.Long _toastsMade;
-    private static List<Range<BigInteger>> _toastsMade_range;
 
     Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> augmentation = new HashMap<>();
 
@@ -28,7 +22,6 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
     }
 
     public AltoProviderImplBuilder(AltoProviderImpl base) {
-        this._toastsMade = base.getToastsMade();
         if (base instanceof AltoProviderImplImpl) {
             AltoProviderImplImpl _impl = (AltoProviderImplImpl) base;
             this.augmentation = new HashMap<>(_impl.augmentation);
@@ -36,9 +29,6 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
     }
 
 
-    public java.lang.Long getToastsMade() {
-        return _toastsMade;
-    }
     
     @SuppressWarnings("unchecked")
     public <E extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> E getAugmentation(java.lang.Class<E> augmentationType) {
@@ -48,34 +38,6 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
         return (E) augmentation.get(augmentationType);
     }
 
-    public AltoProviderImplBuilder setToastsMade(java.lang.Long value) {
-        if (value != null) {
-            BigInteger _constraint = BigInteger.valueOf(value);
-            boolean isValidRange = false;
-            for (Range<BigInteger> r : _toastsMade_range()) {
-                if (r.contains(_constraint)) {
-                    isValidRange = true;
-                }
-            }
-            if (!isValidRange) {
-                throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _toastsMade_range));
-            }
-        }
-        this._toastsMade = value;
-        return this;
-    }
-    public static List<Range<BigInteger>> _toastsMade_range() {
-        if (_toastsMade_range == null) {
-            synchronized (AltoProviderImplBuilder.class) {
-                if (_toastsMade_range == null) {
-                    ImmutableList.Builder<Range<BigInteger>> builder = ImmutableList.builder();
-                    builder.add(Range.closed(BigInteger.ZERO, BigInteger.valueOf(4294967295L)));
-                    _toastsMade_range = builder.build();
-                }
-            }
-        }
-        return _toastsMade_range;
-    }
     
     public AltoProviderImplBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl> augmentation) {
         if (augmentation == null) {
@@ -100,12 +62,10 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
             return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl.class;
         }
 
-        private final java.lang.Long _toastsMade;
 
         private Map<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl>> augmentation = new HashMap<>();
 
         private AltoProviderImplImpl(AltoProviderImplBuilder base) {
-            this._toastsMade = base.getToastsMade();
                 switch (base.augmentation.size()) {
                 case 0:
                     this.augmentation = Collections.emptyMap();
@@ -119,10 +79,6 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
                 }
         }
 
-        @Override
-        public java.lang.Long getToastsMade() {
-            return _toastsMade;
-        }
         
         @SuppressWarnings("unchecked")
         @Override
@@ -137,7 +93,6 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result + ((_toastsMade == null) ? 0 : _toastsMade.hashCode());
             result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode());
             return result;
         }
@@ -154,13 +109,6 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
                 return false;
             }
             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl other = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.alto.provider.impl.rev141119.modules.module.state.AltoProviderImpl)obj;
-            if (_toastsMade == null) {
-                if (other.getToastsMade() != null) {
-                    return false;
-                }
-            } else if(!_toastsMade.equals(other.getToastsMade())) {
-                return false;
-            }
             if (getClass() == obj.getClass()) {
                 // Simple case: we are comparing against self
                 AltoProviderImplImpl otherImpl = (AltoProviderImplImpl) obj;
@@ -191,15 +139,6 @@ public class AltoProviderImplBuilder implements Builder <org.opendaylight.yang.g
             java.lang.StringBuilder builder = new java.lang.StringBuilder ("AltoProviderImpl [");
             boolean first = true;
         
-            if (_toastsMade != null) {
-                if (first) {
-                    first = false;
-                } else {
-                    builder.append(", ");
-                }
-                builder.append("_toastsMade=");
-                builder.append(_toastsMade);
-             }
             if (first) {
                 first = false;
             } else {
index 048e9c14993497662f2fd552d2ce7344aaac1d4f..f8118b9d7a27deff2358770c021dfb6a707b7a47 100644 (file)
@@ -68,12 +68,6 @@ module alto-provider-impl {
     augment "/config:modules/config:module/config:state" {
         case alto-provider-impl {
             when "/config:modules/config:module/config:type = 'alto-provider-impl'";
-
-            leaf toasts-made {
-                type uint32;
-            }
-
-            rpcx:rpc-context-instance "clear-toasts-made-rpc";
         }
     }
 }
diff --git a/alto-services/api/pom.xml b/alto-services/api/pom.xml
new file mode 100644 (file)
index 0000000..5ef6069
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.alto</groupId>
+    <artifactId>alto-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
+
+  <groupId>org.opendaylight.alto</groupId>
+  <artifactId>services.api</artifactId>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>rfc7285</module>
+  </modules>
+</project>
+
similarity index 69%
rename from alto-services/pom.xml
rename to alto-services/api/rfc7285/pom.xml
index fe597cbd26131d9d27a7f08acb869b07c232fd44..7c11201c94f73fef72fbe1177971139f52d5ecba 100644 (file)
@@ -6,13 +6,13 @@
 
   <parent>
     <groupId>org.opendaylight.alto</groupId>
-    <artifactId>alto-parent</artifactId>
+    <artifactId>services.api</artifactId>
     <version>1.0.0-SNAPSHOT</version>
     <relativePath>../</relativePath>
   </parent>
 
   <groupId>org.opendaylight.alto</groupId>
-  <artifactId>alto-services</artifactId>
+  <artifactId>service-api-rfc7285</artifactId>
   <packaging>bundle</packaging>
 
   <build>
           </dependency>
         </dependencies>
       </plugin>
-
+        
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
-        <version>${bundle.plugin.version}</version>
         <extensions>true</extensions>
         <configuration>
           <instructions>
             <Import-Package>
-              org.opendaylight.yang.gen.v1.urn.opendaylight.alto.*,
-              org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
-              org.opendaylight.yangtools.yang.common,
-              org.opendaylight.yangtools.yang.binding,
-              org.opendaylight.controller.md.sal.binding.api,
-              org.opendaylight.controller.sal.binding.api,
-              org.osgi.framework
+              org.opendaylight.alto.commons.types.rfc7285,
             </Import-Package>
             <Export-Package>
-              org.opendaylight.alto.services;
+              org.opendaylight.alto.services.api.rfc7285;
             </Export-Package>
-            <Bundle-Activator>org.opendaylight.alto.services.AltoService</Bundle-Activator>
+            <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
           </instructions>
         </configuration>
       </plugin>
  
     </plugins>
+
   </build>
 
   <dependencies>
       <artifactId>alto-model</artifactId>
       <version>${project.version}</version>
     </dependency>
+
     <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-binding-api</artifactId>
-      <version>${mdsal.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
-      <version>${osgi.core.version}</version>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-commons</artifactId>
+      <version>${project.version}</version>
     </dependency>
   </dependencies>
 </project>
diff --git a/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/AltoService.java b/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/AltoService.java
new file mode 100644 (file)
index 0000000..fdd1866
--- /dev/null
@@ -0,0 +1,8 @@
+package org.opendaylight.alto.services.api.rfc7285;
+
+//TODO EndpointPropertyService and EndpointCostService not defined yet
+public interface AltoService
+    extends IRDService, NetworkMapService, CostMapService,
+            EndpointPropertyService, EndpointCostService {
+
+}
diff --git a/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/CostMapService.java b/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/CostMapService.java
new file mode 100644 (file)
index 0000000..fa3672c
--- /dev/null
@@ -0,0 +1,29 @@
+package org.opendaylight.alto.services.api.rfc7285;
+
+import org.opendaylight.alto.commons.types.rfc7285.CostMap;
+import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.CostType;
+
+public interface CostMapService {
+
+    public CostMap getCostMap(String id);
+
+    public CostMap getCostMap(VersionTag vtag);
+
+    public CostMap getCostMap(String id, CostType type);
+
+    public CostMap getCostMap(VersionTag vtag, CostType type);
+
+    public CostMap getCostMap(String id, CostMap.Filter filter);
+
+    public CostMap getCostMap(VersionTag vtag, CostMap.Filter filter);
+
+    public Boolean supportCostType(String id, CostType type);
+
+    public Boolean supportCostType(VersionTag vtag, CostType type);
+
+    public Boolean validateCostMapFilter(String id, CostMap.Filter filter);
+
+    public Boolean validateCostMapFilter(VersionTag vtag, CostMap.Filter filter);
+}
diff --git a/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/EndpointCostService.java b/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/EndpointCostService.java
new file mode 100644 (file)
index 0000000..b9d1b9f
--- /dev/null
@@ -0,0 +1,12 @@
+package org.opendaylight.alto.services.api.rfc7285;
+
+import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
+import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+
+public interface EndpointCostService {
+
+    public Endpoint.CostResponse getEndpointCost(String id, Endpoint.CostRequest request);
+
+    public Endpoint.CostResponse getEndpointCost(VersionTag vtag, Endpoint.CostRequest request);
+
+}
diff --git a/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/EndpointPropertyService.java b/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/EndpointPropertyService.java
new file mode 100644 (file)
index 0000000..1b2cf66
--- /dev/null
@@ -0,0 +1,12 @@
+package org.opendaylight.alto.services.api.rfc7285;
+
+import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
+import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+
+public interface EndpointPropertyService {
+
+    public Endpoint.PropertyResponse getEndpointProperty(String id, Endpoint.PropertyRequest request);
+
+    public Endpoint.PropertyResponse getEndpointProperty(VersionTag vtag, Endpoint.PropertyRequest request);
+
+}
diff --git a/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/IRDService.java b/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/IRDService.java
new file mode 100644 (file)
index 0000000..767efe6
--- /dev/null
@@ -0,0 +1,11 @@
+package org.opendaylight.alto.services.api.rfc7285;
+
+import org.opendaylight.alto.commons.types.rfc7285.IRD;
+
+public interface IRDService {
+
+    public IRD getDefaultIRD();
+
+    public IRD getIRD(String id);
+
+}
diff --git a/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/NetworkMapService.java b/alto-services/api/rfc7285/src/main/java/org/opendaylight/alto/services/api/rfc7285/NetworkMapService.java
new file mode 100644 (file)
index 0000000..2c83f38
--- /dev/null
@@ -0,0 +1,22 @@
+package org.opendaylight.alto.services.api.rfc7285;
+
+import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+
+public interface NetworkMapService {
+
+    public NetworkMap getDefaultNetworkMap();
+
+    public NetworkMap getNetworkMap(String id);
+
+    public NetworkMap getNetworkMap(VersionTag vtag);
+
+    public NetworkMap getNetworkMap(String id, NetworkMap.Filter filter);
+
+    public NetworkMap getNetworkMap(VersionTag vtag, NetworkMap.Filter filter);
+
+    public Boolean validateNetworkMapFilter(String id, NetworkMap.Filter filter);
+
+    public Boolean validateNetworkMapFilter(VersionTag vtag, NetworkMap.Filter filter);
+
+}
diff --git a/alto-services/ext/fake/pom.xml b/alto-services/ext/fake/pom.xml
new file mode 100644 (file)
index 0000000..6d9dc09
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.alto</groupId>
+    <artifactId>services.ext</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <artifactId>services.ext.fake</artifactId>
+  <packaging>bundle</packaging>
+
+  <build>
+    <plugins>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+
+        <configuration>
+          <failsOnError>true</failsOnError>
+          <configLocation>controller/checkstyle.xml</configLocation>
+          <consoleOutput>true</consoleOutput>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <sourceDirectory>${project.basedir}</sourceDirectory>
+          <excludes>**\/target\/,**\/bin\/,**\/third-party,**\/yang-gen-sal</excludes>
+        </configuration>
+
+        <dependencies>
+          <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>${controller.checkstyle.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Import-Package>
+              org.opendaylight.alto.services.api.rfc7285,
+              org.opendaylight.alto.commons.types.rfc7285,
+              org.slf4j,
+            </Import-Package>
+            <Export-Package>
+              org.opendaylight.alto.services.ext.fake;
+            </Export-Package>
+            <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-model</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-commons</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>service-api-rfc7285</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+  </dependencies>
+</project>
+
diff --git a/alto-services/ext/fake/src/main/java/org/opendaylight/alto/services/ext/fake/FakeAltoService.java b/alto-services/ext/fake/src/main/java/org/opendaylight/alto/services/ext/fake/FakeAltoService.java
new file mode 100644 (file)
index 0000000..bb791f0
--- /dev/null
@@ -0,0 +1,195 @@
+package org.opendaylight.alto.services.ext.fake;
+
+import org.opendaylight.alto.services.api.rfc7285.AltoService;
+import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.CostMap;
+import org.opendaylight.alto.commons.types.rfc7285.CostType;
+import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+import org.opendaylight.alto.commons.types.rfc7285.IRD;
+import org.opendaylight.alto.commons.types.rfc7285.JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.Endpoint;
+
+public class FakeAltoService implements AltoService {
+
+    private JSONMapper mapper = new JSONMapper();
+
+    private static final String NETWORKMAP_JSON = 
+            "{"
+        +       "\"meta\" : {"
+        +           "\"vtag\": {"
+        +               "\"resource-id\": \"default-networkmap\","
+        +               "\"tag\": \"3ee2cb7e8d63d9fab71b9b34cbf764436315542e\""
+        +           "}"
+        +       "},"
+        +       "\"network-map\" : {"
+        +           "\"PID1\" : {"
+        +               "\"ipv4\" : ["
+        +                   "\"192.0.2.0/24\","
+        +                   "\"198.51.100.0/25\""
+        +               "]"
+        +           "},"
+        +           "\"PID2\" : {"
+        +               "\"ipv4\" : ["
+        +                   "\"198.51.100.128/25\""
+        +               "]"
+        +           "},"
+        +           "\"PID3\" : {"
+        +               "\"ipv4\" : ["
+        +                   "\"0.0.0.0/0\""
+        +               "],"
+        +               "\"ipv6\" : ["
+        +                   "\"::/0\""
+        +               "]"
+        +           "}"
+        +       "}"
+        +   "}";
+    
+    private static final String DEFAULT_NETWORKMAP_ID = "default-networkmap";
+    private static final String DEFAULT_NETWORKMAP_TAG = "3ee2cb7e8d63d9fab71b9b34cbf764436315542e";
+    private NetworkMap networkMap = null;
+
+    private static final String COSTMAP_JSON =
+            "{"
+        +       "\"meta\" : {"
+        +           "\"dependent-vtags\" : ["
+        +               "{"
+        +                   "\"resource-id\": \"default-networkmap\","
+        +                   "\"tag\": \"3ee2cb7e8d63d9fab71b9b34cbf764436315542e\""
+        +               "}"
+        +           "],"
+        +           "\"cost-type\" : {"
+        +               "\"cost-mode\" : \"numerical\","
+        +               "\"cost-metric\": \"routingcost\""
+        +           "}"
+        +       "},"
+        +       "\"cost-map\" : {"
+        +           "\"PID1\": { \"PID1\": 1, \"PID2\": 5, \"PID3\": 10 },"
+        +           "\"PID2\": { \"PID1\": 5, \"PID2\": 1, \"PID3\": 15 },"
+        +           "\"PID3\": { \"PID1\": 20, \"PID2\": 15 }"
+        +       "}"
+        +   "}";
+    
+    private static final String DEFAULT_COSTMAP_ID = "default-costmap";
+
+    private CostMap costMap = null;
+
+    public FakeAltoService() {
+        try {
+            networkMap = mapper.asNetworkMap(NETWORKMAP_JSON);
+            costMap = mapper.asCostMap(COSTMAP_JSON);
+        } catch (Exception e) {
+            networkMap = null;
+            costMap = null;
+        }
+    }
+    
+    public CostMap getCostMap(String id) {
+        if (!DEFAULT_COSTMAP_ID.equals(id))
+            return null;
+        return costMap;
+    }
+
+    public CostMap getCostMap(VersionTag vtag) {
+        return getCostMap(vtag.rid);
+    }
+
+    public CostMap getCostMap(String id, CostType type) {
+        if (!DEFAULT_COSTMAP_ID.equals(id))
+            return null;
+        if (!(costMap.meta.costType.equals(type)))
+            return null;
+        return costMap;
+    }
+
+    public CostMap getCostMap(VersionTag vtag, CostType type) {
+        return getCostMap(vtag.rid, type);
+    }
+
+    public CostMap getCostMap(String id, CostMap.Filter filter) {
+        return null;
+    }
+
+    public CostMap getCostMap(VersionTag vtag, CostMap.Filter filter) {
+        return null;
+    }
+
+    public Boolean supportCostType(String id, CostType type) {
+        return null;
+    }
+
+    public Boolean supportCostType(VersionTag vtag, CostType type) {
+        if (!DEFAULT_COSTMAP_ID.equals(vtag.rid))
+            return new Boolean(false);
+        if (!costMap.meta.costType.equals(type))
+            return new Boolean(false);
+        return new Boolean(true);
+    }
+
+    public Boolean validateCostMapFilter(String id, CostMap.Filter filter) {
+        return false;
+    }
+
+    public Boolean validateCostMapFilter(VersionTag vtag, CostMap.Filter filter) {
+        return false;
+    }
+
+
+    public NetworkMap getDefaultNetworkMap() {
+        return networkMap;
+    }
+
+    public NetworkMap getNetworkMap(String id) {
+        if (!DEFAULT_NETWORKMAP_ID.equals(id))
+            return null;
+        return networkMap;
+    }
+
+    public NetworkMap getNetworkMap(VersionTag vtag) {
+        if (!DEFAULT_NETWORKMAP_ID.equals(vtag.rid))
+            return null;
+        if (!DEFAULT_NETWORKMAP_TAG.equals(vtag.tag))
+            return null;
+        return networkMap;
+    }
+
+    public NetworkMap getNetworkMap(String id, NetworkMap.Filter filter) {
+        return null;
+    }
+
+    public NetworkMap getNetworkMap(VersionTag vtag, NetworkMap.Filter filter) {
+        return null;
+    }
+
+    public Boolean validateNetworkMapFilter(String id, NetworkMap.Filter filter) {
+        return new Boolean(false);
+    }
+
+    public Boolean validateNetworkMapFilter(VersionTag vtag, NetworkMap.Filter filter) {
+        return new Boolean(false);
+    }
+
+    public IRD getDefaultIRD() {
+        return null;
+    }
+
+    public IRD getIRD(String id) {
+        return null;
+    }
+
+    public Endpoint.CostResponse getEndpointCost(String id, Endpoint.CostRequest request) {
+        return null;
+    }
+
+    public Endpoint.CostResponse getEndpointCost(VersionTag vtag, Endpoint.CostRequest request) {
+        return null;
+    }
+
+    public Endpoint.PropertyResponse getEndpointProperty(String id, Endpoint.PropertyRequest request) {
+        return null;
+    }
+
+    public Endpoint.PropertyResponse getEndpointProperty(VersionTag vtag, Endpoint.PropertyRequest request) {
+        return null;
+    }
+
+}
diff --git a/alto-services/ext/fs-map/pom.xml b/alto-services/ext/fs-map/pom.xml
new file mode 100644 (file)
index 0000000..a2a371d
--- /dev/null
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.alto</groupId>
+    <artifactId>services.ext</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <artifactId>services.ext.fs-map</artifactId>
+  <packaging>bundle</packaging>
+
+  <build>
+    <plugins>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+
+        <configuration>
+          <failsOnError>true</failsOnError>
+          <configLocation>controller/checkstyle.xml</configLocation>
+          <consoleOutput>true</consoleOutput>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <sourceDirectory>${project.basedir}</sourceDirectory>
+          <excludes>**\/target\/,**\/bin\/,**\/third-party,**\/yang-gen-sal</excludes>
+        </configuration>
+
+        <dependencies>
+          <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>${controller.checkstyle.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Import-Package>
+              org.opendaylight.alto.commons.types.rfc7285,
+              org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
+              org.slf4j,
+            </Import-Package>
+            <Export-Package>
+              org.opendaylight.alto.services.ext.fsmap;
+            </Export-Package>
+            <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-model</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>commons</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+  </dependencies>
+</project>
+
diff --git a/alto-services/ext/fs-map/src/main/java/org/opendaylight/alto/services/ext/fsmap/FileSystemNetworkMapGenerator.java b/alto-services/ext/fs-map/src/main/java/org/opendaylight/alto/services/ext/fsmap/FileSystemNetworkMapGenerator.java
new file mode 100644 (file)
index 0000000..d9ef039
--- /dev/null
@@ -0,0 +1,277 @@
+package org.opendaylight.alto.services.ext.fsmap;
+
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.FileVisitResult;
+import java.nio.file.PathMatcher;
+import java.nio.file.WatchService;
+import java.nio.file.WatchKey;
+import java.nio.file.WatchEvent;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardWatchEventKinds;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.ClosedWatchServiceException;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import java.io.IOException;
+
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.HashMap;
+
+import org.opendaylight.alto.commons.types.rfc7285.JSONMapper;
+import org.opendaylight.alto.commons.types.rfc7285.NetworkMap;
+import org.opendaylight.alto.commons.types.rfc7285.VersionTag;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FileSystemNetworkMapGenerator implements Runnable, AutoCloseable {
+
+    private static final Logger logger = LoggerFactory.getLogger(FileSystemNetworkMapGenerator.class);
+
+    private ReentrantLock lock = new ReentrantLock();
+    private Path source = null;
+    private WatchService watcher = null;
+    private HashMap<Path, WatchKey> keys = new HashMap<Path, WatchKey>();
+    private HashMap<WatchKey, Path> paths = new HashMap<WatchKey, Path>();
+    private MapFileLoader loader = null;
+    private AtomicBoolean cancelled = new AtomicBoolean(false);
+    private HashMap<Path, VersionTag> path_to_id = new HashMap<Path, VersionTag>();
+    private HashMap<VersionTag, NetworkMap> id_to_map = new HashMap<VersionTag, NetworkMap>();
+    private JSONMapper mapper = new JSONMapper();
+
+    public FileSystemNetworkMapGenerator(URI uri) throws Exception {
+        source = Paths.get(uri);
+
+        FileSystem fs = source.getFileSystem();
+        watcher = fs.newWatchService();
+        if (watcher == null) {
+            throw new IOException("Unable to create watcher on given uri: " + uri);
+        }
+
+        onCreateDir(source);
+
+        loader = new MapFileLoader(fs);
+        Files.walkFileTree(source, loader);
+    }
+
+    class MapFileLoader extends SimpleFileVisitor<Path> {
+        private PathMatcher matcher = null;
+
+        MapFileLoader(FileSystem fs) {
+            matcher = fs.getPathMatcher("glob:**/*.{networkmap}");
+        }
+
+        @Override
+        public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
+            lock.lock();
+            onCreateDir(dir);
+            lock.unlock();
+            return FileVisitResult.CONTINUE;
+        }
+
+        @Override
+        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
+            logger.info("visiting file: " + file.toString());
+            if (file.toFile().isFile()) {
+                if (matcher.matches(file)) {
+                    lock.lock();
+                    onCreate(file);
+                    lock.unlock();
+                }
+            }
+            return FileVisitResult.CONTINUE;
+        }
+    }
+
+    public void run() {
+        while (!cancelled.get()) {
+            WatchKey key;
+            try {
+                key = watcher.take();
+            } catch (ClosedWatchServiceException e) {
+                System.out.println(e);
+                break;
+            } catch (Exception e) {
+                System.out.println(e);
+                continue;
+            }
+
+            for (WatchEvent<?> event: key.pollEvents()) {
+                WatchEvent.Kind<?> kind = event.kind();
+
+                if (kind == StandardWatchEventKinds.OVERFLOW)
+                    continue;
+
+                lock.lock();
+                Path dir = paths.get(key);
+                Path file = dir.resolve((Path)event.context());
+
+                if (kind == StandardWatchEventKinds.ENTRY_CREATE) {
+                    if (file.toFile().isFile())
+                        onCreate(file);
+                    else if (file.toFile().isDirectory())
+                        onCreateDir(file);
+                } else if (kind == StandardWatchEventKinds.ENTRY_DELETE) {
+                    if (file.toFile().isFile())
+                        onDelete(file);
+                    else if (file.toFile().isDirectory())
+                        onDeleteDir(file);
+                } else if (kind == StandardWatchEventKinds.ENTRY_MODIFY) {
+                    if (file.toFile().isFile())
+                        onModify(file);
+                    else if (file.toFile().isDirectory())
+                        onModifyDir(file);
+                }
+                lock.unlock();
+            }
+
+            boolean valid = key.reset();
+            if (!valid) {
+                Path dir = paths.get(key);
+                keys.remove(dir);
+                paths.remove(key);
+
+                if (keys.isEmpty())
+                    break;
+            }
+        }
+        cleanup();
+    }
+
+    public void cleanup() {
+        lock.lock();
+        for (WatchKey key: keys.values()) {
+            try {
+                if (key != null) {
+                    key.cancel();
+                }
+            } catch (Exception e) {
+            }
+        }
+        keys.clear();
+        paths.clear();
+        try {
+            if (watcher != null) {
+                watcher.close();
+                watcher = null;
+            }
+        } catch (Exception e) {
+        }
+
+        for (VersionTag vtag: path_to_id.values()) {
+            // TODO remove network map
+            if (vtag.incomplete())
+                continue;
+        }
+        path_to_id.clear();
+        id_to_map.clear();
+        lock.unlock();
+    }
+
+    public void close() {
+        cancelled.set(true);
+        cleanup();
+    }
+
+    public void onCreate(Path file) {
+        //TODO
+        try {
+            String content = new String(Files.readAllBytes(file), StandardCharsets.US_ASCII);
+            NetworkMap map = mapper.asNetworkMap(content);
+
+            VersionTag vtag = map.meta.vtag;
+            logger.info("vtag: <" + vtag.rid + ", " + vtag.tag + ">");
+            if (id_to_map.get(map.meta.vtag) != null) {
+                logger.warn("Version tag already registered: ("
+                                + vtag.rid + ", " + vtag.tag + ")");
+                return;
+            }
+            path_to_id.put(file, map.meta.vtag);
+            id_to_map.put(map.meta.vtag, map);
+            logger.info("create successfully: " + file.toString());
+            logger.info("current maps: " + id_to_map.size());
+        } catch (Exception e) {
+            logger.warn("Error while creating " + file.toString());
+            logger.warn(e.toString());
+        }
+    }
+
+    public void onCreateDir(Path dir) {
+        try {
+            WatchKey key = dir.register(watcher,
+                                    StandardWatchEventKinds.ENTRY_CREATE,
+                                    StandardWatchEventKinds.ENTRY_DELETE,
+                                    StandardWatchEventKinds.ENTRY_MODIFY);
+            keys.put(dir, key);
+            paths.put(key, dir);
+            logger.info("create dir successfully: " + dir.toString());
+        } catch (Exception e) {
+            logger.warn(e.toString());
+        }
+    }
+
+    public void onDelete(Path file) {
+        //TODO
+        try {
+            VersionTag vtag = path_to_id.get(file);
+            if (vtag == null)
+                return;
+
+            id_to_map.remove(vtag);
+            logger.info("delete: " + file.toString());
+        } catch (Exception e) {
+            logger.warn("Error while deleting " + file.toString());
+            logger.warn(e.toString());
+        }
+    }
+
+    public void onDeleteDir(Path dir) {
+        // TODO
+        try {
+            WatchKey key = keys.get(dir);
+            if (key != null) {
+                key.cancel();
+
+                keys.remove(dir);
+                paths.remove(key);
+            }
+            logger.warn("delete dir successfully: " + dir.toString());
+        } catch (Exception e) {
+            logger.warn(e.toString());
+        }
+    }
+
+    public void onModify(Path file) {
+        //TODO
+        try {
+            String content = new String(Files.readAllBytes(file), StandardCharsets.US_ASCII);
+            NetworkMap map = mapper.asNetworkMap(content);
+            VersionTag vtag = map.meta.vtag;
+            VersionTag old = path_to_id.get(file);
+
+            if (old != null) {
+                if (vtag.rid != old.rid) {
+                    throw new Exception("defining another map in one file is not allowed");
+                }
+                id_to_map.remove(old);
+            }
+            path_to_id.put(file, vtag);
+            id_to_map.put(vtag, map);
+            logger.info("modify successfully: " + file.toString());
+        } catch (Exception e) {
+            logger.warn("Error while modifying " + file.toString());
+            logger.warn(e.toString());
+        }
+    }
+
+    public void onModifyDir(Path dir) {
+        //TODO
+        onDeleteDir(dir);
+        onModifyDir(dir);
+    }
+}
diff --git a/alto-services/ext/pom.xml b/alto-services/ext/pom.xml
new file mode 100644 (file)
index 0000000..9471479
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.alto</groupId>
+    <artifactId>alto-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
+
+  <groupId>org.opendaylight.alto</groupId>
+  <artifactId>services.ext</artifactId>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>fs-map</module>
+    <module>fake</module>
+  </modules>
+
+</project>
+
diff --git a/alto-services/provider/pom.xml b/alto-services/provider/pom.xml
new file mode 100644 (file)
index 0000000..1f6adac
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.alto</groupId>
+    <artifactId>alto-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
+
+  <groupId>org.opendaylight.alto</groupId>
+  <artifactId>services.provider</artifactId>
+  <packaging>pom</packaging>
+
+  <modules>
+  </modules>
+
+</project>
+
diff --git a/alto-services/src/main/java/org/opendaylight/alto/services/AltoService.java b/alto-services/src/main/java/org/opendaylight/alto/services/AltoService.java
deleted file mode 100644 (file)
index 066b27a..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.opendaylight.alto.services;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-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.AbstractBrokerAwareActivator;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.IRDBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.NetworkMaps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.resources.network.maps.NetworkMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.CostMetric;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.CostMode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.CostTypeName;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.IRD;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.MediaType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ResourceId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.cost.types.CostTypes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.cost.types.CostTypesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.cost.types.CostTypesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ird.MetaBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ird.data.Resources;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ird.data.ResourcesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev150404.ird.data.ResourcesKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.osgi.framework.BundleContext;
-
-import com.google.common.base.Optional;
-
-public class AltoService extends AbstractBrokerAwareActivator implements BindingAwareConsumer {
-  private DataBroker dataBroker;
-  
-  @Override
-  public void onSessionInitialized(ConsumerContext session) {
-    this.dataBroker = session.getSALService(DataBroker.class);
-  }
-  
-  public NetworkMap getNetworkMap(ResourceId resourceId) {
-    ReadTransaction tx = dataBroker.newReadOnlyTransaction();
-    Optional<NetworkMap> networkMap = null;
-    try {
-      InstanceIdentifier<NetworkMap> npIID = InstanceIdentifier
-          .builder(org.opendaylight.yang.gen.v1.urn.opendaylight.alto.rev150404.Resources.class)
-          .child(NetworkMaps.class)
-          .child(NetworkMap.class, new NetworkMapKey(new ResourceId(resourceId)))
-          .build();
-      networkMap = tx.read(LogicalDatastoreType.OPERATIONAL, npIID).get();
-    } catch (InterruptedException | ExecutionException e) {
-      e.printStackTrace();
-    }
-    
-    return networkMap.get();
-  }
-
-  public IRD getIRD() {
-    IRDBuilder irdb = new IRDBuilder();
-    MetaBuilder mb = new MetaBuilder();
-
-    List<CostTypes> cost_types = new ArrayList<CostTypes>();
-    CostTypesBuilder cb = new CostTypesBuilder();
-    CostTypeName name = new CostTypeName("num-routing");
-    CostMetric metric = new CostMetric(CostMetric.Enumeration.Routingcost);
-    CostMode mode = CostMode.Numerical;
-    CostTypesKey ckey = new CostTypesKey(name);
-
-    cost_types.add(cb.setCostTypeName(name).setCostMetric(metric).setCostMode(mode).setKey(ckey).build());
-    irdb.setMeta(mb.setCostTypes(cost_types).build());
-
-    List<Resources> resources = new ArrayList<Resources>();
-    ResourcesBuilder rb = new ResourcesBuilder();
-
-    MediaType mt = new MediaType(MediaType.Enumeration.AltoNetworkmap);
-    Uri uri = new Uri("http://localhost:8080/controller/nb/v2/networkmap/default");
-    ResourcesKey rkey = new ResourcesKey(new ResourceId("my-default-networkmap"));
-
-    resources.add(rb.setMediaType(mt).setUri(uri).setKey(rkey).build());
-    irdb.setResources(resources);
-
-    return irdb.build();
-  }
-
-  @Override
-  protected void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) {
-    broker.registerConsumer(this);
-  }
-}
index 54e69b55da6aaae53ad48ff89413f2f739941b3d..3a1b05b5012f4e16ce78ab4dd1286251526462d0 100644 (file)
@@ -13,7 +13,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <relativePath>../</relativePath>
   </parent>
 
-  <groupId>org.opendaylight.alto</groupId>
   <artifactId>alto-features</artifactId>
   <name>${project.artifactId}</name>
   <modelVersion>4.0.0</modelVersion>
@@ -57,7 +56,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>features-mdsal</artifactId>
       <classifier>features</classifier>
-      <version>${mdsal.version}</version>
       <type>xml</type>
       <scope>runtime</scope>
     </dependency>
@@ -66,7 +64,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>features-restconf</artifactId>
       <classifier>features</classifier>
-      <version>${mdsal.version}</version>
       <type>xml</type>
       <scope>runtime</scope>
     </dependency>
@@ -85,13 +82,19 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
 
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>alto-services</artifactId>
+      <artifactId>alto-provider</artifactId>
       <version>${project.version}</version>
     </dependency>
 
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>alto-provider</artifactId>
+      <artifactId>alto-config</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-config</artifactId>
       <version>${project.version}</version>
     </dependency>
 
index d5e517e058bd41d1748a382099f542e76b5bec1b..56785283b0dda7e51cbd6891b6927fabf2436540 100644 (file)
@@ -25,6 +25,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:org.opendaylight.alto/alto-model/${project.version}</bundle>
   </feature>
 
+  <feature name='odl-alto-jackson-dependency' version='${project.version}' description='Opendaylight :: alto :: jackson_dependency'>
+    <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson.version}</bundle> 
+    <bundle>mvn:com.fasterxml.jackson.core/jackson-core/${jackson.version}</bundle> 
+    <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson.version}</bundle> 
+  </feature>
+
+  <feature name='odl-alto-commons' version='${project.version}' description='OpenDaylight :: alto :: utils'>
+    <feature version='${project.version}'>odl-alto-model</feature>
+    <feature version='${jackson.version}'>odl-base-jackson</feature>
+    <bundle>mvn:org.opendaylight.alto/commons/${project.version}</bundle>
+  </feature>
+
   <feature name='odl-alto-provider' version='${project.version}' description='OpenDaylight :: alto :: Provider'>
     <feature version='${project.version}'>odl-alto-model</feature>
     <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
@@ -32,6 +44,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:org.opendaylight.alto/alto-provider/${project.version}</bundle>
   </feature>
 
+  <feature name='odl-alto-extension' version='${project.version}' description='Opendaylight :: alto :: extension'>
+    <feature version='${project.version}'>odl-alto-utils</feature>
+    <bundle>mvn:org.opendaylight.alto/services.ext.fs-map/${project.version}</bundle>
+  </feature>
+
   <feature name='odl-alto-manager' version='${project.version}' description='OpenDaylight :: alto :: Provider'>
     <feature version='${jackson.version}'>odl-base-jackson</feature>
     <configfile finalname="configuration/default.networkmap">mvn:org.opendaylight.alto/alto-manager/${project.version}/xml/config</configfile>
@@ -45,27 +62,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <feature version='${mdsal.version}'>odl-mdsal-common</feature>
     <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
     <feature version='${jackson.version}'>odl-base-jackson</feature>
-    <bundle>mvn:org.opendaylight.alto/alto-commons/${project.version}</bundle>
+    <feature version='${project.version}'>odl-alto-commons</feature>
     <bundle>mvn:org.opendaylight.alto/alto-services/${project.version}</bundle>
   </feature>
 
   <feature name='odl-alto-northbound' version='${project.version}' description='Opendaylight :: alto :: Northbound'>
-    <feature version='${project.version}'>odl-alto-services</feature>
     <feature version='${jersey.version}'>odl-base-jersey</feature>
     <feature version='${war.version}'>war</feature>
     <feature version='${controller.commons.northbound.version}'>odl-adsal-northbound</feature>
+    <feature version='${project.version}'>odl-alto-utils</feature>
+    <bundle>mvn:org.opendaylight.alto/service-api-rfc7285/${project.version}</bundle>
+    <bundle>mvn:org.opendaylight.alto/services.ext.fake/${project.version}</bundle>
     <bundle>mvn:org.opendaylight.alto/alto-northbound/${project.version}</bundle>
   </feature>
 
-  <!-- TODO not implemented yet
-  <feature name='odl-alto-provider-rest' version='${project.version}' description='OpenDaylight :: alto :: provider :: REST '>
-    <feature version="${project.version}">odl-alto-provider</feature>
-    <feature version="${mdsal.version}">odl-restconf</feature>
-  </feature>
-  <feature name='odl-alto-provider-ui' version='${project.version}' description='OpenDaylight :: alto :: provider :: UI'>
-    <feature version="${project.version}">odl-alto-provider-rest</feature>
-    <feature version="${mdsal.version}">odl-mdsal-apidocs</feature>
-    <feature version="${mdsal.version}">odl-mdsal-xsql</feature>
-  </feature>
-  -->
 </features>
diff --git a/pom.xml b/pom.xml
index e9235186738cc82019490d31acfb6774eeebcf05..2368f4e51424cb45ba31202c6bf7e988607c2cb0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,6 @@
         <groupId>org.opendaylight.odlparent</groupId>
         <artifactId>odlparent</artifactId>
         <version>1.5.0-SNAPSHOT</version>
-        <relativePath/>
     </parent>
 
     <groupId>org.opendaylight.alto</groupId>
@@ -54,7 +53,6 @@
         <jersey.servlet.version>1.17</jersey.servlet.version>
         <jersey.json.version>1.17</jersey.json.version>
         <jackson.version>2.3.2</jackson.version>
-        <config.version>0.3.0-SNAPSHOT</config.version>
 
         <yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
         <yangtools.binding.version>0.7.0-SNAPSHOT</yangtools.binding.version>
         <module>alto-model</module>
         <module>alto-config</module>
         <module>alto-provider</module>
-        <module>alto-artifacts</module>
         <module>features</module>
         <module>alto-commons</module>
+        <module>alto-services/api</module>
+        <module>alto-services/ext</module>
+        <module>alto-services/provider</module>
         <module>alto-manager</module>
-        <module>alto-services</module>
-        <!--
-        <module>alto-karaf</module>
-        -->
         <module>alto-northbound</module>
     </modules>
 
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>build-helper-maven-plugin</artifactId>
             </plugin>
-            <plugin>
-              <groupId>org.jacoco</groupId>
-              <artifactId>jacoco-maven-plugin</artifactId>
-              <configuration>
-                <includes>
-                  <include>org.opendaylight.sfc.*</include>
-                </includes>
-              </configuration>
-              <executions>
-                <execution>
-                  <id>pre-test</id>
-                  <goals>
-                    <goal>prepare-agent</goal>
-                  </goals>
-                </execution>
-                <execution>
-                  <id>post-test</id>
-                  <goals>
-                    <goal>report</goal>
-                  </goals>
-                  <phase>test</phase>
-                </execution>
-              </executions>
-            </plugin>
         </plugins>
         <pluginManagement>
             <plugins>