Added YANG models for flow configuration, statistics and inventory. 12/912/1
authorTony Tkacik <ttkacik@cisco.com>
Mon, 19 Aug 2013 18:37:51 +0000 (20:37 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Mon, 19 Aug 2013 18:55:11 +0000 (20:55 +0200)
Added AbstractBindingAwareConsumer and Provider, updated samples.

Change-Id: I72a8707b7e0b4e97d11d9f6f4288f0656d0840e0
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
22 files changed:
opendaylight/sal/yang-prototype/sal/model/model-flow-statistics/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/model/model-flow-statistics/src/main/yang/opendaylight-flow-statistics.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/model/model-flow/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/model/model-flow/src/main/yang/opendaylight-flow.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/model/model-inventory/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/model/model-inventory/src/main/yang/opendaylight-inventory.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/model/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/model/src/main/yang/.gitignore [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/pom.xml
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataCommitHandler.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataProviderService.java [moved from opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataConsumerService.java with 96% similarity]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/RuntimeDataProvider.java
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/.gitignore [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend
opendaylight/sal/yang-prototype/sal/sal-core-api/pom.xml
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java
opendaylight/sal/yang-prototype/sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/impl/ToastConsumerImpl.java
opendaylight/sal/yang-prototype/sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/ToasterProvider.java

diff --git a/opendaylight/sal/yang-prototype/sal/model/model-flow-statistics/pom.xml b/opendaylight/sal/yang-prototype/sal/model/model-flow-statistics/pom.xml
new file mode 100644 (file)
index 0000000..98617a8
--- /dev/null
@@ -0,0 +1,26 @@
+<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>
+        <artifactId>model-parent</artifactId>
+        <groupId>org.opendaylight.controller.model</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>model-flow-statistics</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>model-inventory</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>model-flow</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+    <packaging>bundle</packaging>
+</project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/model/model-flow-statistics/src/main/yang/opendaylight-flow-statistics.yang b/opendaylight/sal/yang-prototype/sal/model/model-flow-statistics/src/main/yang/opendaylight-flow-statistics.yang
new file mode 100644 (file)
index 0000000..36d8bf2
--- /dev/null
@@ -0,0 +1,82 @@
+module opendaylight-flow-statistics {
+    namespace "urn:opendaylight:flow:statistics";
+    prefix flowstat;
+
+    import yang-ext {prefix ext;}
+    import ietf-inet-types {prefix inet;}
+    import ietf-yang-types {prefix yang;}
+    import opendaylight-flow {prefix flow;}
+    import opendaylight-inventory {prefix inv;}
+
+    revision "2013-08-19" {
+        description "Initial revision of flow service";
+    }
+
+    augment "/flow:flows/flow:flow" {
+        ext:augment-identifier "flow-statistics";
+
+        leaf packet-count {
+            type uint64;
+        } 
+
+        leaf byte-count {
+            type uint64;
+        }
+
+        container duration {
+            leaf second {
+                type uint64;
+            }
+            leaf nanosecond {
+                type uint64;
+            }
+        }
+    }
+
+    augment "/inv:nodes/inv:node/inv:node-connector" {
+        ext:augment-identifier "node-connector-statistics";
+
+        container packets {
+            leaf received {
+                type uint64;
+            }
+            leaf transmitted {
+                type uint64;
+            }
+        }
+        container bytes {
+            leaf received {
+                type uint64;
+            }
+            leaf transmitted {
+                type uint64;
+            }
+        }
+        leaf receive-drops {
+            type uint64;
+        }
+        leaf transmit-drops {
+            type uint64;
+        }
+        leaf receive-errors {
+            type uint64;
+        }
+        leaf transmit-errors {
+            type uint64;
+        }
+        leaf receive-frame-error {
+            type uint64;
+        }
+        leaf receive-over-run-error {
+            type uint64;
+        }
+        leaf receive-crc-error {
+            type uint64;
+        }
+        leaf collision-count {
+            type uint64;
+        }
+
+    }
+
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/model/model-flow/pom.xml b/opendaylight/sal/yang-prototype/sal/model/model-flow/pom.xml
new file mode 100644 (file)
index 0000000..7c878fa
--- /dev/null
@@ -0,0 +1,21 @@
+<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>
+        <artifactId>model-parent</artifactId>
+        <groupId>org.opendaylight.controller.model</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>model-flow</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>model-inventory</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+    <packaging>bundle</packaging>
+</project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/model/model-flow/src/main/yang/opendaylight-flow.yang b/opendaylight/sal/yang-prototype/sal/model/model-flow/src/main/yang/opendaylight-flow.yang
new file mode 100644 (file)
index 0000000..1f94ef9
--- /dev/null
@@ -0,0 +1,266 @@
+module opendaylight-flow {
+    namespace "urn:opendaylight:flow:service";
+    prefix flow;
+
+    import yang-ext {prefix ext;}
+    import ietf-inet-types {prefix inet;}
+    import ietf-yang-types {prefix yang;}
+    import opendaylight-inventory {prefix inv;}
+
+    revision "2013-08-19" {
+        description "Initial revision of flow service";
+    }
+
+    /** Base structure **/
+    container flows {
+        list flow {
+            leaf node {
+                type inv:node-id;
+            }
+            container match {
+                // Match is empty
+                leaf input-node-connector {
+                    type inv:node-connector-id; //
+                }
+            }
+            list action {
+                key id;
+                leaf id {
+                    type string;
+                }
+                choice action {
+                
+                }
+            }
+        }
+    }
+
+    /** Matches **/
+    augment "/flows/flow/match" {
+        ext:augment-identifier "ethernet-match";
+        container ethernet-source {
+            description "Ethernet source address.";
+            leaf address {
+                type yang:mac-address;
+            }
+            leaf mask {
+                type binary;
+            }
+        }
+        container ethernet-destination {
+            description "Ethernet destination address.";
+            leaf address {
+                type yang:mac-address;
+            }
+        }
+        container ethernet-type {
+            description "Ethernet frame type.";
+            leaf type {
+                type uint16; // Needs to define that as general model
+            }
+            leaf mask {
+                type binary;
+            }
+        }
+    }
+
+    augment "/flows/flow/match" {
+        ext:augment-identifier "vlan-match";
+
+        container vlan-id {
+            description "VLAN id.";
+            leaf vlan-id {
+                type uint16; // TODO: Define proper vlan id type.
+            }
+            leaf mask {
+                type binary;
+            }
+        }
+        leaf vlan-pcp {
+            description "VLAN priority.";
+            type uint8; // TODO: Define PCP type
+        }
+        
+
+    }
+
+    augment "/flows/flow/match" {
+        ext:augment-identifier "ip-match";
+
+        leaf ip-protocol {
+                description "IP protocol.";
+                type uint8; // TODO define IP protocol number
+        }
+
+        leaf ip-dscp {
+            description "IP DSCP (6 bits in ToS field).";
+            type inet:dscp; // TODO: Define DSCP type
+        }
+        leaf ip-ecn {
+            description "IP ECN (2 bits in ToS field).";
+            type uint8; // TODO define ECN
+        }
+    }
+
+    augment "/flows/flow/match" {
+        ext:augment-identifier "ipv4-match";
+        leaf ipv4-source {
+            description "IPv4 source address.";
+            type inet:ipv4-prefix;
+        }
+        leaf ipv4-destination {
+            description "IPv4 destination address.";
+            type inet:ipv4-prefix;
+        }
+    }
+
+    augment "/flows/flow/match" {
+        ext:augment-identifier "ipv6-match";
+        leaf ipv6-source {
+            description "IPv6 source address.";
+            type inet:ipv6-prefix;
+        }
+        leaf ipv6-destination {
+            description "IPv6 destination address.";
+            type inet:ipv6-prefix;
+        }
+    }
+
+
+    augment "/flows/flow/match" {
+        ext:augment-identifier "udp-match";
+        
+        leaf udp-source-port {
+            description "UDP source port.";
+            type inet:port-number;
+        }
+        leaf udp-destination-port {
+            description "UDP destination port.";
+                type inet:port-number;
+        }
+    }
+
+    augment "/flows/flow/match" {
+        ext:augment-identifier "tcp-match";
+        leaf tcp-source-port {
+            description "TCP source port.";
+            type inet:port-number;
+        }
+        leaf tcp-destination-port {
+            description "TCP destination port.";
+            type inet:port-number;
+        }
+    }
+
+    augment "/flows/flow/match" {
+        ext:augment-identifier "sctp-match";
+        leaf sctp-source-port {
+            description "SCTP source port.";
+            type inet:port-number;
+        }
+        leaf sctp-destination-dst {
+            description "SCTP destination port.";
+            type inet:port-number;
+        }
+    }
+
+    augment "/flows/flow/match" {
+        ext:augment-identifier "icmpv4-match";
+        leaf icmpv4-type {
+        description "ICMP type.";
+            type uint8; // Define ICMP Type
+        }
+        description "ICMP code.";
+        leaf icmpv4-code {
+            type uint8; // Define ICMP Code
+        }
+    }
+
+    augment "/flows/flow/match" {
+        ext:augment-identifier "arp-match";
+            
+        leaf arp-source-transport-address {
+            description "ARP source IPv4 address.";
+            type inet:ipv4-prefix;
+        }
+    
+        leaf arp-target-transport-address {
+            description "ARP target IPv4 address.";
+            type inet:ipv4-prefix;
+        }
+        container arp-source-hardware-address {
+            description "ARP source hardware address.";
+            leaf address {
+                type yang:mac-address;
+            }
+            leaf mask {
+                type binary;
+            }
+        }
+        container arp-target-hardware-address {
+            description "ARP target hardware address.";
+            leaf address {
+                type yang:mac-address;
+            }
+            leaf mask {
+                type binary;
+            }
+        }
+    }
+
+    /** Actions **/
+    augment "/flows/flow/action/action" {
+        case output-action {
+            leaf output-node-connector {
+                type string;
+            }
+        }
+
+        case controller-action {
+            leaf max-length {
+                type uint16 {
+                    range "0..65294";
+                }
+            }
+        }
+
+        case set-queue-action {
+            leaf queue {
+                type string; // TODO: define queues
+            }
+        }
+
+        case pop-mpls-action {
+            container pop-mpls {
+                leaf ethernet-type {
+                    type uint16; // TODO: define ethertype type
+                }
+            }
+        }
+
+        case set-mpls-ttl-action {
+            leaf mpls-ttl {
+                type uint8;
+            }
+        }
+
+        case set-nw-ttl-action {
+            leaf nw-ttl {
+                type uint8;
+            }
+        }
+
+        case push-pbb-action {
+
+        }
+
+        case push-mpls-action {
+
+        }
+
+        case push-vlan-action {
+
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/model/model-inventory/pom.xml b/opendaylight/sal/yang-prototype/sal/model/model-inventory/pom.xml
new file mode 100644 (file)
index 0000000..0de70e3
--- /dev/null
@@ -0,0 +1,13 @@
+<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>
+        <artifactId>model-parent</artifactId>
+        <groupId>org.opendaylight.controller.model</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>model-inventory</artifactId>
+    <packaging>bundle</packaging>
+</project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/model/model-inventory/src/main/yang/opendaylight-inventory.yang b/opendaylight/sal/yang-prototype/sal/model/model-inventory/src/main/yang/opendaylight-inventory.yang
new file mode 100644 (file)
index 0000000..9f2590b
--- /dev/null
@@ -0,0 +1,34 @@
+module opendaylight-inventory {
+    namespace "urn:opendaylight:inventory";
+    prefix flow;
+
+    import yang-ext {prefix ext;}
+    import ietf-inet-types {prefix inet;}
+    import ietf-yang-types {prefix yang;}
+
+
+    revision "2013-08-19" {
+        description "Initial revision of Inventory model";
+    }
+
+    typedef node-id {
+        type inet:uri;
+    }
+
+    typedef node-connector-id {
+        type inet:uri;
+    }
+
+    /** Base structure **/
+    container nodes {
+        list node {
+            key id;
+            leaf id {
+                type node-id;
+            }
+            list node-connector {
+                type node-connector-id;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/model/pom.xml b/opendaylight/sal/yang-prototype/sal/model/pom.xml
new file mode 100644 (file)
index 0000000..4ce4dcb
--- /dev/null
@@ -0,0 +1,163 @@
+<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>sal-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.controller.model</groupId>
+    <artifactId>model-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <properties>
+        <yang.version>0.5.7-SNAPSHOT</yang.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.bundle.version>2.4.0</maven.bundle.version>
+    </properties>
+
+    <modules>
+        <module>model-inventory</module>
+        <module>model-flow</module>
+        <module>model-flow-statistics</module>
+        <!-- <module>model-topology-bgp</module> -->
+    </modules>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>${maven.bundle.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>${yang.version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <yangFilesRootDir>src/main/yang</yangFilesRootDir>
+                            <codeGenerators>
+                                <generator>
+                                    <codeGeneratorClass>
+                                        org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
+                                    </codeGeneratorClass>
+                                    <outputBaseDir>
+                                        target/generated-sources/sal
+                                    </outputBaseDir>
+                                </generator>
+                            </codeGenerators>
+                            <inspectDependencies>true</inspectDependencies>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>0.5.7-SNAPSHOT</version>
+                        <type>jar</type>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.7</version>
+                <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>
+        </plugins>
+        <pluginManagement>
+            <plugins>
+                <!--This plugin's configuration is used to store Eclipse 
+                    m2e settings only. It has no influence on the Maven build itself. -->
+                <plugin>
+                    <groupId>org.eclipse.m2e</groupId>
+                    <artifactId>lifecycle-mapping</artifactId>
+                    <version>1.0.0</version>
+                    <configuration>
+                        <lifecycleMappingMetadata>
+                            <pluginExecutions>
+                                <pluginExecution>
+                                    <pluginExecutionFilter>
+                                        <groupId>
+                                            org.opendaylight.yangtools
+                                        </groupId>
+                                        <artifactId>
+                                            yang-maven-plugin
+                                        </artifactId>
+                                        <versionRange>
+                                            [0.5,)
+                                        </versionRange>
+                                        <goals>
+                                            <goal>
+                                                generate-sources
+                                            </goal>
+                                        </goals>
+                                    </pluginExecutionFilter>
+                                    <action>
+                                        <ignore></ignore>
+                                    </action>
+                                </pluginExecution>
+                            </pluginExecutions>
+                        </lifecycleMappingMetadata>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-binding</artifactId>
+            <version>${yang.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+            <version>${yang.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.model</groupId>
+            <artifactId>ietf-inet-types</artifactId>
+            <version>2010.09.24-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.model</groupId>
+            <artifactId>ietf-yang-types</artifactId>
+            <version>2010.09.24-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-ext</artifactId>
+            <version>2013.09.07-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git a/opendaylight/sal/yang-prototype/sal/model/src/main/yang/.gitignore b/opendaylight/sal/yang-prototype/sal/model/src/main/yang/.gitignore
new file mode 100644 (file)
index 0000000..d40e041
--- /dev/null
@@ -0,0 +1 @@
+*.yang
\ No newline at end of file
index a3d95bdf3087727884ea53a2134cd5eee0649134..3b38c1eee70056832d8509e88a63f37c98709901 100644 (file)
@@ -13,6 +13,7 @@
                <module>sal-binding-api</module>
                <module>sal-binding-broker-impl</module>
         <module>samples</module>
+        <module>model</module>
        </modules>
 
        <properties>
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java b/opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java
new file mode 100644 (file)
index 0000000..b90bd23
--- /dev/null
@@ -0,0 +1,23 @@
+package org.opendaylight.controller.sal.binding.api;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public abstract class AbstractBindingAwareConsumer implements BindingAwareConsumer,BundleActivator {
+
+    @Override
+    public final void start(BundleContext context) throws Exception {
+        ServiceReference<BindingAwareBroker> brokerRef = context.getServiceReference(BindingAwareBroker.class);
+        BindingAwareBroker broker = context.getService(brokerRef);
+        broker.registerConsumer(this, context);
+        //context.ungetService(brokerRef);
+    }
+
+    @Override
+    public final  void stop(BundleContext context) throws Exception {
+        // TODO Auto-generated method stub
+        
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java b/opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java
new file mode 100644 (file)
index 0000000..dbdedc3
--- /dev/null
@@ -0,0 +1,21 @@
+package org.opendaylight.controller.sal.binding.api;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public abstract class AbstractBindingAwareProvider implements BindingAwareProvider, BundleActivator {
+
+    @Override
+    public final void start(BundleContext context) throws Exception {
+            ServiceReference<BindingAwareBroker> brokerRef = context.getServiceReference(BindingAwareBroker.class);
+            BindingAwareBroker broker = context.getService(brokerRef);
+            broker.registerProvider(this, context);
+    }
+
+    @Override
+    public final void stop(BundleContext context) throws Exception {
+            
+            
+    }
+}
index fa104882a372bf173a283406f506c7011385aa34..87008cd14b9e8780f4185d155a675c921467faf3 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.sal.binding.api;
 
 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataConsumerService;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.osgi.framework.BundleContext;
 
@@ -35,7 +35,7 @@ import org.osgi.framework.BundleContext;
  * {@link NotificationProviderService}
  * <li>Functionality and Data model
  * <li>Data Store access and modification - see {@link DataBrokerService} and
- * {@link DataConsumerService}
+ * {@link DataProviderService}
  * </ul>
  * 
  * The services are exposed via session.
index 250aaf35c07156f4b8127ece47c7a6b58e70b1d9..dd055aa3820d64c6ffaa084066ed0bf22c25a5d5 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
  * system.
  * 
  * 
- * @see DataConsumerService
+ * @see DataProviderService
  */
 public interface DataBrokerService extends BindingAwareService {
 
index 7b965d16f296ed4300be26e3d28966e2d7f58128..ea5a16e27b3159dad19469c13e329c5971ee517c 100644 (file)
@@ -191,7 +191,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
  * {@link Provider#getProviderFunctionality()}
  * <li>passing an instance of implementation and {@link DataStoreIdentifier} of
  * rpc as arguments to the
- * {@link DataConsumerService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)}
+ * {@link DataProviderService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)}
  * </ul>
  * 
  * 
index b9f5d5aa2700a92665db21f966766873f8baec47..4b01aed6ee7a285d91b9faddc5e03da27091cabf 100644 (file)
@@ -2,9 +2,50 @@ package org.opendaylight.controller.sal.binding.api.data;
 
 import java.util.Set;
 
+import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.DataRoot;
 
 public interface RuntimeDataProvider {
 
+    Set<DataStoreIdentifier> getSupportedStores();
+    
+    
     Set<Class<? extends DataRoot>> getProvidedDataRoots();
+    
+    
+    /**
+     * Returns a data from specified Data Store.
+     * 
+     * Returns all the data visible to the consumer from specified Data Store.
+     * 
+     * @param <T>
+     *            Interface generated from YANG module representing root of data
+     * @param store
+     *            Identifier of the store, from which will be data retrieved
+     * @return data visible to the consumer
+     */
+    <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType);
+
+    /**
+     * Returns a filtered subset of data from specified Data Store.
+     * 
+     * <p>
+     * The filter is modeled as an hierarchy of Java TOs starting with
+     * implementation of {@link DataRoot} representing data root. The semantics
+     * of the filter tree is the same as filter semantics defined in the NETCONF
+     * protocol for rpc operations <code>get</code> and <code>get-config</code>
+     * in Section 6 of RFC6241.
+     * 
+     * 
+     * @see http://tools.ietf.org/html/rfc6241#section-6
+     * @param <T>
+     *            Interface generated from YANG module representing root of data
+     * @param store
+     *            Identifier of the store, from which will be data retrieved
+     * @param filter
+     *            Data tree filter similar to the NETCONF filter
+     * @return
+     */
+    <T extends DataRoot> T getData(DataStoreIdentifier store, T filter);
 }
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/.gitignore b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/.gitignore
new file mode 100644 (file)
index 0000000..04b73cb
--- /dev/null
@@ -0,0 +1 @@
+/xtend-gen
index 74ef87ae5afd4713f135a8feb05d2a4e306f58a5..4f7d41a12c7e86bf5d1696cc9a7d5a26d8ee245f 100644 (file)
@@ -38,7 +38,8 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
     private Map<Class<? extends RpcService>, RpcProxyContext> managedProxies = new HashMap();
     private var NotificationBrokerImpl notifyBroker
     private var ServiceRegistration<NotificationProviderService> notifyBrokerRegistration
-
+    private var DataBrokerImpl dataBroker
+    
     @Property
     var BundleContext brokerBundleContext
 
@@ -80,6 +81,17 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
         new OsgiProviderContext(providerCtx, this)
     }
 
+    /**
+     * Returns a Managed Direct Proxy for supplied class
+     * 
+     * Managed direct proxy is a generated proxy class conforming to the supplied interface
+     * which delegates all calls to the backing delegate.
+     * 
+     * Proxy does not do any validation, null pointer checks or modifies data in any way, it
+     * is only use to avoid exposing direct references to backing implementation of service.
+     * 
+     * If proxy class does not exist for supplied service class it will be generated automatically.
+     */
     def <T extends RpcService> getManagedDirectProxy(Class<T> service) {
         
         var RpcProxyContext existing = null
@@ -115,6 +127,10 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
         return proxyCls.toClass(delegate.classLoader)
     }
 
+    /**
+     * Registers RPC Implementation
+     * 
+     */
     def <T extends RpcService> registerRpcImplementation(Class<T> type, T service, OsgiProviderContext context,
         Hashtable<String, String> properties) {
         val proxy = getManagedDirectProxy(type)
@@ -126,12 +142,26 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
         return new RpcServiceRegistrationImpl<T>(type, service, osgiReg);
     }
     
+    /**
+     * Helper method to return delegate from ManagedDirectedProxy with use of reflection.
+     * 
+     * Note: This method uses reflection, but access to delegate field should be 
+     * avoided and called only if neccessary.
+     * 
+     */
     def <T extends RpcService> getDelegate(RpcService proxy) {
         val field = proxy.class.getField(DELEGATE_FIELD)
         if(field == null) throw new UnsupportedOperationException("Unable to get delegate from proxy");
         return field.get(proxy) as T
     }
     
+        /**
+     * Helper method to set delegate to ManagedDirectedProxy with use of reflection.
+     * 
+     * Note: This method uses reflection, but setting delegate field should not occur too much
+     * to introduce any significant performance hits.
+     * 
+     */
     def void setDelegate(RpcService proxy, RpcService delegate) {
         val field = proxy.class.getField(DELEGATE_FIELD)
         if(field == null) throw new UnsupportedOperationException("Unable to set delegate to proxy");
index e3ded1a6795b706df56980a5db452a0d76944428..15e90ec8c57a9c9d1b41d928711be8a8cdc65d9a 100644 (file)
@@ -1,27 +1,27 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
-    <modelVersion>4.0.0</modelVersion>\r
-    <parent>\r
-        <groupId>org.opendaylight.controller</groupId>\r
-        <artifactId>sal-parent</artifactId>\r
-        <version>1.0-SNAPSHOT</version>\r
-    </parent>\r
-    <artifactId>sal-core-api</artifactId>\r
-\r
-    <dependencies>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>sal-common</artifactId>\r
-            <version>1.0-SNAPSHOT</version>\r
-        </dependency>\r
-\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>yang-data-api</artifactId>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>yang-model-api</artifactId>\r
-        </dependency>\r
-    </dependencies>\r
+<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.controller</groupId>
+        <artifactId>sal-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>sal-core-api</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-data-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-model-api</artifactId>
+        </dependency>
+    </dependencies>
 </project>
\ No newline at end of file
index f4bc71142a4bfe36daf9eeec39d04e95285c0a05..fef894ba5c52b2bd13132136ac1c07e35c5aeaf0 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.controller.sal.core.api.Consumer;
 import org.opendaylight.controller.sal.core.api.Provider;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.CompositeNodeModification;
+import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;
 import org.opendaylight.yangtools.yang.data.api.Node;
 
 
@@ -106,7 +106,7 @@ public interface DataBrokerService extends BrokerService {
      *         was successful, otherwise list of the encountered errors.
      */
     RpcResult<CompositeNode> editCandidateData(DataStoreIdentifier store,
-            CompositeNodeModification changeSet);
+            MutableCompositeNode changeSet);
 
     /**
      * Initiates a two-phase commit of candidate data.
index 71ef68d565581866380f8e9cfe173a235dfc6d19..0a73110262116ba99a753697c695381ecad3c185 100644 (file)
@@ -11,15 +11,21 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.concurrent.ExecutionException;
 
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareConsumer;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
 import org.opendaylight.controller.sal.binding.api.NotificationListener;
 import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+import org.opendaylight.controller.sal.common.GlobalDataStore;
 import org.opendaylight.controller.sample.toaster.provider.api.ToastConsumer;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev20091120.MakeToastInputBuilder;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev20091120.ToastDone;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev20091120.ToastType;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev20091120.Toaster;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev20091120.ToasterData;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev20091120.ToasterService;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.osgi.framework.BundleActivator;
@@ -28,7 +34,7 @@ import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ToastConsumerImpl implements BundleActivator, BindingAwareConsumer, ToastConsumer,
+public class ToastConsumerImpl extends AbstractBindingAwareConsumer implements BundleActivator, BindingAwareConsumer, ToastConsumer,
         NotificationListener<ToastDone> {
 
     private static final Logger log = LoggerFactory.getLogger(ToastConsumerImpl.class);
@@ -64,22 +70,17 @@ public class ToastConsumerImpl implements BundleActivator, BindingAwareConsumer,
         this.session = session;
         NotificationService notificationService = session.getSALService(NotificationService.class);
         notificationService.addNotificationListener(ToastDone.class, this);
-
-    }
-
-    @Override
-    public void start(BundleContext context) throws Exception {
-        ServiceReference<BindingAwareBroker> brokerRef = context.getServiceReference(BindingAwareBroker.class);
-        BindingAwareBroker broker = context.getService(brokerRef);
-        broker.registerConsumer(this, context);
-        Dictionary<String, String> properties = new Hashtable<>();
-        context.registerService(ToastConsumer.class, this, properties);
+        
+        
     }
 
-    @Override
-    public void stop(BundleContext context) throws Exception {
-        // TODO Auto-generated method stub
-
+    private void loadToasterData() {
+        // We request data store service implementation
+        DataBrokerService brokerService = session.getSALService(DataBrokerService.class);
+        
+        ToasterData data = brokerService.getData(GlobalDataStore.RuntimeInfo, ToasterData.class);
+        Toaster toaster = data.getToaster();
+        log.info("Available toaster is: ", toaster.getToasterManufacturer(),toaster.getToasterModelNumber());
     }
 
     @Override
index 08ac1494c658e8e4a75fe220c9c7119719f41618..c776f363ddaa5e312d1f8bd31159f6143845e69c 100644 (file)
@@ -3,11 +3,12 @@ import java.util.Collection;
 import java.util.Collections;
 
 
+import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev20091120.ToasterService;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.osgi.framework.BundleActivator;
@@ -17,7 +18,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-public class ToasterProvider implements BindingAwareProvider, BundleActivator {
+public class ToasterProvider extends AbstractBindingAwareProvider {
     private static final Logger log = LoggerFactory.getLogger(ToasterProvider.class);
 
        private ConsumerContext consumerContext;
@@ -55,17 +56,4 @@ public class ToasterProvider implements BindingAwareProvider, BundleActivator {
        public Collection<? extends ProviderFunctionality> getFunctionality() {
                return Collections.emptySet();
        }
-
-       @Override
-       public void start(BundleContext context) throws Exception {
-               ServiceReference<BindingAwareBroker> brokerRef = context.getServiceReference(BindingAwareBroker.class);
-               BindingAwareBroker broker = context.getService(brokerRef);
-               broker.registerProvider(this, context);
-       }
-
-       @Override
-       public void stop(BundleContext context) throws Exception {
-               
-               
-       }
 }