Add RFC7895 YANG Module Library model 24/71024/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 17 Apr 2018 10:11:57 +0000 (12:11 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Tue, 17 Apr 2018 22:16:48 +0000 (22:16 +0000)
This model is linked to MD-SAL mount points, hence it should really
be provided by MD-SAL.

Change-Id: I4a0c23f8137fd0fff09e6500f27000ff62535fff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
model/artifacts/pom.xml
model/features/odl-mdsal-models/pom.xml
model/ietf/pom.xml
model/ietf/rfc7895/pom.xml [new file with mode: 0644]
model/ietf/rfc7895/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/yang/library/rev160621/RevisionUtils.java [new file with mode: 0644]
model/ietf/rfc7895/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/yang/library/rev160621/module/list/CommonLeafsRevisionBuilder.java [new file with mode: 0644]
model/ietf/rfc7895/src/main/yang/ietf-yang-library@2016-06-21.yang [new file with mode: 0644]

index c0b26215e9c54718c7675617e0310d0863b0fc9e..fbe6128feb4eb12da3349ad9e6c33699db8301e0 100644 (file)
                 <artifactId>ietf-access-control-list</artifactId>
                 <version>0.11.0-SNAPSHOT</version>
             </dependency>
+
+            <dependency>
+                <groupId>org.opendaylight.mdsal.model</groupId>
+                <artifactId>rfc7895</artifactId>
+                <version>1.0.0-SNAPSHOT</version>
+            </dependency>
             <!-- TODO: Sort dependencies alphabetically? -->
         </dependencies>
     </dependencyManagement>
index 6dbdec5ef25f11d520746f79c33ce86e7b7cdd16..0fb9989243191e5f36d4df14e6a2e15b40bfaa1d 100644 (file)
             <groupId>${project.groupId}</groupId>
             <artifactId>ietf-lisp-address-types-2015-11-05</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>rfc7895</artifactId>
+        </dependency>
     </dependencies>
 
     <!--
index 3d18d3760da4eee4b2a7fbde2ffbb3be1e8d5367..59fe6f8270d9c9e680dd0e403e8d77e3c0a5b792 100644 (file)
@@ -46,6 +46,9 @@
 
         <module>ietf-type-util</module>
         <module>ietf-ip-2014-06-16</module>
+
+        <!-- RFC7895 YANG Module Library -->
+        <module>rfc7895</module>
     </modules>
 
   <!--
diff --git a/model/ietf/rfc7895/pom.xml b/model/ietf/rfc7895/pom.xml
new file mode 100644 (file)
index 0000000..b21ef5c
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+* Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
+*
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0 which accompanies this distribution,
+* and is available at http://www.eclipse.org/legal/epl-v10.html
+*/
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.mdsal</groupId>
+        <artifactId>binding-parent</artifactId>
+        <version>0.13.0-SNAPSHOT</version>
+        <relativePath>../../../binding/binding-parent</relativePath>
+    </parent>
+
+    <groupId>org.opendaylight.mdsal.model</groupId>
+    <artifactId>rfc7895</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>${project.artifactId}</name>
+    <description>YANG Module Library model</description>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>ietf-inet-types-2013-07-15</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>ietf-yang-types-20130715</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/model/ietf/rfc7895/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/yang/library/rev160621/RevisionUtils.java b/model/ietf/rfc7895/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/yang/library/rev160621/RevisionUtils.java
new file mode 100644 (file)
index 0000000..f5a2a8e
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621;
+
+import com.google.common.annotations.Beta;
+import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision;
+
+/**
+ * Utility methods for working with {@link Revision}s.
+ *
+ * @author Robert Varga
+ */
+@Beta
+@NonNullByDefault
+public final class RevisionUtils {
+    private static final Revision EMPTY_REVISION = new Revision("");
+
+    private RevisionUtils() {
+
+    }
+
+    /**
+     * Return an empty {@link Revision}.
+     *
+     * @return An empty Revision.
+     */
+    public static Revision emptyRevision() {
+        return EMPTY_REVISION;
+    }
+
+    /**
+     * Create a {@link Revision} from an optional {@link org.opendaylight.yangtools.yang.common.Revision}.
+     *
+     * @param revision Optional {@link org.opendaylight.yangtools.yang.common.Revision}
+     * @return A Revision
+     * @throws NullPointerException if revision is null
+     */
+    public static Revision fromYangCommon(final Optional<org.opendaylight.yangtools.yang.common.Revision> revision) {
+        return revision.map(rev -> new Revision(new RevisionIdentifier(rev.toString()))).orElse(EMPTY_REVISION);
+    }
+
+    /**
+     * Create an optional {@link org.opendaylight.yangtools.yang.common.Revision} from a {@link Revision}.
+     *
+     * @param revision A Revision
+     * @return Optional {@link org.opendaylight.yangtools.yang.common.Revision}
+     * @throws NullPointerException if revision is null
+     */
+    public static Optional<org.opendaylight.yangtools.yang.common.Revision> toYangCommon(final Revision revision) {
+        final @Nullable RevisionIdentifier id = revision.getRevisionIdentifier();
+        return id != null ? Optional.of(org.opendaylight.yangtools.yang.common.Revision.of(id.getValue()))
+                : Optional.empty();
+    }
+}
diff --git a/model/ietf/rfc7895/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/yang/library/rev160621/module/list/CommonLeafsRevisionBuilder.java b/model/ietf/rfc7895/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/yang/library/rev160621/module/list/CommonLeafsRevisionBuilder.java
new file mode 100644 (file)
index 0000000..d4edd20
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision;
+
+public final class CommonLeafsRevisionBuilder {
+    private CommonLeafsRevisionBuilder() {
+
+    }
+
+    public static Revision getDefaultInstance(final String defaultValue) {
+        return defaultValue.isEmpty() ? RevisionUtils.emptyRevision()
+                : new Revision(new RevisionIdentifier(defaultValue));
+    }
+
+}
diff --git a/model/ietf/rfc7895/src/main/yang/ietf-yang-library@2016-06-21.yang b/model/ietf/rfc7895/src/main/yang/ietf-yang-library@2016-06-21.yang
new file mode 100644 (file)
index 0000000..e6221a6
--- /dev/null
@@ -0,0 +1,244 @@
+module ietf-yang-library {
+  namespace "urn:ietf:params:xml:ns:yang:ietf-yang-library";
+  prefix "yanglib";
+
+  import ietf-yang-types {
+    prefix yang;
+  }
+  import ietf-inet-types {
+    prefix inet;
+  }
+
+  organization
+    "IETF NETCONF (Network Configuration) Working Group";
+
+  contact
+    "WG Web:   <https://datatracker.ietf.org/wg/netconf/>
+     WG List:  <mailto:netconf@ietf.org>
+
+     WG Chair: Mehmet Ersue
+               <mailto:mehmet.ersue@nsn.com>
+
+     WG Chair: Mahesh Jethanandani
+               <mailto:mjethanandani@gmail.com>
+
+     Editor:   Andy Bierman
+               <mailto:andy@yumaworks.com>
+
+     Editor:   Martin Bjorklund
+               <mailto:mbj@tail-f.com>
+
+     Editor:   Kent Watsen
+               <mailto:kwatsen@juniper.net>";
+
+  description
+    "This module contains monitoring information about the YANG
+     modules and submodules that are used within a YANG-based
+     server.
+
+     Copyright (c) 2016 IETF Trust and the persons identified as
+     authors of the code.  All rights reserved.
+
+     Redistribution and use in source and binary forms, with or
+     without modification, is permitted pursuant to, and subject
+     to the license terms contained in, the Simplified BSD License
+     set forth in Section 4.c of the IETF Trust's Legal Provisions
+     Relating to IETF Documents
+     (http://trustee.ietf.org/license-info).
+
+     This version of this YANG module is part of RFC 7895; see
+     the RFC itself for full legal notices.";
+
+  revision 2016-06-21 {
+    description
+      "Initial revision.";
+    reference
+      "RFC 7895: YANG Module Library.";
+  }
+
+  /*
+   * Typedefs
+   */
+
+  typedef revision-identifier {
+    type string {
+      pattern '\d{4}-\d{2}-\d{2}';
+    }
+    description
+      "Represents a specific date in YYYY-MM-DD format.";
+  }
+
+  /*
+   * Groupings
+   */
+
+  grouping module-list {
+    description
+      "The module data structure is represented as a grouping
+       so it can be reused in configuration or another monitoring
+       data structure.";
+
+    grouping common-leafs {
+      description
+        "Common parameters for YANG modules and submodules.";
+
+      leaf name {
+        type yang:yang-identifier;
+        description
+          "The YANG module or submodule name.";
+      }
+      leaf revision {
+        type union {
+          type revision-identifier;
+          type string { length 0; }
+        }
+        description
+          "The YANG module or submodule revision date.
+           A zero-length string is used if no revision statement
+           is present in the YANG module or submodule.";
+      }
+    }
+
+    grouping schema-leaf {
+      description
+        "Common schema leaf parameter for modules and submodules.";
+
+      leaf schema {
+        type inet:uri;
+        description
+          "Contains a URL that represents the YANG schema
+           resource for this module or submodule.
+
+           This leaf will only be present if there is a URL
+           available for retrieval of the schema for this entry.";
+      }
+    }
+
+    list module {
+      key "name revision";
+      description
+        "Each entry represents one revision of one module
+         currently supported by the server.";
+
+      uses common-leafs;
+      uses schema-leaf;
+
+      leaf namespace {
+        type inet:uri;
+        mandatory true;
+        description
+          "The XML namespace identifier for this module.";
+      }
+      leaf-list feature {
+        type yang:yang-identifier;
+        description
+          "List of YANG feature names from this module that are
+           supported by the server, regardless of whether they are
+           defined in the module or any included submodule.";
+      }
+      list deviation {
+        key "name revision";
+        description
+          "List of YANG deviation module names and revisions
+           used by this server to modify the conformance of
+           the module associated with this entry.  Note that
+           the same module can be used for deviations for
+           multiple modules, so the same entry MAY appear
+           within multiple 'module' entries.
+
+           The deviation module MUST be present in the 'module'
+           list, with the same name and revision values.
+           The 'conformance-type' value will be 'implement' for
+           the deviation module.";
+        uses common-leafs;
+      }
+      leaf conformance-type {
+        type enumeration {
+          enum implement {
+            description
+              "Indicates that the server implements one or more
+               protocol-accessible objects defined in the YANG module
+               identified in this entry.  This includes deviation
+               statements defined in the module.
+
+               For YANG version 1.1 modules, there is at most one
+               module entry with conformance type 'implement' for a
+               particular module name, since YANG 1.1 requires that,
+               at most, one revision of a module is implemented.
+
+               For YANG version 1 modules, there SHOULD NOT be more
+               than one module entry for a particular module name.";
+          }
+          enum import {
+            description
+              "Indicates that the server imports reusable definitions
+               from the specified revision of the module but does
+               not implement any protocol-accessible objects from
+               this revision.
+
+               Multiple module entries for the same module name MAY
+               exist.  This can occur if multiple modules import the
+               same module but specify different revision dates in
+               the import statements.";
+          }
+        }
+        mandatory true;
+        description
+          "Indicates the type of conformance the server is claiming
+           for the YANG module identified by this entry.";
+      }
+      list submodule {
+        key "name revision";
+        description
+          "Each entry represents one submodule within the
+           parent module.";
+        uses common-leafs;
+        uses schema-leaf;
+      }
+    }
+  }
+
+  /*
+   * Operational state data nodes
+   */
+
+  container modules-state {
+    config false;
+    description
+      "Contains YANG module monitoring information.";
+
+    leaf module-set-id {
+      type string;
+      mandatory true;
+      description
+        "Contains a server-specific identifier representing
+         the current set of modules and submodules.  The
+         server MUST change the value of this leaf if the
+         information represented by the 'module' list instances
+         has changed.";
+    }
+
+    uses module-list;
+  }
+
+  /*
+   * Notifications
+   */
+
+  notification yang-library-change {
+    description
+      "Generated when the set of modules and submodules supported
+       by the server has changed.";
+    leaf module-set-id {
+      type leafref {
+        path "/yanglib:modules-state/yanglib:module-set-id";
+      }
+      mandatory true;
+      description
+        "Contains the module-set-id value representing the
+         set of modules and submodules supported at the server at
+         the time the notification is generated.";
+    }
+  }
+
+}