Added YANG extensions module 80/580/2
authorTony Tkacik <ttkacik@cisco.com>
Tue, 9 Jul 2013 15:22:53 +0000 (17:22 +0200)
committerMartin Vitez <mvitez@cisco.com>
Thu, 11 Jul 2013 11:10:10 +0000 (13:10 +0200)
  - Added YANG extensions module which defines
    - Context-aware RPCs
    - Named Augmentations

Change-Id: I7b6cb7f579c519dfa726f966df466ad6c9e6aee1
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
opendaylight/sal/yang-prototype/yang/pom.xml
opendaylight/sal/yang-prototype/yang/yang-ext/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/yang/yang-ext/src/main/yang/yang-ext.yang [new file with mode: 0644]

index 3076a6fd679fdbc75509dd6dd4036bbf2f10be01..b9627a5a07b0f7fc747ac06a1190dd9a01c1002b 100644 (file)
@@ -1,34 +1,35 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 <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>yang-prototype</artifactId>
-               <version>0.5-SNAPSHOT</version>
-       </parent>
-       <version>0.5.3-SNAPSHOT</version>
-       <artifactId>yang</artifactId>
-       <packaging>pom</packaging>
+    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>yang-prototype</artifactId>
+        <version>0.5-SNAPSHOT</version>
+    </parent>
+    <version>0.5.3-SNAPSHOT</version>
+    <artifactId>yang</artifactId>
+    <packaging>pom</packaging>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <!-- Version of all child artifacts -->
     </properties>
 
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <!-- Version of all child artifacts -->
     </properties>
 
-       <modules>
-               <module>yang-common</module>
-               <module>yang-data-api</module>
-               <module>yang-data-util</module>
+    <modules>
+        <module>yang-common</module>
+        <module>yang-data-api</module>
+        <module>yang-data-util</module>
                <module>yang-data-impl</module>
                <module>yang-data-impl</module>
-               <module>yang-model-api</module>
-               <module>yang-model-util</module>
-               <module>yang-binding</module>
-               <module>../code-generator/yang-model-parser-api</module>
-               <module>../code-generator/yang-model-parser-impl</module>
-               <module>../code-generator/maven-yang</module>
-               <module>../code-generator/maven-yang-plugin</module>
-               <module>../code-generator/maven-yang-plugin-it</module>
-       </modules>
+        <module>yang-model-api</module>
+        <module>yang-model-util</module>
+        <module>yang-binding</module>
+        <module>yang-ext</module>
+        <module>../code-generator/yang-model-parser-api</module>
+        <module>../code-generator/yang-model-parser-impl</module>
+        <module>../code-generator/maven-yang</module>
+        <module>../code-generator/maven-yang-plugin</module>
+        <module>../code-generator/maven-yang-plugin-it</module>
+    </modules>
 
     <dependencyManagement>
         <dependencies>
 
     <dependencyManagement>
         <dependencies>
         </dependencies>
     </dependencyManagement>
 
         </dependencies>
     </dependencyManagement>
 
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-compiler-plugin</artifactId>
-                               <version>2.0</version>
-                               <inherited>true</inherited>
-                               <configuration>
-                                       <source>1.7</source>
-                                       <target>1.7</target>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-javadoc-plugin</artifactId>
-                               <version>2.8.1</version>
-                               <configuration>
-                                       <stylesheet>maven</stylesheet>
-                               </configuration>
-                               <executions>
-                                       <execution>
-                                               <goals>
-                                                       <goal>aggregate</goal>
-                                               </goals>
-                                               <phase>site</phase>
-                                       </execution>
-                               </executions>
-                       </plugin>
-               </plugins>
-       </build>
-       <reporting>
-               <plugins>
-                       <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>findbugs-maven-plugin</artifactId>
-                               <version>2.4.0</version>
-                               <configuration>
-                                       <effort>Max</effort>
-                                       <threshold>Low</threshold>
-                                       <goal>site</goal>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>jdepend-maven-plugin</artifactId>
-                               <version>2.0-beta-2</version>
-                       </plugin>
-               </plugins>
-       </reporting>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.0</version>
+                <inherited>true</inherited>
+                <configuration>
+                    <source>1.7</source>
+                    <target>1.7</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.8.1</version>
+                <configuration>
+                    <stylesheet>maven</stylesheet>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>aggregate</goal>
+                        </goals>
+                        <phase>site</phase>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <version>2.4.0</version>
+                <configuration>
+                    <effort>Max</effort>
+                    <threshold>Low</threshold>
+                    <goal>site</goal>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>jdepend-maven-plugin</artifactId>
+                <version>2.0-beta-2</version>
+            </plugin>
+        </plugins>
+    </reporting>
 </project>
 </project>
diff --git a/opendaylight/sal/yang-prototype/yang/yang-ext/pom.xml b/opendaylight/sal/yang-prototype/yang/yang-ext/pom.xml
new file mode 100644 (file)
index 0000000..16cd65d
--- /dev/null
@@ -0,0 +1,100 @@
+<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>yang</artifactId>
+        <version>0.5.3-SNAPSHOT</version>
+    </parent>
+    <artifactId>yang-ext</artifactId>
+    <version>2013.09.07-SNAPSHOT</version>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.opendaylight.controller</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5.3-SNAPSHOT</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <yangFilesRootDir>src/main/yang</yangFilesRootDir>
+                            <codeGenerators>
+                            </codeGenerators>
+                            <inspectDependencies>false</inspectDependencies>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.opendaylight.controller</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>0.5.3-SNAPSHOT</version>
+                        <type>jar</type>
+                    </dependency>
+                </dependencies>
+            </plugin>
+        </plugins>
+
+        <pluginManagement>
+            <plugins>
+
+                <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>
+                <!--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.controller
+                                        </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>
+</project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/yang/yang-ext/src/main/yang/yang-ext.yang b/opendaylight/sal/yang-prototype/yang/yang-ext/src/main/yang/yang-ext.yang
new file mode 100644 (file)
index 0000000..22aa48a
--- /dev/null
@@ -0,0 +1,60 @@
+module yang-ext {
+    yang-version 1;
+    namespace "urn:opendaylight:params:ns:yang:extension:yang-ext";
+    prefix "ext";
+    
+    contact "Anton Tkacik <ttkacik@cisco.com>";
+
+    revision "2013-07-09" {
+        description "";
+    }
+
+    // Augmentation name
+
+    extension "augment-identifier" {
+        description 
+           "YANG language extension which assigns an identifier to 
+            augmentation. Augment identifier is used to identify
+            specific augment statement by name. 
+
+            The identifier syntax is defined formally defined by the rule
+            'identifier' in Section 12 of RFC 6020.
+
+            All augment identifiers defined in a namespace MUST be unique.
+            The namespace of augment identifiers is shared by module and
+            its submodules. 
+            ";
+            /*
+                Discussion:
+                This extension allows for ease of development / debug
+                of YANG modules and it is suitable for code generation,
+                where each augment statement is nicely identified by
+                unique name instead of combination of augment target
+                and when condition. 
+            */
+        argument "identifier";
+    }
+
+
+    // Context-aware RPCs
+
+    grouping rpc-context-ref {
+        description 
+           "A reference to RPC context.";
+        leaf context-instance {
+            type instance-identifier;
+            description "Pointer to the context. ";
+        }
+    }
+
+    extension "rpc-context-instance" {
+        description
+           "YANG language extension which defines enclosing (parent) 
+            schema node as referencable context for RPCs.
+
+            The argument is identity which is used to identify RPC context
+            type.";
+
+        argument "context-type";
+    }
+}
\ No newline at end of file