Merge "Fixed serialization issues with Augments and java types"
authorEd Warnicke <eaw@cisco.com>
Wed, 4 Dec 2013 19:02:17 +0000 (19:02 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 4 Dec 2013 19:02:17 +0000 (19:02 +0000)
44 files changed:
opendaylight/clustering/integrationtest/pom.xml
opendaylight/clustering/services/pom.xml
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IClusterServices.java
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IClusterServicesCommon.java
opendaylight/clustering/services_implementation/pom.xml
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManagerCommon.java
opendaylight/clustering/stub/pom.xml
opendaylight/clustering/stub/src/main/java/org/opendaylight/controller/clustering/stub/internal/ClusterManagerCommon.java
opendaylight/commons/opendaylight/pom.xml
opendaylight/config/pom.xml
opendaylight/config/yang-test/src/main/yang/config-test-impl.yang
opendaylight/configuration/integrationtest/pom.xml
opendaylight/distribution/opendaylight/pom.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/00-netty.conf
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.conf
opendaylight/forwardingrulesmanager/integrationtest/pom.xml
opendaylight/hosttracker/integrationtest/pom.xml
opendaylight/md-sal/clustered-data-store/implementation/pom.xml
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FRMUtil.java
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FlowConsumerImpl.java
opendaylight/md-sal/model/pom.xml
opendaylight/md-sal/sal-binding-broker/pom.xml
opendaylight/md-sal/sal-binding-config/pom.xml
opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java
opendaylight/md-sal/sal-dom-api/pom.xml
opendaylight/md-sal/sal-dom-broker/pom.xml
opendaylight/md-sal/sal-netconf-connector/pom.xml
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/StructuredDataToXmlProvider.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlMapper.java [new file with mode: 0644]
opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/resolving/SimpleAttributeResolvingStrategy.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivator.java
opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java
opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/IOThread.java
opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/SocketThread.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtil.java
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/editConfig.xml
opendaylight/northbound/integrationtest/pom.xml
opendaylight/statisticsmanager/integrationtest/pom.xml
opendaylight/switchmanager/integrationtest/pom.xml

index ca1e37e3bee0eac8a55fda94e4385d58cbdfa4ec..43fa74fba8dd9a10b0d167fd0a05cf4f7fcfd0c5 100644 (file)
@@ -21,7 +21,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 7eede83638b0fd8eda5155c3d20a3773acbfc5c4..ebaffc29dfad0d6ceb4ac43a673a48c24db8adfe 100644 (file)
@@ -16,7 +16,7 @@
   </scm>
 
   <artifactId>clustering.services</artifactId>
-  <version>0.4.1-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <dependencies>
index 77e300e95aaa7475b276fa10eaa8f37bb9326d5b..b3427c7fcc13d77b43afd4666c788f21386cdbb6 100644 (file)
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
 
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
@@ -215,6 +216,16 @@ public interface IClusterServices {
      */
     void tbegin() throws NotSupportedException, SystemException;
 
+    /**
+     * tbegin with a timeout
+     * @see IClusterServices#tbegin
+     * @param timeout the transaction timeout
+     * @param unit TimeUnit for the timeout
+     * @throws NotSupportedException
+     * @throws SystemException
+     */
+    void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException;
+
     /**
      * Commit a transaction covering all the data structures/HW updates.
      */
index 6850c64a0ed15774c3808773241659da7b75d7aa..7ea86c6db7d334fc0cd85ac940a76da1c96c7cc0 100644 (file)
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
 
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
@@ -118,6 +119,16 @@ public interface IClusterServicesCommon {
      */
     void tbegin() throws NotSupportedException, SystemException;
 
+    /**
+     * tbegin with a timeout
+     * @see IClusterServicesCommon#tbegin
+     * @param timeout the transaction timeout
+     * @param unit TimeUnit for the timeout
+     * @throws NotSupportedException
+     * @throws SystemException
+     */
+    void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException;
+
     /**
      * Commit a transaction covering all the data structures/HW updates.
      */
index ab75eb8dd1414f777c41adb985ac475097c0cd2b..90df7511e4c8050aadfbe42a40bae6a8eea8f821 100644 (file)
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index a9e6948a408699762c9e0cd2e7396db0d05e1b16..fcf71a90ac5c3ae96940861df4296dd14dc8ef7e 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
 
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
@@ -69,6 +70,9 @@ public class ClusterManager implements IClusterServices {
 
     private static String loopbackAddress = "127.0.0.1";
 
+    // defaultTransactionTimeout is 60 seconds
+    private static int DEFAULT_TRANSACTION_TIMEOUT = 60;
+
     /**
      * Start a JGroups GossipRouter if we are a supernode. The
      * GosispRouter is nothing more than a simple
@@ -525,6 +529,12 @@ public class ClusterManager implements IClusterServices {
 
     @Override
     public void tbegin() throws NotSupportedException, SystemException {
+        // call tbegin with the default timeout
+        tbegin(DEFAULT_TRANSACTION_TIMEOUT, TimeUnit.SECONDS);
+    }
+
+    @Override
+    public void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException {
         EmbeddedCacheManager manager = this.cm;
         if (manager == null) {
             throw new IllegalStateException();
@@ -534,6 +544,15 @@ public class ClusterManager implements IClusterServices {
         if (tm == null) {
             throw new IllegalStateException();
         }
+        long timeoutSec = unit.toSeconds(timeout);
+        if((timeoutSec > Integer.MAX_VALUE) || (timeoutSec <= 0)) {
+            // fall back to the default timeout
+            tm.setTransactionTimeout(DEFAULT_TRANSACTION_TIMEOUT);
+        } else {
+            // cast is ok here
+            // as here we are sure that timeoutSec < = Integer.MAX_VALUE.
+            tm.setTransactionTimeout((int) timeoutSec);
+        }
         tm.begin();
     }
 
index 9ee00484ce573123778226c0a298b3203b3ba116..97d9ded6c86b864f06356ff026bd170cc6dbe4d5 100644 (file)
@@ -19,12 +19,15 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
+
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.NotSupportedException;
 import javax.transaction.RollbackException;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
+
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
@@ -255,6 +258,15 @@ public abstract class ClusterManagerCommon implements IClusterServicesCommon {
         }
     }
 
+    @Override
+    public void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException {
+        if (this.clusterService != null) {
+            this.clusterService.tbegin(timeout, unit);
+        } else {
+            throw new IllegalStateException();
+        }
+    }
+
     @Override
     public void tcommit() throws RollbackException, HeuristicMixedException,
             HeuristicRollbackException, java.lang.SecurityException,
index 607b48b3aa99d7d522e0ebae6276dbef8a80d00f..8fe1a99a0df59d2e8573b9f2964fb413480457a6 100644 (file)
@@ -48,7 +48,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index b6cb742d4789bf9dcc9760e3aa9fd42490a8feef..fe73e240f995acf3ff2b00dead4e9771bdb98fd5 100644 (file)
@@ -9,14 +9,16 @@
 
 package org.opendaylight.controller.clustering.stub.internal;
 
-import java.util.ArrayList;
-import java.util.concurrent.ConcurrentHashMap;
-import java.net.UnknownHostException;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Dictionary;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
 
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
@@ -25,6 +27,7 @@ import javax.transaction.RollbackException;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 
+import org.apache.felix.dm.Component;
 import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterServices;
@@ -32,9 +35,6 @@ import org.opendaylight.controller.clustering.services.IClusterServicesCommon;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Dictionary;
-import org.apache.felix.dm.Component;
-
 public abstract class ClusterManagerCommon implements IClusterServicesCommon {
     protected String containerName = "";
     protected static final Logger logger = LoggerFactory
@@ -120,6 +120,11 @@ public abstract class ClusterManagerCommon implements IClusterServicesCommon {
             java.lang.IllegalStateException, SystemException {
     }
 
+    @Override
+    public void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException {
+
+    }
+
     @Override
     public void trollback() throws java.lang.IllegalStateException,
             java.lang.SecurityException, SystemException {
index a652845770eb64009bf8fc79fc63356ce99a3e95..1cdf391a2ee50145dc5c08d7351431e5fd5a431b 100644 (file)
@@ -59,8 +59,8 @@
     <yang.version>0.5.9-SNAPSHOT</yang.version>
     <guava.version>14.0.1</guava.version>
     <osgi.core.version>5.0.0</osgi.core.version>
-    <ietf-inet-types.version>2010.09.24.1</ietf-inet-types.version>
-    <ietf-yang-types.version>2010.09.24.1</ietf-yang-types.version>
+    <ietf-inet-types.version>2010.09.24.2-SNAPSHOT</ietf-inet-types.version>
+    <ietf-yang-types.version>2010.09.24.2-SNAPSHOT</ietf-yang-types.version>
     <opendaylight-l2-types.version>2013.08.27.1</opendaylight-l2-types.version>
     <yang-ext.version>2013.09.07.1</yang-ext.version>
     <javassist.version>3.17.1-GA</javassist.version>
     <sonar.language>java</sonar.language>
     <forwardingrulesmanager.version>0.5.0-SNAPSHOT</forwardingrulesmanager.version>
     <statisticsmanager.version>0.5.0-SNAPSHOT</statisticsmanager.version>
+    <clustering.services.version>0.5.0-SNAPSHOT</clustering.services.version>
     <maven.compile.plugin.version>2.5.1</maven.compile.plugin.version>
     <java.version.source>1.7</java.version.source>
     <java.version.target>1.7</java.version.target>
index 675e5cf80da4366771cd52f12fd2ec06f7fc3e2f..99437979de214aa4177d13f739f00f7e171f6210 100644 (file)
                                     </generator>
                                     <generator>
                                         <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
-                                        <outputBaseDir>target/site</outputBaseDir>
+                                        <outputBaseDir>target/site/models</outputBaseDir>
                                     </generator>
                                 </codeGenerators>
                                 <inspectDependencies>true</inspectDependencies>
index df636fd0ef3297eb3f87870afa38d8cd18098cf5..ba5021ea099361fd5d548e318a6448811020177f 100644 (file)
@@ -119,6 +119,12 @@ module config-test-impl {
                 type tt:extend-enum;
             }
 
+            leaf sleep-factor {
+                type decimal64 {
+                    fraction-digits 2;
+                }
+            }
+
            container dto-c {
                 leaf simple-arg {
                     type uint32;
index 894f94bc46b67d11e2858715d8602dec1a54755e..6bcee92544327290aeea3826f79d26edaad206cf 100644 (file)
@@ -40,7 +40,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 9ce668da85a63dd0145daac62a34574a4a8d4054..35ebbbe0dd2455394a06f5ff62e731b57012ac6d 100644 (file)
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>${controller.version}</version>
+      <version>${clustering.services.version}</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index b9b9c7337d8922e82b8f1f8927c40be8422d8d51..7d57e6005e65774519d579838c90c9cbd4f8fe85 100644 (file)
@@ -17,6 +17,9 @@ osgi.bundles=\
 netconf.tcp.address=0.0.0.0
 netconf.tcp.port=8383
 
+netconf.tcp.client.address=127.0.0.1
+netconf.tcp.client.port=8383
+
 netconf.ssh.address=0.0.0.0
 netconf.ssh.port=1830
 
index ffee9c6da80b926437c19c4e851f10edae543646..e83fdcc5c885eac73f9d9837e0f5758ea2240499 100644 (file)
@@ -31,7 +31,7 @@
                <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-event-executor</type>
                <instance>
                        <name>global-event-executor</name>
-                       <provider>/config/modules/module[name='netty-global-eventexecutor']/instance[name='global-event-executor']</provider>
+                       <provider>/config/modules/module[name='netty-global-event-executor']/instance[name='global-event-executor']</provider>
                </instance>
        </service>
        <service>
index acae8866cee17788f73ed482f3723775f2069ace..07c21261bb4d9fad5d4ecbd002119a07d2f0163b 100644 (file)
                        <name>ref_dom-broker</name>
                </dom-broker>
                <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-               <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
-               <name>ref_runtime-mapping-singleton</name>
+                       <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+                       <name>ref_runtime-mapping-singleton</name>
                </mapping-service>
        </module>
 //SERVICES START
        <service>
-       <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+               <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
                <instance>
-               <name>ref_yang-schema-service</name>
-               <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
+                       <name>ref_yang-schema-service</name>
+                       <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
                </instance>
        </service>
        <service>
                        <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
                </instance>
        </service>
+       <service>
+               <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+               <instance>
+                       <name>ref_binding-rpc-broker</name>
+                       <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
+               </instance>
+       </service>
        <service>
                <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
                <instance>
        <service>
                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
                <instance>
-               <name>ref_binding-data-broker</name>
-               <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
-       </instance>
+                       <name>ref_binding-data-broker</name>
+                       <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
+               </instance>
        </service>
 //CAPABILITIES START
 urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
index 7904bd3a8f78f522a9a5dc93bd5b621ea3ab1488..95fbd5dafb66b2e376f595b9d8fa90552ab1c522 100644 (file)
@@ -61,7 +61,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 8f4163d68674d8a65cd0fb94689d42b6a6679189..2e80cac2ac540ca36a5ca8c4a6fbb80b07afbd3b 100644 (file)
@@ -58,7 +58,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
index 07ff98b9c521324536efdb292d425d933de8332e..9cbf35576f49ace3b4f6c26b8e7404f951f45c0a 100644 (file)
                                         </namespaceToPackage1>
                                     </additionalConfiguration>
                                 </generator>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+                                    <outputBaseDir>target/site/models</outputBaseDir>
+                                </generator>
                             </codeGenerators>
                             <inspectDependencies>true</inspectDependencies>
                         </configuration>
                         <artifactId>yang-jmx-generator-plugin</artifactId>
                         <version>0.2.3-SNAPSHOT</version>
                     </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>0.6.0-SNAPSHOT</version>
+                        <type>jar</type>
+                    </dependency>
                 </dependencies>
             </plugin>
         </plugins>
index ae6ce2f8004dd3a3244ff2567507b175fade9f53..24bfc4fdf4c09079230189c43e9d33a428ab0cbf 100644 (file)
@@ -5,7 +5,9 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
 import org.opendaylight.controller.sal.utils.IPProtocols;
+import org.opendaylight.controller.sal.utils.NetUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
@@ -21,24 +23,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTable;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 
 public class FRMUtil {
     protected static final Logger logger = LoggerFactory.getLogger(FRMUtil.class);
@@ -48,6 +52,10 @@ public class FRMUtil {
         ADD, DELETE, UPDATE, GET
     };
 
+    private enum EtherIPType {
+        ANY, V4, V6;
+    };
+
     public static boolean isNameValid(String name) {
 
         // Name validation
@@ -59,55 +67,134 @@ public class FRMUtil {
     }
 
     public static boolean validateMatch(Flow flow) {
+        EtherIPType etype = EtherIPType.ANY;
+        EtherIPType ipsrctype = EtherIPType.ANY;
+        EtherIPType ipdsttype = EtherIPType.ANY;
+
         Match match = flow.getMatch();
         if (match != null) {
             EthernetMatch ethernetmatch = match.getEthernetMatch();
             IpMatch ipmatch = match.getIpMatch();
+            Layer3Match layer3match = match.getLayer3Match();
             VlanMatch vlanmatch = match.getVlanMatch();
             match.getIcmpv4Match();
 
             if (ethernetmatch != null) {
                 if ((ethernetmatch.getEthernetSource() != null)
-                        && !isL2AddressValid(ethernetmatch.getEthernetSource().toString())) {
+                        && !isL2AddressValid(ethernetmatch.getEthernetSource().getAddress().getValue())) {
 
-                    logger.error("Ethernet source address %s is not valid. Example: 00:05:b9:7c:81:5f",
+                    logger.error("Ethernet source address is not valid. Example: 00:05:b9:7c:81:5f",
                             ethernetmatch.getEthernetSource());
                     return false;
                 }
 
                 if ((ethernetmatch.getEthernetDestination() != null)
-                        && !isL2AddressValid(ethernetmatch.getEthernetDestination().toString())) {
-                    logger.error("Ethernet destination address %s is not valid. Example: 00:05:b9:7c:81:5f",
+                        && !isL2AddressValid(ethernetmatch.getEthernetDestination().getAddress().getValue())) {
+                    logger.error("Ethernet destination address is not valid. Example: 00:05:b9:7c:81:5f",
                             ethernetmatch.getEthernetDestination());
                     return false;
                 }
 
                 if (ethernetmatch.getEthernetType() != null) {
-                    int type = Integer.decode(ethernetmatch.getEthernetType().toString());
+                    long type = ethernetmatch.getEthernetType().getType().getValue().longValue();
                     if ((type < 0) || (type > 0xffff)) {
                         logger.error("Ethernet type is not valid");
                         return false;
+                    } else {
+                        if (type == 0x0800) {
+                            etype = EtherIPType.V4;
+                        } else if (type == 0x86dd) {
+                            etype = EtherIPType.V6;
+                        }
+                    }
+
+                }
+            }
+
+            if (layer3match != null) {
+                if (layer3match instanceof Ipv4Match) {
+                    if (((Ipv4Match) layer3match).getIpv4Source() != null) {
+                        if (NetUtils.isIPv4AddressValid(((Ipv4Match) layer3match).getIpv4Source().getValue())) {
+                            ipsrctype = EtherIPType.V4;
+                        } else {
+                            logger.error("IP source address is not valid");
+                            return false;
+                        }
+
+                    } else if (((Ipv4Match) layer3match).getIpv4Destination() != null) {
+                        if (NetUtils.isIPv4AddressValid(((Ipv4Match) layer3match).getIpv4Destination().getValue())) {
+                            ipdsttype = EtherIPType.V4;
+                        } else {
+                            logger.error("IP Destination address is not valid");
+                            return false;
+                        }
+
+                    }
+                } else if (layer3match instanceof Ipv6Match) {
+                    if (((Ipv6Match) layer3match).getIpv6Source() != null) {
+                        if (NetUtils.isIPv6AddressValid(((Ipv6Match) layer3match).getIpv6Source().getValue())) {
+                            ipsrctype = EtherIPType.V6;
+                        } else {
+                            logger.error("IPv6 source address is not valid");
+                            return false;
+                        }
+
+                    } else if (((Ipv6Match) layer3match).getIpv6Destination() != null) {
+                        if (NetUtils.isIPv6AddressValid(((Ipv6Match) layer3match).getIpv6Destination().getValue())) {
+                            ipdsttype = EtherIPType.V6;
+                        } else {
+                            logger.error("IPv6 Destination address is not valid");
+                            return false;
+                        }
+
+                    }
+
+                }
+
+                if (etype != EtherIPType.ANY) {
+                    if ((ipsrctype != EtherIPType.ANY) && (ipsrctype != etype)) {
+                        logger.error("Type mismatch between Ethernet & Src IP");
+                        return false;
+                    }
+                    if ((ipdsttype != EtherIPType.ANY) && (ipdsttype != etype)) {
+                        logger.error("Type mismatch between Ethernet & Dst IP");
+                        return false;
+                    }
+                }
+                if (ipsrctype != ipdsttype) {
+                    if (!((ipsrctype == EtherIPType.ANY) || (ipdsttype == EtherIPType.ANY))) {
+                        logger.error("IP Src Dest Type mismatch");
+                        return false;
                     }
                 }
-            } else if (ipmatch != null) {
-                if (ipmatch.getIpProtocol() != null && isProtocolValid(ipmatch.getIpProtocol().toString())) {
+            }
+
+            if (ipmatch != null) {
+                if (ipmatch.getIpProtocol() != null && !(isProtocolValid(ipmatch.getIpProtocol().toString()))) {
                     logger.error("Protocol is not valid");
                     return false;
                 }
-            } else if (vlanmatch != null) {
-                if (vlanmatch.getVlanId() != null && isVlanIdValid(vlanmatch.getVlanId().toString())) {
+
+            }
+
+            if (vlanmatch != null) {
+                if (vlanmatch.getVlanId() != null
+                        && !(isVlanIdValid(vlanmatch.getVlanId().getVlanId().getValue().toString()))) {
                     logger.error("Vlan ID is not in the range 0 - 4095");
                     return false;
                 }
 
-                if (vlanmatch.getVlanPcp() != null && isVlanPriorityValid(vlanmatch.getVlanPcp().toString())) {
+                if (vlanmatch.getVlanPcp() != null
+                        && !(isVlanPriorityValid(vlanmatch.getVlanPcp().getValue().toString()))) {
                     logger.error("Vlan priority is not in the range 0 - 7");
                     return false;
                 }
             }
+
         }
 
         return true;
+
     }
 
     public static boolean validateActions(List<Action> actions) {
@@ -134,7 +221,24 @@ public class FRMUtil {
                     return false;
                 }
                 if (outputnodeconnector != null) {
-                    // TODO
+                    if (!outputnodeconnector.getValue().equals(NodeConnectorIDType.ALL)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.CONTROLLER)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.HWPATH)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.ONEPK)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.ONEPK2OPENFLOW)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.ONEPK2PCEP)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.OPENFLOW)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.OPENFLOW2ONEPK)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.OPENFLOW2PCEP)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.PCEP)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.PCEP2ONEPK)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.PCEP2OPENFLOW)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.PRODUCTION)
+                            || !outputnodeconnector.getValue().equals(NodeConnectorIDType.SWSTACK)) {
+                        logger.error("Output Action: NodeConnector Type is not valid");
+                        return false;
+                    }
+
                 }
             } else if (action instanceof PushMplsAction) {
                 Integer ethertype = ((PushMplsAction) action).getEthernetType();
@@ -154,7 +258,7 @@ public class FRMUtil {
                     logger.error("Ether Type is not valid for PushVlanAction");
                     return false;
                 }
-            } else if (action instanceof SetDlDstAction || action instanceof SetDlSrcAction) {
+            } else if (action instanceof SetDlDstAction) {
                 MacAddress address = ((SetDlDstAction) action).getAddress();
                 if (address != null && !isL2AddressValid(address.toString())) {
                     logger.error("SetDlDstAction: Address not valid");
@@ -184,25 +288,26 @@ public class FRMUtil {
                 }
             } else if (action instanceof SetVlanIdAction) {
                 VlanId vlanid = ((SetVlanIdAction) action).getVlanId();
-                if (vlanid != null && !isVlanIdValid(vlanid.toString())) {
-                    logger.error("Vlan ID %s is not in the range 0 - 4095");
+                if (vlanid != null && !isVlanIdValid(vlanid.getValue().toString())) {
+                    logger.error("Vlan ID is not in the range 0 - 4095");
                     return false;
                 }
             } else if (action instanceof SetVlanPcpAction) {
                 VlanPcp vlanpcp = ((SetVlanPcpAction) action).getVlanPcp();
-                if (vlanpcp != null && !isVlanPriorityValid(vlanpcp.toString())) {
-                    logger.error("Vlan priority %s is not in the range 0 - 7");
+                if (vlanpcp != null && !isVlanPriorityValid(vlanpcp.getValue().toString())) {
+                    logger.error("Vlan priority is not in the range 0 - 7");
                     return false;
                 }
             }
         }
         return true;
+
     }
 
     public static boolean validateInstructions(Flow flow) {
         List<Instruction> instructionsList = new ArrayList<>();
         Instructions instructions = flow.getInstructions();
-        if( instructions == null ) {
+        if (instructions == null) {
             return false;
         }
         instructionsList = instructions.getInstruction();
index 6aa0d5fc909508a930dfd8c1d6182964b8ba744a..2710104fcfac524ea9cd71cb023f151b81f98c90 100644 (file)
@@ -29,19 +29,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
@@ -58,7 +50,8 @@ import org.slf4j.LoggerFactory;
 
 public class FlowConsumerImpl implements IForwardingRulesManager {
     protected static final Logger logger = LoggerFactory.getLogger(FlowConsumerImpl.class);
-    private final FlowEventListener flowEventListener = new FlowEventListener();
+    // private final FlowEventListener flowEventListener = new
+    // FlowEventListener();
     private Registration<NotificationListener> listener1Reg;
     private SalFlowService flowService;
     // private FlowDataListener listener;
@@ -89,7 +82,6 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
 
         if (null == flowService) {
             logger.error("Consumer SAL Service is down or NULL. FRM may not function as intended");
-            System.out.println("Consumer SAL Service is down or NULL.");
             return;
         }
 
@@ -104,15 +96,14 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
         // }
 
         // For switch events
-        listener1Reg = FRMConsumerImpl.getNotificationService().registerNotificationListener(flowEventListener);
+        // listener1Reg =
+        // FRMConsumerImpl.getNotificationService().registerNotificationListener(flowEventListener);
 
         if (null == listener1Reg) {
             logger.error("Listener to listen on flow data modifcation events");
-            System.out.println("Consumer SAL Service is down or NULL.");
             return;
         }
         // addFlowTest();
-        System.out.println("-------------------------------------------------------------------");
         commitHandler = new FlowDataCommitHandler();
         FRMConsumerImpl.getDataProviderService().registerCommitHandler(path, commitHandler);
         clusterContainerService = (IClusterContainerServices) ServiceHelper.getGlobalInstance(
@@ -163,9 +154,7 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
             AddFlowInput firstMsg = input1.build();
 
             if (null != flowService) {
-                System.out.println(flowService.toString());
-            } else {
-                System.out.println("ConsumerFlowService is NULL");
+                logger.error("ConsumerFlowService is NULL");
             }
             @SuppressWarnings("unused")
             Future<RpcResult<AddFlowOutput>> result1 = flowService.addFlow(firstMsg);
@@ -185,36 +174,42 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
     private void addFlow(InstanceIdentifier<?> path, Flow dataObject) {
 
         AddFlowInputBuilder input = new AddFlowInputBuilder();
-        
-        List<Instruction> inst = (dataObject).getInstructions().getInstruction();
+
         input.setNode((dataObject).getNode());
         input.setPriority((dataObject).getPriority());
         input.setMatch((dataObject).getMatch());
         input.setCookie((dataObject).getCookie());
         input.setInstructions((dataObject).getInstructions());
-        dataObject.getMatch().getLayer3Match();
-        for (int i = 0; i < inst.size(); i++) {
-            System.out.println("i = " + i + inst.get(i).getInstruction().toString());
-            System.out.println("i = " + i + inst.get(i).toString());
-        }
-
-        System.out.println("Instruction list" + (dataObject).getInstructions().getInstruction().toString());
+        input.setBufferId(dataObject.getBufferId());
+        input.setTableId(dataObject.getTableId());
+        input.setOutPort(dataObject.getOutPort());
+        input.setOutGroup(dataObject.getOutGroup());
+        input.setIdleTimeout(dataObject.getIdleTimeout());
+        input.setHardTimeout(dataObject.getHardTimeout());
+        input.setFlowName(dataObject.getFlowName());
+        input.setFlags(dataObject.getFlags());
+        input.setCookieMask(dataObject.getCookieMask());
+        input.setContainerName(dataObject.getContainerName());
+        input.setBarrier(dataObject.isBarrier());
+        input.setInstallHw(dataObject.isInstallHw());
+        input.setStrict(dataObject.isStrict());
 
         // updating the staticflow cache
         /*
-         *  Commented out... as in many other places... use of ClusteringServices is breaking things
-         *  insufficient time to debug
-        Integer ordinal = staticFlowsOrdinal.get(0);
-        staticFlowsOrdinal.put(0, ++ordinal);
-        staticFlows.put(ordinal, dataObject);
-        */
+         * Commented out... as in many other places... use of ClusteringServices
+         * is breaking things insufficient time to debug Integer ordinal =
+         * staticFlowsOrdinal.get(0); staticFlowsOrdinal.put(0, ++ordinal);
+         * staticFlows.put(ordinal, dataObject);
+         */
 
         // We send flow to the sounthbound plugin
+
         flowService.addFlow(input.build());
+
         /*
-         * Commented out as this will also break due to improper use of ClusteringServices
-        updateLocalDatabase((NodeFlow) dataObject, true);
-        */
+         * Commented out as this will also break due to improper use of
+         * ClusteringServices updateLocalDatabase((NodeFlow) dataObject, true);
+         */
     }
 
     /**
@@ -226,34 +221,39 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
     private void removeFlow(InstanceIdentifier<?> path, Flow dataObject) {
 
         RemoveFlowInputBuilder input = new RemoveFlowInputBuilder();
-        List<Instruction> inst = (dataObject).getInstructions().getInstruction();
         input.setNode((dataObject).getNode());
         input.setPriority((dataObject).getPriority());
         input.setMatch((dataObject).getMatch());
         input.setCookie((dataObject).getCookie());
         input.setInstructions((dataObject).getInstructions());
-        dataObject.getMatch().getLayer3Match();
-        for (int i = 0; i < inst.size(); i++) {
-            System.out.println("i = " + i + inst.get(i).getInstruction().toString());
-            System.out.println("i = " + i + inst.get(i).toString());
-        }
-
-        System.out.println("Instruction list" + (dataObject).getInstructions().getInstruction().toString());
-
+        input.setBufferId(dataObject.getBufferId());
+        input.setTableId(dataObject.getTableId());
+        input.setOutPort(dataObject.getOutPort());
+        input.setOutGroup(dataObject.getOutGroup());
+        input.setIdleTimeout(dataObject.getIdleTimeout());
+        input.setHardTimeout(dataObject.getHardTimeout());
+        input.setFlowName(dataObject.getFlowName());
+        input.setFlags(dataObject.getFlags());
+        input.setCookieMask(dataObject.getCookieMask());
+        input.setContainerName(dataObject.getContainerName());
+        input.setBarrier(dataObject.isBarrier());
+        input.setInstallHw(dataObject.isInstallHw());
+        input.setStrict(dataObject.isStrict());
         // updating the staticflow cache
         /*
-         * Commented out due to problems caused by improper use of ClusteringServices
-        Integer ordinal = staticFlowsOrdinal.get(0);
-        staticFlowsOrdinal.put(0, ++ordinal);
-        staticFlows.put(ordinal, dataObject);
-        */
+         * Commented out due to problems caused by improper use of
+         * ClusteringServices Integer ordinal = staticFlowsOrdinal.get(0);
+         * staticFlowsOrdinal.put(0, ++ordinal); staticFlows.put(ordinal,
+         * dataObject);
+         */
 
         // We send flow to the sounthbound plugin
         flowService.removeFlow(input.build());
+
         /*
-         * Commented out due to problems caused by improper use of ClusteringServices
-        updateLocalDatabase((NodeFlow) dataObject, false);
-        */
+         * Commented out due to problems caused by improper use of
+         * ClusteringServices updateLocalDatabase((NodeFlow) dataObject, false);
+         */
     }
 
     /**
@@ -272,52 +272,71 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
 
         // updating the staticflow cache
         /*
-         * Commented out due to problems caused by improper use of ClusteringServices.
-        Integer ordinal = staticFlowsOrdinal.get(0);
-        staticFlowsOrdinal.put(0, ++ordinal);
-        staticFlows.put(ordinal, dataObject);
-        */
+         * Commented out due to problems caused by improper use of
+         * ClusteringServices. Integer ordinal = staticFlowsOrdinal.get(0);
+         * staticFlowsOrdinal.put(0, ++ordinal); staticFlows.put(ordinal,
+         * dataObject);
+         */
 
         // We send flow to the sounthbound plugin
         flowService.updateFlow(input.build());
+
         /*
-         * Commented out due to problems caused by improper use of ClusteringServices.
-        updateLocalDatabase((NodeFlow) dataObject, true);
-        */
+         * Commented out due to problems caused by improper use of
+         * ClusteringServices. updateLocalDatabase((NodeFlow) dataObject, true);
+         */
     }
 
     @SuppressWarnings("unchecked")
     private void commitToPlugin(internalTransaction transaction) {
-        Set<Entry<InstanceIdentifier<?>, DataObject>> createdEntries = transaction.getModification().getCreatedConfigurationData().entrySet();
+        Set<Entry<InstanceIdentifier<?>, DataObject>> createdEntries = transaction.getModification()
+                .getCreatedConfigurationData().entrySet();
 
         /*
-         * This little dance is because updatedEntries contains both created and modified entries
-         * The reason I created a new HashSet is because the collections we are returned are immutable.
+         * This little dance is because updatedEntries contains both created and
+         * modified entries The reason I created a new HashSet is because the
+         * collections we are returned are immutable.
          */
         Set<Entry<InstanceIdentifier<?>, DataObject>> updatedEntries = new HashSet<Entry<InstanceIdentifier<?>, DataObject>>();
         updatedEntries.addAll(transaction.getModification().getUpdatedConfigurationData().entrySet());
         updatedEntries.removeAll(createdEntries);
 
-        Set<InstanceIdentifier<?>> removeEntriesInstanceIdentifiers = transaction.getModification().getRemovedConfigurationData();
+        Set<InstanceIdentifier<?>> removeEntriesInstanceIdentifiers = transaction.getModification()
+                .getRemovedConfigurationData();
         transaction.getModification().getOriginalConfigurationData();
         for (Entry<InstanceIdentifier<?>, DataObject> entry : createdEntries) {
-            if(entry.getValue() instanceof Flow) {
-                System.out.println("Coming add cc in FlowDatacommitHandler");
+            if (entry.getValue() instanceof Flow) {
+                logger.debug("Coming add cc in FlowDatacommitHandler");
+                Flow flow = (Flow) entry.getValue();
+                boolean status = validate(flow);
+                if (!status) {
+                    return;
+                }
                 addFlow(entry.getKey(), (Flow) entry.getValue());
             }
         }
         for (@SuppressWarnings("unused")
         Entry<InstanceIdentifier<?>, DataObject> entry : updatedEntries) {
-            if(entry.getValue() instanceof Flow) {
-                System.out.println("Coming update cc in FlowDatacommitHandler");
+            if (entry.getValue() instanceof Flow) {
+                logger.debug("Coming update cc in FlowDatacommitHandler");
+                Flow flow = (Flow) entry.getValue();
+                boolean status = validate(flow);
+                if (!status) {
+                    return;
+                }
                 updateFlow(entry.getKey(), (Flow) entry.getValue());
             }
         }
 
-        for (InstanceIdentifier<?> instanceId : removeEntriesInstanceIdentifiers ) {
+        for (InstanceIdentifier<?> instanceId : removeEntriesInstanceIdentifiers) {
             DataObject removeValue = transaction.getModification().getOriginalConfigurationData().get(instanceId);
-            if(removeValue instanceof Flow) {
-                System.out.println("Coming remove cc in FlowDatacommitHandler");
+            if (removeValue instanceof Flow) {
+                logger.debug("Coming remove cc in FlowDatacommitHandler");
+                Flow flow = (Flow) removeValue;
+                boolean status = validate(flow);
+                if (!status) {
+                    return;
+                }
                 removeFlow(instanceId, (Flow) removeValue);
 
             }
@@ -331,7 +350,7 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
         @Override
         public DataCommitTransaction requestCommit(DataModification<InstanceIdentifier<?>, DataObject> modification) {
             // We should verify transaction
-            System.out.println("Coming in FlowDatacommitHandler");
+            logger.debug("Coming in FlowDatacommitHandler");
             internalTransaction transaction = new internalTransaction(modification);
             transaction.prepareUpdate();
             return transaction;
@@ -364,44 +383,6 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
 
             Set<Entry<InstanceIdentifier<?>, DataObject>> puts = modification.getUpdatedConfigurationData().entrySet();
             for (Entry<InstanceIdentifier<?>, DataObject> entry : puts) {
-
-                // validating the DataObject
-                DataObject value = entry.getValue();
-                if(value instanceof Flow ) {
-                    Flow flow = (Flow)value;
-                    boolean status = validate(flow);
-                    if (!status) {
-                        return;
-                    }
-                    // Presence check
-                    /*
-                     * This is breaking due to some improper use of caches...
-                     *
-                    if (flowEntryExists(flow)) {
-                        String error = "Entry with this name on specified table already exists";
-                        logger.warn("Entry with this name on specified table already exists: {}", entry);
-                        logger.error(error);
-                        return;
-                    }
-                    if (originalSwView.containsKey(entry)) {
-                        logger.warn("Operation Rejected: A flow with same match and priority exists on the target node");
-                        logger.trace("Aborting to install {}", entry);
-                        continue;
-                    }
-                    */
-                    if (!FRMUtil.validateMatch(flow)) {
-                        logger.error("Not a valid Match");
-                        return;
-                    }
-                    if (!FRMUtil.validateInstructions(flow)) {
-                        logger.error("Not a valid Instruction");
-                        return;
-                    }
-                    /*
-                     * Commented out due to Clustering Services issues
-                     * preparePutEntry(entry.getKey(), flow);
-                     */
-                }
             }
 
             // removals = modification.getRemovedConfigurationData();
@@ -419,11 +400,9 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
             Flow original = originalSwView.get(key);
             if (original != null) {
                 // It is update for us
-                System.out.println("Coming update  in FlowDatacommitHandler");
                 updates.put(key, flow);
             } else {
                 // It is addition for us
-                System.out.println("Coming add in FlowDatacommitHandler");
                 additions.put(key, flow);
             }
         }
@@ -438,7 +417,7 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
             commitToPlugin(this);
             // We return true if internal transaction is successful.
             // return Rpcs.getRpcResult(true, null, Collections.emptySet());
-            return Rpcs.getRpcResult(true, null, Collections.<RpcError>emptySet());
+            return Rpcs.getRpcResult(true, null, Collections.<RpcError> emptySet());
         }
 
         /**
@@ -451,43 +430,10 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
             // NOOP - we did not modified any internal state during
             // requestCommit phase
             // return Rpcs.getRpcResult(true, null, Collections.emptySet());
-            return Rpcs.getRpcResult(true, null, Collections.<RpcError>emptySet());
+            return Rpcs.getRpcResult(true, null, Collections.<RpcError> emptySet());
 
         }
 
-        public boolean validate(Flow flow) {
-
-            String msg = ""; // Specific part of warn/error log
-
-            boolean result  = true;
-            // flow Name validation
-            if (flow.getFlowName() == null || flow.getFlowName().trim().isEmpty()
-                    || !flow.getFlowName().matches(NAMEREGEX)) {
-                msg = "Invalid Flow name";
-                result = false;
-            }
-            // Node Validation
-            if (result == true && flow.getNode() == null) {
-                msg = "Node is null";
-                result = false;
-            }
-
-            // TODO: Validate we are seeking to program a flow against a valid Node
-
-            if (result == true && flow.getPriority() != null) {
-                if (flow.getPriority() < 0 || flow.getPriority() > 65535) {
-                    msg = String.format("priority %s is not in the range 0 - 65535",
-                            flow.getPriority());
-                    result = false;
-                }
-            }
-            if (result == false) {
-                logger.warn("Invalid Configuration for flow {}. The failure is {}",flow,msg);
-                logger.error("Invalid Configuration ({})",msg);
-            }
-            return result;
-        }
-
         private boolean flowEntryExists(Flow flow) {
             // Flow name has to be unique on per table id basis
             for (ConcurrentMap.Entry<FlowKey, Flow> entry : originalSwView.entrySet()) {
@@ -500,47 +446,6 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
         }
     }
 
-    final class FlowEventListener implements SalFlowListener {
-
-        List<FlowAdded> addedFlows = new ArrayList<>();
-        List<FlowRemoved> removedFlows = new ArrayList<>();
-        List<FlowUpdated> updatedFlows = new ArrayList<>();
-
-        @Override
-        public void onFlowAdded(FlowAdded notification) {
-            System.out.println("added flow..........................");
-            addedFlows.add(notification);
-        }
-
-        @Override
-        public void onFlowRemoved(FlowRemoved notification) {
-            removedFlows.add(notification);
-        };
-
-        @Override
-        public void onFlowUpdated(FlowUpdated notification) {
-            updatedFlows.add(notification);
-        }
-
-        @Override
-        public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
-            // TODO
-        }
-
-        @Override
-        public void onNodeErrorNotification(NodeErrorNotification notification) {
-            // TODO Auto-generated method stub
-
-        }
-
-        @Override
-        public void onNodeExperimenterErrorNotification(NodeExperimenterErrorNotification notification) {
-            // TODO Auto-generated method stub
-
-        };
-
-    }
-
     // Commented out DataChangeListene - to be used by Stats
 
     // final class FlowDataListener implements DataChangeListener {
@@ -580,6 +485,60 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
     // }
     // }
 
+    public boolean validate(Flow flow) {
+
+        String msg = ""; // Specific part of warn/error log
+
+        boolean result = true;
+        // flow Name validation
+        if (flow.getFlowName() == null || flow.getFlowName().trim().isEmpty() || !flow.getFlowName().matches(NAMEREGEX)) {
+            msg = "Invalid Flow name";
+            result = false;
+        }
+        // Node Validation
+        if (result == true && flow.getNode() == null) {
+            msg = "Node is null";
+            result = false;
+        }
+
+        // TODO: Validate we are seeking to program a flow against a valid
+        // Node
+
+        if (result == true && flow.getPriority() != null) {
+            if (flow.getPriority() < 0 || flow.getPriority() > 65535) {
+                msg = String.format("priority %s is not in the range 0 - 65535", flow.getPriority());
+                result = false;
+            }
+        }
+
+        // Presence check
+        /*
+         * This is breaking due to some improper use of caches...
+         *
+         * if (flowEntryExists(flow)) { String error =
+         * "Entry with this name on specified table already exists";
+         * logger.warn(
+         * "Entry with this name on specified table already exists: {}" ,
+         * entry); logger.error(error); return; } if
+         * (originalSwView.containsKey(entry)) { logger.warn(
+         * "Operation Rejected: A flow with same match and priority exists on the target node"
+         * ); logger.trace("Aborting to install {}", entry); continue; }
+         */
+        if (!FRMUtil.validateMatch(flow)) {
+            logger.error("Not a valid Match");
+            result = false;
+        }
+        if (!FRMUtil.validateInstructions(flow)) {
+            logger.error("Not a valid Instruction");
+            result = false;
+        }
+        if (result == false) {
+            logger.warn("Invalid Configuration for flow {}. The failure is {}", flow, msg);
+            logger.error("Invalid Configuration ({})", msg);
+        }
+        return result;
+    }
+
     private static void updateLocalDatabase(NodeFlow entry, boolean add) {
 
         updateSwViewes(entry, add);
index 2f3b7a036c6113b23d8020dd207c30ce490e6ab6..c5f1dddc344b0e239595d7ae55ac6aa3dbd1bf99 100644 (file)
@@ -66,7 +66,7 @@
                                 </generator>
                                 <generator>
                                     <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
-                                    <outputBaseDir>target/site/restconf</outputBaseDir>
+                                    <outputBaseDir>target/site/models</outputBaseDir>
                                 </generator>
                             </codeGenerators>
                             <inspectDependencies>true</inspectDependencies>
index 51b00845aef17d832e8ec737b965b5f168f06c11..89bb1e8502570ee901d5e0f5f6052ce450140120 100644 (file)
                                         </namespaceToPackage1>
                                     </additionalConfiguration>
                                 </generator>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+                                    <outputBaseDir>target/site/models</outputBaseDir>
+                                </generator>
                             </codeGenerators>
                             <inspectDependencies>true</inspectDependencies>
                         </configuration>
                         <artifactId>yang-jmx-generator-plugin</artifactId>
                         <version>0.2.3-SNAPSHOT</version>
                     </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>0.6.0-SNAPSHOT</version>
+                        <type>jar</type>
+                    </dependency>
                 </dependencies>
             </plugin>
 
index 3bc50cdd2ed1aecbf55d791f0c3fe02d9ed1bd04..a913faa15bd9396e04cdbd97eb22d3864d4272b2 100644 (file)
                                         </namespaceToPackage1>
                                     </additionalConfiguration>
                                 </generator>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+                                    <outputBaseDir>target/site/models</outputBaseDir>
+                                </generator>
                             </codeGenerators>
                             <inspectDependencies>true</inspectDependencies>
                         </configuration>
                         <artifactId>yang-jmx-generator-plugin</artifactId>
                         <version>0.2.3-SNAPSHOT</version>
                     </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>0.6.0-SNAPSHOT</version>
+                        <type>jar</type>
+                    </dependency>
                 </dependencies>
             </plugin>
             <plugin>
index 4ef9d80b02c2f34a34de5f7e6360857565bb71fe..49781ce11630a7f589dda76922e1107025b9abba 100644 (file)
@@ -111,6 +111,8 @@ public class TestHelper {
 
                 systemProperty("netconf.tcp.address").value("0.0.0.0"), //
                 systemProperty("netconf.tcp.port").value("18383"), //
+                systemProperty("netconf.tcp.client.address").value("127.0.0.1"), //
+                systemProperty("netconf.tcp.client.port").value("18383"), //
                 systemProperty("netconf.config.persister.active").value("1"), //
                 systemProperty("netconf.config.persister.1.storageAdapterClass").value(
                         "org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter"), //
index e52a7c302dc0aa378310a68874c37904e3698fdd..4ed629b77ddf8519032d106c39e8cbc40d057aba 100644 (file)
                                         </namespaceToPackage1>
                                     </additionalConfiguration>
                                 </generator>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+                                    <outputBaseDir>target/site/models</outputBaseDir>
+                                </generator>
                             </codeGenerators>
                             <inspectDependencies>true</inspectDependencies>
                         </configuration>
                         <artifactId>yang-jmx-generator-plugin</artifactId>
                         <version>0.2.3-SNAPSHOT</version>
                     </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>0.6.0-SNAPSHOT</version>
+                        <type>jar</type>
+                    </dependency>
                 </dependencies>
             </plugin>
             <plugin>
index a6601cef21f98e50c378cc573b2ea14f207655c7..4740b0d5697c916c747079819700d2f732550b1f 100644 (file)
                                         </namespaceToPackage1>
                                     </additionalConfiguration>
                                 </generator>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+                                    <outputBaseDir>target/site/models</outputBaseDir>
+                                </generator>
                             </codeGenerators>
                             <inspectDependencies>true</inspectDependencies>
                         </configuration>
                         <artifactId>yang-jmx-generator-plugin</artifactId>
                         <version>0.2.3-SNAPSHOT</version>
                     </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>0.6.0-SNAPSHOT</version>
+                        <type>jar</type>
+                    </dependency>
                 </dependencies>
             </plugin>
             
index e790a9dbb1bbd396570445e0e58da1eee105e443..fe613565a6232b608ab91ed33e014b327c4a4e2a 100644 (file)
                                         </namespaceToPackage1>
                                     </additionalConfiguration>
                                 </generator>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+                                    <outputBaseDir>target/site/models</outputBaseDir>
+                                </generator>
                             </codeGenerators>
                             <inspectDependencies>true</inspectDependencies>
                         </configuration>
                         <artifactId>yang-jmx-generator-plugin</artifactId>
                         <version>0.2.3-SNAPSHOT</version>
                     </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>0.6.0-SNAPSHOT</version>
+                        <type>jar</type>
+                    </dependency>
                 </dependencies>
             </plugin>
             <plugin>
index d0c007795263be5d8777ebd9af29774a8b47d0d9..fbddd05cafbaa6f5dd7808f31794cfb213a8deea 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.controller.sal.rest.api.RestconfService;
 import org.opendaylight.controller.sal.restconf.impl.ResponseException;
 import org.opendaylight.controller.sal.restconf.impl.StructuredData;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.NodeUtils;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -56,8 +56,9 @@ public enum StructuredDataToXmlProvider implements MessageBodyWriter<StructuredD
         if (data == null) {
             throw new ResponseException(Response.Status.NOT_FOUND, "No data exists.");
         }
-
-        Document domTree = NodeUtils.buildShadowDomTree(data);
+        
+        XmlMapper xmlMapper = new XmlMapper();
+        Document domTree = xmlMapper.write(data, (DataNodeContainer) t.getSchema());
         try {
             TransformerFactory tf = TransformerFactory.newInstance();
             Transformer transformer = tf.newTransformer();
diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlMapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlMapper.java
new file mode 100644 (file)
index 0000000..39525f8
--- /dev/null
@@ -0,0 +1,119 @@
+package org.opendaylight.controller.sal.rest.impl;
+
+import java.util.Set;
+
+import javax.activation.UnsupportedDataTypeException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.YangNode;
+import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import com.google.common.base.Preconditions;
+
+public class XmlMapper {
+
+    public Document write(CompositeNode data, DataNodeContainer schema) throws UnsupportedDataTypeException {
+        Preconditions.checkNotNull(data);
+        Preconditions.checkNotNull(schema);
+
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        Document doc = null;
+        try {
+            DocumentBuilder bob = dbf.newDocumentBuilder();
+            doc = bob.newDocument();
+        } catch (ParserConfigurationException e) {
+            return null;
+        }
+
+        if (schema instanceof ContainerSchemaNode || schema instanceof ListSchemaNode) {
+            doc.appendChild(translateToXmlAndReturnRootElement(doc, data, schema));
+            return doc;
+        } else {
+            throw new UnsupportedDataTypeException(
+                    "Schema can be ContainerSchemaNode or ListSchemaNode. Other types are not supported yet.");
+        }
+    }
+
+    private Element translateToXmlAndReturnRootElement(Document doc, Node<?> data, YangNode schema)
+            throws UnsupportedDataTypeException {
+        QName dataType = data.getNodeType();
+        Element itemEl = doc.createElementNS(dataType.getNamespace().toString(), dataType.getLocalName());
+
+        if (data instanceof SimpleNode<?>) {
+            if (schema instanceof LeafListSchemaNode) {
+                writeValueOfNodeByType(itemEl, (SimpleNode<?>) data, ((LeafListSchemaNode) schema).getType());
+            } else if (schema instanceof LeafSchemaNode) {
+                writeValueOfNodeByType(itemEl, (SimpleNode<?>) data, ((LeafSchemaNode) schema).getType());
+            } else {
+                Object value = data.getValue();
+                if (value != null) {
+                    itemEl.setTextContent(String.valueOf(value));
+                }
+            }
+        } else { // CompositeNode
+            for (Node<?> child : ((CompositeNode) data).getChildren()) {
+                DataSchemaNode childSchema = findFirstSchemaForNode(child, ((DataNodeContainer) schema).getChildNodes());
+                if (childSchema == null) {
+                    throw new UnsupportedDataTypeException("Probably the data node \""
+                            + child.getNodeType().getLocalName() + "\" is not conform to schema");
+                }
+                itemEl.appendChild(translateToXmlAndReturnRootElement(doc, child, childSchema));
+            }
+        }
+        return itemEl;
+    }
+
+    private void writeValueOfNodeByType(Element element, SimpleNode<?> node, TypeDefinition<?> type) {
+
+        TypeDefinition<?> baseType = resolveBaseTypeFrom(type);
+
+        if (baseType instanceof IdentityrefTypeDefinition && node.getValue() instanceof QName) {
+            QName value = (QName) node.getValue();
+            element.setAttribute("xmlns:x", value.getNamespace().toString());
+            element.setTextContent("x:" + value.getLocalName());
+        } else {
+            Object value = node.getValue();
+            if (value != null) {
+                element.setTextContent(String.valueOf(value));
+            }
+        }
+    }
+
+    private DataSchemaNode findFirstSchemaForNode(Node<?> node, Set<DataSchemaNode> dataSchemaNode) {
+        for (DataSchemaNode dsn : dataSchemaNode) {
+            if (node.getNodeType().getLocalName().equals(dsn.getQName().getLocalName())) {
+                return dsn;
+            } else if (dsn instanceof ChoiceNode) {
+                for (ChoiceCaseNode choiceCase : ((ChoiceNode) dsn).getCases()) {
+                    DataSchemaNode foundDsn = findFirstSchemaForNode(node, choiceCase.getChildNodes());
+                    if (foundDsn != null) {
+                        return foundDsn;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    private TypeDefinition<?> resolveBaseTypeFrom(TypeDefinition<?> type) {
+        return type.getBaseType() != null ? resolveBaseTypeFrom(type.getBaseType()) : type;
+    }
+
+}
index 41ae52b3bf0ff5da3cfb3adcffb6ccfbeb4ac491..fda1e264e6babd472799340faeda579174c497b8 100644 (file)
@@ -151,6 +151,9 @@ public class ServiceProviderController {
                 systemProperty("netconf.tcp.address").value("127.0.0.1"),
                 systemProperty("netconf.tcp.port").value("8383"),
 
+                systemProperty("netconf.tcp.client.address").value("127.0.0.1"),
+                systemProperty("netconf.tcp.client.port").value("8383"),
+
                 // Set the systemPackages (used by clustering)
                 systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
 
index 3b881579f1b4547ecdebbd287387a9b2b3f68aee..e1b8ecf17ee50c1a4895d73301025faabd5f88e6 100644 (file)
@@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
 
 import javax.management.openmbean.SimpleType;
 import java.lang.reflect.Method;
+import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.Date;
 import java.util.Map;
@@ -65,6 +66,7 @@ final class SimpleAttributeResolvingStrategy extends AbstractAttributeResolvingS
         resolverPlugins.put(Date.class.getCanonicalName(), new DateResolver());
         resolverPlugins.put(Character.class.getCanonicalName(), new CharResolver());
         resolverPlugins.put(BigInteger.class.getCanonicalName(), new BigIntegerResolver());
+        resolverPlugins.put(BigDecimal.class.getCanonicalName(), new BigDecimalResolver());
     }
 
     static interface Resolver {
@@ -106,6 +108,14 @@ final class SimpleAttributeResolvingStrategy extends AbstractAttributeResolvingS
         }
     }
 
+    static class BigDecimalResolver extends DefaultResolver {
+
+        @Override
+        protected Object parseObject(Class<?> type, String value) throws Exception {
+            return new BigDecimal(value);
+        }
+    }
+
     static class CharResolver extends DefaultResolver {
 
         @Override
index 73d39c616221403737d5cfe7f52315b043fc19d5..d91e38db33bf9206c96c18ba178dbfaa2ef115d7 100644 (file)
@@ -137,6 +137,7 @@ public class NetconfMappingTest extends AbstractConfigTest {
         checkTypeConfigAttribute(response);
         checkTypedefs(response);
         checkEnum(response);
+        checkBigDecimal(response);
 
         edit("netconfMessages/editConfig_remove.xml");
 
@@ -162,6 +163,11 @@ public class NetconfMappingTest extends AbstractConfigTest {
         verifyNoMoreInteractions(netconfOperationRouter);
     }
 
+    private void checkBigDecimal(Element response) {
+        int size = response.getElementsByTagName("sleep-factor").getLength();
+        assertEquals(1, size);
+    }
+
     private void closeSession() throws NetconfDocumentedException, ParserConfigurationException, SAXException,
             IOException {
         DefaultCloseSession closeOp = new DefaultCloseSession(NETCONF_SESSION_ID);
index 5fa0b49d7b954434e88220f5378ccc89d0f51f8d..e7916c2d5f3d041ee315e03335586d533c76206e 100644 (file)
@@ -53,7 +53,7 @@ public class ConfigPersisterActivator implements BundleActivator {
         PersisterAggregator persister = PersisterAggregator.createFromProperties(propertiesProvider);
 
         InetSocketAddress address = NetconfConfigUtil.extractTCPNetconfAddress(context,
-                "Netconf is not configured, persister is not operational");
+                "Netconf is not configured, persister is not operational",true);
         configPersisterNotificationHandler = new ConfigPersisterNotificationHandler(persister, address,
                 platformMBeanServer, ignoredMissingCapabilityRegex);
 
index 1d18f063bcc062ed64fb077d7cc34d07369a8d2e..b30c80b43d964426839306477a3c84a4d28084fd 100644 (file)
@@ -34,7 +34,8 @@ public class NetconfImplActivator implements BundleActivator {
 
     @Override
     public void start(final BundleContext context) throws Exception {
-        InetSocketAddress address = NetconfConfigUtil.extractTCPNetconfAddress(context, "TCP is not configured, netconf not available.");
+        InetSocketAddress address = NetconfConfigUtil.extractTCPNetconfAddress(context,
+                "TCP is not configured, netconf not available.", false);
 
         NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
         factoriesTracker = new NetconfOperationServiceFactoryTracker(context, factoriesListener);
index 6f164f93d9c9482613a286352a6868e41cf649c3..b91824866a107ffef75290f3a52af53318dca7a5 100644 (file)
@@ -38,7 +38,8 @@ public class NetconfSSHActivator implements BundleActivator{
         logger.trace("Starting netconf SSH  bridge.");
 
         Optional<InetSocketAddress> sshSocketAddressOptional = NetconfConfigUtil.extractSSHNetconfAddress(context,EXCEPTION_MESSAGE);
-        InetSocketAddress tcpSocketAddress = NetconfConfigUtil.extractTCPNetconfAddress(context,EXCEPTION_MESSAGE);
+        InetSocketAddress tcpSocketAddress = NetconfConfigUtil.extractTCPNetconfAddress(context,
+                EXCEPTION_MESSAGE, true);
 
         if (sshSocketAddressOptional.isPresent()){
             server = NetconfSSHServer.start(sshSocketAddressOptional.get().getPort(),tcpSocketAddress);
index 33ed88edf839a0d4c6a3f47793acf9baa15f4545..b9c9c174dcb3fd10a626c080cca5d75479c3bd62 100644 (file)
@@ -26,6 +26,7 @@ public class IOThread extends Thread {
     private String id;
     private ServerSession servSession;
     private ServerConnection servconnection;
+    private String customHeader;
 
 
     public IOThread (InputStream is, OutputStream os, String id,ServerSession ss, ServerConnection conn){
@@ -36,11 +37,24 @@ public class IOThread extends Thread {
         super.setName(id);
         logger.trace("IOThread {} created", super.getName());
     }
+    public IOThread (InputStream is, OutputStream os, String id,ServerSession ss, ServerConnection conn,String header){
+        this.inputStream = is;
+        this.outputStream = os;
+        this.servSession = ss;
+        this.servconnection = conn;
+        this.customHeader = header;
+        super.setName(id);
+        logger.trace("IOThread {} created", super.getName());
+    }
 
     @Override
     public void run() {
         logger.trace("thread {} started", super.getName());
         try {
+            if (this.customHeader!=null && !this.customHeader.equals("")){
+                this.outputStream.write(this.customHeader.getBytes());
+                logger.trace("adding  {} header", this.customHeader);
+            }
             IOUtils.copy(this.inputStream, this.outputStream);
         } catch (Exception e) {
             logger.error("inputstream -> outputstream copy error ",e);
index 95fdd48bfe31d6e83b1082eefedbfe7da06842a5..15d99a44ee4db4a7b31bd0ee2fd6abd25476079c 100644 (file)
@@ -28,6 +28,8 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser
     private static final Logger logger =  LoggerFactory.getLogger(SocketThread.class);
     private ServerConnection conn = null;
     private long sessionId;
+    private String currentUser;
+    private final String remoteAddressWithPort;
 
 
     public static void start(Socket socket, InetSocketAddress clientAddress, long sessionId) throws IOException{
@@ -40,6 +42,7 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser
         this.socket = socket;
         this.clientAddress = clientAddress;
         this.sessionId = sessionId;
+        this.remoteAddressWithPort = socket.getRemoteSocketAddress().toString().replaceFirst("/","");
 
     }
 
@@ -81,7 +84,8 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser
                                 netconf_ssh_input.start();
 
                                 logger.trace("starting netconf_ssh_output thread");
-                                netconf_ssh_output = new IOThread(ss.getStdout(),echoSocket.getOutputStream(),"output_thread_"+sessionId,ss,conn);
+                                final String customHeader = "["+currentUser+";"+remoteAddressWithPort+";ssh;;;;;;]\n";
+                                netconf_ssh_output = new IOThread(ss.getStdout(),echoSocket.getOutputStream(),"output_thread_"+sessionId,ss,conn,customHeader);
                                 netconf_ssh_output.setDaemon(false);
                                 netconf_ssh_output.start();
 
@@ -146,7 +150,8 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser
 
     public String initAuthentication(ServerConnection sc)
     {
-        return "";
+        logger.trace("Established connection with host {}",remoteAddressWithPort);
+        return "Established connection with host "+remoteAddressWithPort+"\r\n";
     }
 
     public String[] getRemainingAuthMethods(ServerConnection sc)
@@ -161,8 +166,12 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser
 
     public AuthenticationResult authenticateWithPassword(ServerConnection sc, String username, String password)
     {
-        if (USER.equals(username) && PASSWORD.equals(password))
+        if (USER.equals(username) && PASSWORD.equals(password)){
+            currentUser = username;
+            logger.trace("user {}@{} authenticated",currentUser,remoteAddressWithPort);
             return AuthenticationResult.SUCCESS;
+        }
+
 
         return AuthenticationResult.FAILURE;
     }
index b1d902d6341f83415b8be25509bc6e1dc27000c2..987708d67ed03db1276a6459ad47c75f7eabf0bf 100644 (file)
@@ -8,12 +8,12 @@
 
 package org.opendaylight.controller.netconf.util.osgi;
 
-import com.google.common.base.Optional;
-import java.net.InetSocketAddress;
-import org.osgi.framework.BundleContext;
-import static com.google.common.base.Preconditions.checkNotNull;
+        import com.google.common.base.Optional;
+        import java.net.InetSocketAddress;
+        import org.osgi.framework.BundleContext;
+        import static com.google.common.base.Preconditions.checkNotNull;
 
-    public class NetconfConfigUtil {
+public class NetconfConfigUtil {
     private static final String PREFIX_PROP = "netconf.";
 
     private enum InfixProp {
@@ -22,10 +22,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
 
     private static final String PORT_SUFFIX_PROP = ".port";
     private static final String ADDRESS_SUFFIX_PROP = ".address";
+    private static final String CLIENT_PROP = ".client";
 
-    public static InetSocketAddress extractTCPNetconfAddress(BundleContext context, String exceptionMessageIfNotFound) {
+    public static InetSocketAddress extractTCPNetconfAddress(BundleContext context, String exceptionMessageIfNotFound, boolean forClient) {
 
-        Optional<InetSocketAddress> inetSocketAddressOptional = extractSomeNetconfAddress(context, InfixProp.tcp, exceptionMessageIfNotFound);
+        Optional<InetSocketAddress> inetSocketAddressOptional = extractSomeNetconfAddress(context, InfixProp.tcp, exceptionMessageIfNotFound, forClient);
 
         if (inetSocketAddressOptional.isPresent() == false) {
             throw new IllegalStateException("Netconf tcp address not found." + exceptionMessageIfNotFound);
@@ -34,7 +35,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
     }
 
     public static Optional<InetSocketAddress> extractSSHNetconfAddress(BundleContext context, String exceptionMessage) {
-        return extractSomeNetconfAddress(context, InfixProp.ssh, exceptionMessage);
+        return extractSomeNetconfAddress(context, InfixProp.ssh, exceptionMessage, false);
     }
 
     /**
@@ -47,14 +48,28 @@ import static com.google.common.base.Preconditions.checkNotNull;
      *             if address or port are invalid, or configuration is missing
      */
     private static Optional<InetSocketAddress> extractSomeNetconfAddress(BundleContext context,
-            InfixProp infixProp, String exceptionMessage) {
-        String address = context.getProperty(PREFIX_PROP + infixProp + ADDRESS_SUFFIX_PROP);
-        if (address == null) {
+                                                                         InfixProp infixProp,
+                                                                         String exceptionMessage,
+                                                                         boolean client) {
+        String address = "";
+        if (client) {
+            address = context.getProperty(PREFIX_PROP + infixProp + CLIENT_PROP + ADDRESS_SUFFIX_PROP);
+        }
+        if (address == null || address.equals("")){
+            address = context.getProperty(PREFIX_PROP + infixProp + ADDRESS_SUFFIX_PROP);
+        }
+        if (address == null || address.equals("")) {
             throw new IllegalStateException("Cannot find initial netconf configuration for parameter    "
                     +PREFIX_PROP + infixProp + ADDRESS_SUFFIX_PROP
                     +" in config.ini. "+exceptionMessage);
         }
-        String portKey = PREFIX_PROP + infixProp + PORT_SUFFIX_PROP;
+        String portKey = "";
+        if (client) {
+            portKey = PREFIX_PROP + infixProp + CLIENT_PROP + PORT_SUFFIX_PROP;
+        }
+        if (portKey == null || portKey.equals("")){
+            portKey = PREFIX_PROP + infixProp + PORT_SUFFIX_PROP;
+        }
         String portString = context.getProperty(portKey);
         checkNotNull(portString, "Netconf port must be specified in properties file with " + portKey);
         try {
index 2233b41a850d34e0bcd15937d5e56ae1d158280e..caa0094c4b2b31a1259df17b536ebdb84d89a8b6 100644 (file)
 
                     <name>test1</name>
 
+                    <sleep-factor>
+                        2.00
+                    </sleep-factor>
+
                     <extended>
                             1
                     </extended>
index b4e0b34d091c570d3ceb90a0da52df23927ae4a7..4e1de914f7677e649f291a86d1dea69b368bddba 100644 (file)
@@ -74,7 +74,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 743c6784a51b607e57bd15b0d216593be274a6a0..a3ecf526c0748bfd274f39ff9161089d1ba3389b 100644 (file)
@@ -50,7 +50,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 5d8ce9b303067c68e79cc82fbf2a3293ac1e72ce..c06efb91b88f4b730fb86e7e256fe3e0fac7f688 100644 (file)
@@ -51,7 +51,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>