From ca5968bd58ad61c90b23436f78788af50b27d4a1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 3 Feb 2022 10:13:40 +0100 Subject: [PATCH] Remove rfc7895 ietf-yang-library We have a replacement revision in rfc8525 which we support equally well. Remove modules and yanglib implementation based on the old revision. JIRA: MDSAL-720 Change-Id: I20b84657876a83895eb35bf18b2878e129eece33 Signed-off-by: Robert Varga --- artifacts/pom.xml | 27 -- docs/pom.xml | 8 - features/features-mdsal-experimental/pom.xml | 6 - features/features-mdsal/pom.xml | 6 - .../odl-mdsal-exp-yanglib-rfc7895/pom.xml | 48 ---- features/odl-mdsal-model-rfc7895/pom.xml | 37 --- features/pom.xml | 2 - model/ietf/pom.xml | 6 +- model/ietf/rfc7895/pom.xml | 35 --- .../yang/library/rev160621/RevisionUtils.java | 62 ----- .../list/CommonLeafsRevisionBuilder.java | 23 -- .../yang/ietf-yang-library@2016-06-21.yang | 244 ------------------ yanglib/mdsal-yanglib-rfc7895/pom.xml | 99 ------- .../rfc7895/MountPointContextFactoryImpl.java | 132 ---------- .../rfc7895/Rfc7895ContentBuilder.java | 108 -------- .../rfc7895/YangModuleLibrarySupport.java | 80 ------ .../YangModuleLibrarySupportFactory.java | 49 ---- .../rfc7895/YangModuleLibrarySupportTest.java | 87 ------- yanglib/pom.xml | 1 - 19 files changed, 1 insertion(+), 1059 deletions(-) delete mode 100644 features/odl-mdsal-exp-yanglib-rfc7895/pom.xml delete mode 100644 features/odl-mdsal-model-rfc7895/pom.xml delete mode 100644 model/ietf/rfc7895/pom.xml delete mode 100644 model/ietf/rfc7895/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/yang/library/rev160621/RevisionUtils.java delete mode 100644 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 delete mode 100644 model/ietf/rfc7895/src/main/yang/ietf-yang-library@2016-06-21.yang delete mode 100644 yanglib/mdsal-yanglib-rfc7895/pom.xml delete mode 100644 yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/MountPointContextFactoryImpl.java delete mode 100644 yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/Rfc7895ContentBuilder.java delete mode 100644 yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupport.java delete mode 100644 yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupportFactory.java delete mode 100644 yanglib/mdsal-yanglib-rfc7895/src/test/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupportTest.java diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 39211c788a..c7b0a16a9b 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -391,11 +391,6 @@ mdsal-yanglib-api 0.14.0-SNAPSHOT - - org.opendaylight.mdsal - mdsal-yanglib-rfc7895 - 0.14.0-SNAPSHOT - org.opendaylight.mdsal mdsal-yanglib-rfc8525 @@ -408,13 +403,6 @@ features xml - - ${project.groupId} - odl-mdsal-exp-yanglib-rfc7895 - 0.14.0-SNAPSHOT - features - xml - ${project.groupId} odl-mdsal-exp-yanglib-rfc8525 @@ -492,14 +480,6 @@ 9.0.0-SNAPSHOT - - - - org.opendaylight.mdsal.binding.model.ietf - rfc7895 - 9.0.0-SNAPSHOT - - org.opendaylight.mdsal.binding.model.ietf @@ -783,13 +763,6 @@ features xml - - org.opendaylight.mdsal.model - odl-mdsal-model-rfc7895 - 9.0.0-SNAPSHOT - features - xml - org.opendaylight.mdsal.model odl-mdsal-model-rfc7952 diff --git a/docs/pom.xml b/docs/pom.xml index c8263bf701..3e10dca1d5 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -191,10 +191,6 @@ org.opendaylight.mdsal mdsal-yanglib-api - - org.opendaylight.mdsal - mdsal-yanglib-rfc7895 - org.opendaylight.mdsal mdsal-yanglib-rfc8525 @@ -234,10 +230,6 @@ org.opendaylight.mdsal.model ietf-type-util - - org.opendaylight.mdsal.binding.model.ietf - rfc7895 - org.opendaylight.mdsal.binding.model.ietf rfc7952 diff --git a/features/features-mdsal-experimental/pom.xml b/features/features-mdsal-experimental/pom.xml index 833146c366..ecd3363de1 100644 --- a/features/features-mdsal-experimental/pom.xml +++ b/features/features-mdsal-experimental/pom.xml @@ -49,12 +49,6 @@ features xml - - org.opendaylight.mdsal - odl-mdsal-exp-yanglib-rfc7895 - features - xml - org.opendaylight.mdsal odl-mdsal-exp-yanglib-rfc8525 diff --git a/features/features-mdsal/pom.xml b/features/features-mdsal/pom.xml index 8b798d32b6..2d154f5f81 100644 --- a/features/features-mdsal/pom.xml +++ b/features/features-mdsal/pom.xml @@ -179,12 +179,6 @@ features xml - - org.opendaylight.mdsal.model - odl-mdsal-model-rfc7895 - features - xml - org.opendaylight.mdsal.model odl-mdsal-model-rfc7952 diff --git a/features/odl-mdsal-exp-yanglib-rfc7895/pom.xml b/features/odl-mdsal-exp-yanglib-rfc7895/pom.xml deleted file mode 100644 index 94eb8ca639..0000000000 --- a/features/odl-mdsal-exp-yanglib-rfc7895/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - 4.0.0 - - org.opendaylight.mdsal - feature-parent - 9.0.0-SNAPSHOT - ../feature-parent - - - odl-mdsal-exp-yanglib-rfc7895 - 0.14.0-SNAPSHOT - feature - OpenDaylight :: MD-SAL :: RFC7895 YANG Module Library - MD-SAL YANG Module Library (RFC7895) - - - - org.opendaylight.mdsal - odl-mdsal-exp-yanglib-api - xml - features - - - org.opendaylight.mdsal.model - odl-mdsal-model-rfc7895 - xml - features - - - org.opendaylight.mdsal - odl-mdsal-binding-runtime - xml - features - - - org.opendaylight.mdsal - mdsal-yanglib-rfc7895 - - - diff --git a/features/odl-mdsal-model-rfc7895/pom.xml b/features/odl-mdsal-model-rfc7895/pom.xml deleted file mode 100644 index 6613f9e6a8..0000000000 --- a/features/odl-mdsal-model-rfc7895/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - 4.0.0 - - org.opendaylight.mdsal - feature-parent - 9.0.0-SNAPSHOT - ../feature-parent - - - org.opendaylight.mdsal.model - odl-mdsal-model-rfc7895 - 9.0.0-SNAPSHOT - feature - OpenDaylight :: MD-SAL :: Model :: RFC7895 - Models from RFC7895 - - - - org.opendaylight.mdsal.model - odl-mdsal-model-rfc6991 - features - xml - - - org.opendaylight.mdsal.binding.model.ietf - rfc7895 - - - diff --git a/features/pom.xml b/features/pom.xml index 56993dd66e..adc06fce88 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -58,7 +58,6 @@ odl-mdsal-exp-yanglib-api - odl-mdsal-exp-yanglib-rfc7895 odl-mdsal-exp-yanglib-rfc8525 @@ -72,7 +71,6 @@ odl-mdsal-model-rfc6991 odl-mdsal-model-rfc7224 - odl-mdsal-model-rfc7895 odl-mdsal-model-rfc7952 odl-mdsal-model-rfc8294 odl-mdsal-model-rfc8342 diff --git a/model/ietf/pom.xml b/model/ietf/pom.xml index 5240c12066..bff2ce55e1 100644 --- a/model/ietf/pom.xml +++ b/model/ietf/pom.xml @@ -31,11 +31,7 @@ rfc6991-ietf-yang-types ietf-type-util - - - rfc7895 - - + rfc7952 diff --git a/model/ietf/rfc7895/pom.xml b/model/ietf/rfc7895/pom.xml deleted file mode 100644 index d33ce04511..0000000000 --- a/model/ietf/rfc7895/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - 4.0.0 - - org.opendaylight.mdsal - binding-parent - 9.0.0-SNAPSHOT - ../../../binding/binding-parent - - - org.opendaylight.mdsal.binding.model.ietf - rfc7895 - 9.0.0-SNAPSHOT - ${project.artifactId} - YANG Module Library (pre-NMDA) model - bundle - - - - org.opendaylight.mdsal.binding.model.ietf - rfc6991 - - - - 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 deleted file mode 100644 index f5a2a8e5b6..0000000000 --- a/model/ietf/rfc7895/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/yang/library/rev160621/RevisionUtils.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 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 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 deleted file mode 100644 index 17f35f2a5b..0000000000 --- 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 +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 deleted file mode 100644 index e6221a60a2..0000000000 --- a/model/ietf/rfc7895/src/main/yang/ietf-yang-library@2016-06-21.yang +++ /dev/null @@ -1,244 +0,0 @@ -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: - WG List: - - WG Chair: Mehmet Ersue - - - WG Chair: Mahesh Jethanandani - - - Editor: Andy Bierman - - - Editor: Martin Bjorklund - - - Editor: Kent Watsen - "; - - 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."; - } - } - -} diff --git a/yanglib/mdsal-yanglib-rfc7895/pom.xml b/yanglib/mdsal-yanglib-rfc7895/pom.xml deleted file mode 100644 index 122ecfb9e9..0000000000 --- a/yanglib/mdsal-yanglib-rfc7895/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - 4.0.0 - - org.opendaylight.mdsal - dom-parent - 9.0.0-SNAPSHOT - ../../dom/dom-parent - - - mdsal-yanglib-rfc7895 - 0.14.0-SNAPSHOT - bundle - - - - org.opendaylight.mdsal - mdsal-yanglib-api - - - org.opendaylight.mdsal.binding.model.ietf - rfc7895 - - - org.opendaylight.yangtools - yang-parser-api - - - org.opendaylight.mdsal - mdsal-binding-runtime-api - - - org.opendaylight.mdsal - mdsal-binding-runtime-spi - - - org.opendaylight.mdsal - mdsal-binding-dom-codec-api - - - org.kohsuke.metainf-services - metainf-services - - - com.guicedee.services - javax.inject - true - - - org.osgi - osgi.cmpn - - - - org.opendaylight.yangtools - yang-parser-impl - test - - - org.opendaylight.mdsal - mdsal-binding-dom-codec - test - - - org.opendaylight.mdsal - mdsal-binding-generator - test - - - - - - - org.apache.felix - maven-bundle-plugin - - - org.opendaylight.mdsal.yanglib.rfc7895 - - - - - - - scm:git:ssh://git.opendaylight.org:29418/mdsal.git - scm:git:ssh://git.opendaylight.org:29418/mdsal.git - https://wiki.opendaylight.org/view/MD-SAL:Main - HEAD - - diff --git a/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/MountPointContextFactoryImpl.java b/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/MountPointContextFactoryImpl.java deleted file mode 100644 index 26557bd507..0000000000 --- a/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/MountPointContextFactoryImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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 codec; - private final EffectiveModelContext yangLibContext; - private final SchemaContextResolver resolver; - - MountPointContextFactoryImpl(final MountPointIdentifier mountId, final SchemaContextResolver resolver, - final EffectiveModelContext yangLibContext, - final BindingDataObjectCodecTreeNode 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 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 requiredSources = new ArrayList<>(); - final List librarySources = new ArrayList<>(); - final Set 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); - } -} diff --git a/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/Rfc7895ContentBuilder.java b/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/Rfc7895ContentBuilder.java deleted file mode 100644 index ba21926a0a..0000000000 --- a/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/Rfc7895ContentBuilder.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 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 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) { - return revision.map(rev -> new CommonLeafs.Revision(new RevisionIdentifier(rev.toString()))).orElse(EMPTY_REV); - } - - @Override - public Optional formatYangLibraryLegacyContent() { - return Optional.of(formatYangLibraryContent()); - } -} diff --git a/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupport.java b/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupport.java deleted file mode 100644 index f571855512..0000000000 --- a/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupport.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 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); - } -} diff --git a/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupportFactory.java b/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupportFactory.java deleted file mode 100644 index c0efc3968f..0000000000 --- a/yanglib/mdsal-yanglib-rfc7895/src/main/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupportFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 load(final Class clazz) { - return ServiceLoader.load(clazz).findFirst() - .orElseThrow(() -> new IllegalStateException("Failed to find a " + clazz.getSimpleName() + " service")); - } -} diff --git a/yanglib/mdsal-yanglib-rfc7895/src/test/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupportTest.java b/yanglib/mdsal-yanglib-rfc7895/src/test/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupportTest.java deleted file mode 100644 index c80860e38f..0000000000 --- a/yanglib/mdsal-yanglib-rfc7895/src/test/java/org/opendaylight/mdsal/yanglib/rfc7895/YangModuleLibrarySupportTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 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 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 diff --git a/yanglib/pom.xml b/yanglib/pom.xml index 640150bc6f..336eb47726 100644 --- a/yanglib/pom.xml +++ b/yanglib/pom.xml @@ -26,7 +26,6 @@ mdsal-yanglib-api - mdsal-yanglib-rfc7895 mdsal-yanglib-rfc8525 -- 2.36.6