<artifactId>mdsal-yanglib-api</artifactId>
<version>0.14.0-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-yanglib-rfc7895</artifactId>
- <version>0.14.0-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-yanglib-rfc8525</artifactId>
<classifier>features</classifier>
<type>xml</type>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-mdsal-exp-yanglib-rfc7895</artifactId>
- <version>0.14.0-SNAPSHOT</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-mdsal-exp-yanglib-rfc8525</artifactId>
<version>9.0.0-SNAPSHOT</version>
</dependency>
- <!-- RFC7895 -->
- <!-- FIXME: upgrade this to RFC8525 (2019-01-04, NMDA) -->
- <dependency>
- <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc7895</artifactId>
- <version>9.0.0-SNAPSHOT</version>
- </dependency>
-
<!-- RFC7952 -->
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<classifier>features</classifier>
<type>xml</type>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>odl-mdsal-model-rfc7895</artifactId>
- <version>9.0.0-SNAPSHOT</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>odl-mdsal-model-rfc7952</artifactId>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-yanglib-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-yanglib-rfc7895</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-yanglib-rfc8525</artifactId>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>ietf-type-util</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc7895</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc7952</artifactId>
<classifier>features</classifier>
<type>xml</type>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>odl-mdsal-exp-yanglib-rfc7895</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>odl-mdsal-exp-yanglib-rfc8525</artifactId>
<classifier>features</classifier>
<type>xml</type>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>odl-mdsal-model-rfc7895</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>odl-mdsal-model-rfc7952</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2019 PANTHEON.tech, 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
- -->
-<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>feature-parent</artifactId>
- <version>9.0.0-SNAPSHOT</version>
- <relativePath>../feature-parent</relativePath>
- </parent>
-
- <artifactId>odl-mdsal-exp-yanglib-rfc7895</artifactId>
- <version>0.14.0-SNAPSHOT</version>
- <packaging>feature</packaging>
- <name>OpenDaylight :: MD-SAL :: RFC7895 YANG Module Library</name>
- <description>MD-SAL YANG Module Library (RFC7895)</description>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>odl-mdsal-exp-yanglib-api</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>odl-mdsal-model-rfc7895</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>odl-mdsal-binding-runtime</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-yanglib-rfc7895</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 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
- -->
-<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>feature-parent</artifactId>
- <version>9.0.0-SNAPSHOT</version>
- <relativePath>../feature-parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>odl-mdsal-model-rfc7895</artifactId>
- <version>9.0.0-SNAPSHOT</version>
- <packaging>feature</packaging>
- <name>OpenDaylight :: MD-SAL :: Model :: RFC7895</name>
- <description>Models from RFC7895</description>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>odl-mdsal-model-rfc6991</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc7895</artifactId>
- </dependency>
- </dependencies>
-</project>
<!-- YANG (Module) Library -->
<module>odl-mdsal-exp-yanglib-api</module>
- <module>odl-mdsal-exp-yanglib-rfc7895</module>
<module>odl-mdsal-exp-yanglib-rfc8525</module>
<!-- Netty/Routing Types integration -->
<!-- Standards -->
<module>odl-mdsal-model-rfc6991</module>
<module>odl-mdsal-model-rfc7224</module>
- <module>odl-mdsal-model-rfc7895</module>
<module>odl-mdsal-model-rfc7952</module>
<module>odl-mdsal-model-rfc8294</module>
<module>odl-mdsal-model-rfc8342</module>
<module>rfc6991-ietf-yang-types</module>
<module>ietf-type-util</module>
- <!-- RFC7895 YANG Module Library -->
- <!-- FIXME: superseded by RFC8525 -->
- <module>rfc7895</module>
-
- <!-- RFC7895 YANG Metadata -->
+ <!-- RFC7952 YANG Metadata -->
<module>rfc7952</module>
<!-- RFC8294 Common YANG Data Types for the Routing Area -->
+++ /dev/null
-<?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>9.0.0-SNAPSHOT</version>
- <relativePath>../../../binding/binding-parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc7895</artifactId>
- <version>9.0.0-SNAPSHOT</version>
- <name>${project.artifactId}</name>
- <description>YANG Module Library (pre-NMDA) model</description>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc6991</artifactId>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-/*
- * 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();
- }
-}
+++ /dev/null
-/*
- * 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));
- }
-}
+++ /dev/null
-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.";
- }
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2019 PANTHEON.tech, 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
--->
-<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>dom-parent</artifactId>
- <version>9.0.0-SNAPSHOT</version>
- <relativePath>../../dom/dom-parent</relativePath>
- </parent>
-
- <artifactId>mdsal-yanglib-rfc7895</artifactId>
- <version>0.14.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-yanglib-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc7895</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-runtime-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-runtime-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-codec-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.kohsuke.metainf-services</groupId>
- <artifactId>metainf-services</artifactId>
- </dependency>
- <dependency>
- <groupId>com.guicedee.services</groupId>
- <artifactId>javax.inject</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-codec</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-generator</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Automatic-Module-Name>org.opendaylight.mdsal.yanglib.rfc7895</Automatic-Module-Name>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/mdsal.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/mdsal.git</developerConnection>
- <url>https://wiki.opendaylight.org/view/MD-SAL:Main</url>
- <tag>HEAD</tag>
- </scm>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2019 PANTHEON.tech 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.mdsal.yanglib.rfc7895;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Verify.verifyNotNull;
-import static java.util.Objects.requireNonNull;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
-import org.opendaylight.mdsal.yanglib.api.SchemaContextResolver;
-import org.opendaylight.mdsal.yanglib.api.SourceReference;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesState;
-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;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.Module;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.Module.ConformanceType;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.module.Submodule;
-import org.opendaylight.yangtools.rfc8528.data.api.MountPointContextFactory;
-import org.opendaylight.yangtools.rfc8528.data.api.MountPointIdentifier;
-import org.opendaylight.yangtools.rfc8528.data.api.YangLibraryConstants.ContainerName;
-import org.opendaylight.yangtools.rfc8528.data.util.AbstractMountPointContextFactory;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.XMLNamespace;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.parser.api.YangParserException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class MountPointContextFactoryImpl extends AbstractMountPointContextFactory {
- private static final Logger LOG = LoggerFactory.getLogger(MountPointContextFactoryImpl.class);
-
- private final BindingDataObjectCodecTreeNode<ModulesState> codec;
- private final EffectiveModelContext yangLibContext;
- private final SchemaContextResolver resolver;
-
- MountPointContextFactoryImpl(final MountPointIdentifier mountId, final SchemaContextResolver resolver,
- final EffectiveModelContext yangLibContext,
- final BindingDataObjectCodecTreeNode<ModulesState> moduleStateCodec) {
- super(mountId);
- this.resolver = requireNonNull(resolver);
- this.yangLibContext = requireNonNull(yangLibContext);
- codec = requireNonNull(moduleStateCodec);
- }
-
- @Override
- protected MountPointContextFactory createContextFactory(final MountPointDefinition mountPoint) {
- return new MountPointContextFactoryImpl(mountPoint.getIdentifier(), resolver, yangLibContext, codec);
- }
-
- @Override
- protected Optional<EffectiveModelContext> findSchemaForLibrary(final ContainerName containerName) {
- switch (containerName) {
- case RFC7895:
- return Optional.of(yangLibContext);
- default:
- LOG.debug("Unhandled YANG library container {}", containerName);
- return Optional.empty();
- }
- }
-
- @Override
- protected EffectiveModelContext bindLibrary(final ContainerName containerName, final ContainerNode libData)
- throws YangParserException {
- checkArgument(containerName == ContainerName.RFC7895, "Unsupported container type %s", containerName);
- checkArgument(ModulesState.QNAME.equals(libData.getIdentifier().getNodeType()),
- "Unexpected container %s", libData);
-
- // DOM-to-Binding magic
- return bindLibrary(verifyNotNull(codec.deserialize(libData)));
- }
-
- private @NonNull EffectiveModelContext bindLibrary(final @NonNull ModulesState modState)
- throws YangParserException {
- final List<SourceReference> requiredSources = new ArrayList<>();
- final List<SourceReference> librarySources = new ArrayList<>();
- final Set<QName> supportedFeatures = new HashSet<>();
-
- for (Module module : modState.nonnullModule().values()) {
- final SourceReference modRef = sourceRefFor(module, module.getSchema());
- final var namespace = XMLNamespace.of(module.requireNamespace().getValue());
- for (var feature : module.requireFeature()) {
- supportedFeatures.add(QName.create(namespace, feature.getValue()).intern());
- }
-
- // TODO: take deviations into account
-
- if (ConformanceType.Import == module.getConformanceType()) {
- librarySources.add(modRef);
- } else {
- requiredSources.add(modRef);
- }
-
- for (Submodule submodule : module.nonnullSubmodule().values()) {
- // Submodules go to library, as they are pulled in as needed
- librarySources.add(sourceRefFor(submodule, submodule.getSchema()));
- }
- }
-
- return resolver.resolveSchemaContext(librarySources, requiredSources, supportedFeatures);
- }
-
- private static SourceReference sourceRefFor(final CommonLeafs obj, final Uri uri) {
- final SourceIdentifier sourceId = RevisionSourceIdentifier.create(obj.getName().getValue(),
- RevisionUtils.toYangCommon(obj.getRevision()));
- if (uri != null) {
- try {
- return SourceReference.of(sourceId, new URL(uri.getValue()));
- } catch (MalformedURLException e) {
- LOG.debug("Ignoring invalid schema location {}", uri, e);
- }
- }
-
- return SourceReference.of(sourceId);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2020 PANTHEON.tech 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.mdsal.yanglib.rfc7895;
-
-import static com.google.common.base.Verify.verifyNotNull;
-
-import com.google.common.annotations.VisibleForTesting;
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
-import org.opendaylight.mdsal.yanglib.api.YangLibraryContentBuilder;
-import org.opendaylight.mdsal.yanglib.api.YangLibraryContentBuilderWithLegacy;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesState;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesStateBuilder;
-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.module.list.CommonLeafs;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.Module;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.module.Submodule;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.module.SubmoduleBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.module.SubmoduleKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.data.api.DatastoreIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-
-class Rfc7895ContentBuilder implements YangLibraryContentBuilderWithLegacy {
- private static final CommonLeafs.Revision EMPTY_REV = new CommonLeafs.Revision("");
-
- private final BindingDataObjectCodecTreeNode<ModulesState> legacyCodec;
-
- private EffectiveModelContext context;
-
- Rfc7895ContentBuilder(final BindingCodecTree codecTree) {
- this.legacyCodec = verifyNotNull(codecTree.getSubtreeCodec(InstanceIdentifier.create(ModulesState.class)));
- }
-
- @Override
- public Rfc7895ContentBuilder defaultContext(final EffectiveModelContext modelContext) {
- this.context = modelContext;
- return this;
- }
-
- @Override
- public YangLibraryContentBuilder addDatastore(final DatastoreIdentifier identifier,
- final EffectiveModelContext newContext) {
- // NOOP does not apply for rfc7895
- return this;
- }
-
- @Override
- public YangLibraryContentBuilderWithLegacy includeLegacy() {
- // NOOP does not apply for rfc7895
- return this;
- }
-
- @Override
- public ContainerNode formatYangLibraryContent() {
- return formatModulesState(context);
- }
-
- @VisibleForTesting
- ContainerNode formatModulesState(final EffectiveModelContext effectiveModelContext) {
- Map<SubmoduleKey, Submodule> vals;
- // Two-step process: we first build the content and then use hashCode() to generate module-set-id
- final ModulesStateBuilder builder = new ModulesStateBuilder().setModuleSetId("")
- .setModule(effectiveModelContext.getModules().stream()
- .map(module -> new ModuleBuilder()
- .setName(new YangIdentifier(module.getName()))
- .setNamespace(new Uri(module.getNamespace().toString()))
- .setRevision(convertRevision(module.getRevision()))
- .setSubmodule(module.getSubmodules().stream()
- .map(submodule -> new SubmoduleBuilder()
- .setName(new YangIdentifier(submodule.getName()))
- .setRevision(convertRevision(submodule.getRevision()))
- .build())
- .collect(Collectors.toUnmodifiableMap(Submodule::key, Function.identity())))
- .setFeature(module.getFeatures().stream()
- .map(feat -> new YangIdentifier(feat.getQName().getLocalName()))
- .collect(Collectors.toUnmodifiableList()))
- .setConformanceType(Module.ConformanceType.Implement)
- .build())
- .collect(Collectors.toUnmodifiableMap(Module::key, Function.identity())));
-
- return (ContainerNode) legacyCodec.serialize(builder.setModuleSetId(String.valueOf(builder.build().hashCode()))
- .build());
- }
-
- private static CommonLeafs.Revision convertRevision(final Optional<Revision> revision) {
- return revision.map(rev -> new CommonLeafs.Revision(new RevisionIdentifier(rev.toString()))).orElse(EMPTY_REV);
- }
-
- @Override
- public Optional<ContainerNode> formatYangLibraryLegacyContent() {
- return Optional.of(formatYangLibraryContent());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2019 PANTHEON.tech 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.mdsal.yanglib.rfc7895;
-
-import static com.google.common.base.Verify.verifyNotNull;
-
-import com.google.common.annotations.Beta;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
-import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator;
-import org.opendaylight.mdsal.binding.runtime.api.DefaultBindingRuntimeContext;
-import org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot;
-import org.opendaylight.mdsal.binding.runtime.spi.ModuleInfoSnapshotBuilder;
-import org.opendaylight.mdsal.yanglib.api.SchemaContextResolver;
-import org.opendaylight.mdsal.yanglib.api.YangLibSupport;
-import org.opendaylight.mdsal.yanglib.api.YangLibraryContentBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesState;
-import org.opendaylight.yangtools.rfc8528.data.api.MountPointContextFactory;
-import org.opendaylight.yangtools.rfc8528.data.api.MountPointIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.parser.api.YangParserException;
-import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-
-@Beta
-@NonNullByDefault
-@Singleton
-@Component(immediate = true)
-public final class YangModuleLibrarySupport implements YangLibSupport {
- private static final Revision REVISION = ModulesState.QNAME.getRevision().orElseThrow();
-
- private final BindingDataObjectCodecTreeNode<ModulesState> codec;
- private final EffectiveModelContext context;
- private final BindingCodecTree codecTree;
-
- @Inject
- @Activate
- public YangModuleLibrarySupport(@Reference final YangParserFactory parserFactory,
- @Reference final BindingRuntimeGenerator generator, @Reference final BindingCodecTreeFactory codecFactory)
- throws YangParserException {
- final ModuleInfoSnapshot snapshot = new ModuleInfoSnapshotBuilder(parserFactory)
- .add(ModulesState.class)
- .build();
- context = snapshot.getEffectiveModelContext();
-
- codecTree = codecFactory.create(new DefaultBindingRuntimeContext(
- generator.generateTypeMapping(context), snapshot));
-
- this.codec = verifyNotNull(codecTree.getSubtreeCodec(InstanceIdentifier.create(ModulesState.class)));
- }
-
- @Override
- public MountPointContextFactory createMountPointContextFactory(final MountPointIdentifier mountId,
- final SchemaContextResolver resolver) {
- return new MountPointContextFactoryImpl(mountId, resolver, context, codec);
- }
-
- @Override
- public Revision implementedRevision() {
- return REVISION;
- }
-
- @Override
- public YangLibraryContentBuilder newContentBuilder() {
- return new Rfc7895ContentBuilder(codecTree);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2019 PANTHEON.tech 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.mdsal.yanglib.rfc7895;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import java.util.ServiceLoader;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.kohsuke.MetaInfServices;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory;
-import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator;
-import org.opendaylight.mdsal.yanglib.api.YangLibSupport;
-import org.opendaylight.mdsal.yanglib.api.YangLibSupportFactory;
-import org.opendaylight.yangtools.yang.parser.api.YangParserException;
-import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
-
-@Beta
-@MetaInfServices
-@NonNullByDefault
-public final class YangModuleLibrarySupportFactory implements YangLibSupportFactory {
- private final BindingCodecTreeFactory codecFactory;
- private final BindingRuntimeGenerator generator;
-
- public YangModuleLibrarySupportFactory() {
- this(load(BindingRuntimeGenerator.class), load(BindingCodecTreeFactory.class));
- }
-
- public YangModuleLibrarySupportFactory(final BindingRuntimeGenerator generator,
- final BindingCodecTreeFactory codecFactory) {
- this.generator = requireNonNull(generator);
- this.codecFactory = requireNonNull(codecFactory);
- }
-
- @Override
- public YangLibSupport createYangLibSupport(final YangParserFactory parserFactory) throws YangParserException {
- return new YangModuleLibrarySupport(parserFactory, generator, codecFactory);
- }
-
- private static <T> T load(final Class<T> clazz) {
- return ServiceLoader.load(clazz).findFirst()
- .orElseThrow(() -> new IllegalStateException("Failed to find a " + clazz.getSimpleName() + " service"));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2020 PANTHEON.tech 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.mdsal.yanglib.rfc7895;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Collections;
-import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
-import org.opendaylight.mdsal.binding.dom.codec.impl.DefaultBindingCodecTreeFactory;
-import org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator;
-import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
-import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator;
-import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesState;
-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.module.list.CommonLeafs.Revision;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.Module;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.Module.ConformanceType;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.parser.api.YangParserException;
-import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
-import org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory;
-
-public class YangModuleLibrarySupportTest {
-
- private static final BindingRuntimeGenerator BINDING_RUNTIME_GENERATOR = new DefaultBindingRuntimeGenerator();
-
- private static final YangParserFactory YANG_PARSER_FACTORY = new DefaultYangParserFactory();
-
- private BindingRuntimeContext runtimeContext;
- private BindingCodecTree codecTree;
- private YangModuleLibrarySupport yangLib;
-
- @Before
- public void setUp() throws YangParserException {
- runtimeContext = BindingRuntimeHelpers.createRuntimeContext();
- final DefaultBindingCodecTreeFactory codecFactory = new DefaultBindingCodecTreeFactory();
- codecTree = codecFactory.create(runtimeContext);
-
- yangLib = new YangModuleLibrarySupport(YANG_PARSER_FACTORY, BINDING_RUNTIME_GENERATOR, codecFactory);
- }
-
- @Test
- public void testModulesState() {
- final BindingDataObjectCodecTreeNode<ModulesState> legacyCodec =
- codecTree.getSubtreeCodec(InstanceIdentifier.create(ModulesState.class));
- final ModulesState modulesState = legacyCodec.deserialize(
- yangLib.newContentBuilder().defaultContext(
- runtimeContext.getEffectiveModelContext()).formatYangLibraryContent());
-
- assertEquals(3, modulesState.nonnullModule().size());
- assertEquals(createControlModules(), modulesState.getModule());
- }
-
- private static Map<ModuleKey, Module> createControlModules() {
- return Map.of(
- new ModuleKey(new YangIdentifier("ietf-yang-library"), new Revision(new RevisionIdentifier("2016-06-21"))),
- createModule("ietf-yang-library", "urn:ietf:params:xml:ns:yang:ietf-yang-library", "2016-06-21"),
- new ModuleKey(new YangIdentifier("ietf-inet-types"), new Revision(new RevisionIdentifier("2013-07-15"))),
- createModule("ietf-inet-types", "urn:ietf:params:xml:ns:yang:ietf-inet-types", "2013-07-15"),
- new ModuleKey(new YangIdentifier("ietf-yang-types"), new Revision(new RevisionIdentifier("2013-07-15"))),
- createModule("ietf-yang-types", "urn:ietf:params:xml:ns:yang:ietf-yang-types", "2013-07-15"));
- }
-
- private static Module createModule(final String name, final String namespace, final String revision) {
- return new ModuleBuilder()
- .setName(new YangIdentifier(name))
- .setNamespace(new Uri(namespace))
- .setRevision(new Revision(new RevisionIdentifier(revision)))
- .setConformanceType(ConformanceType.Implement)
- .setFeature(Collections.emptyList())
- .build();
- }
-}
\ No newline at end of file
<modules>
<module>mdsal-yanglib-api</module>
- <module>mdsal-yanglib-rfc7895</module>
<module>mdsal-yanglib-rfc8525</module>
</modules>