aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh')
-rw-r--r--sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/feature/pom.xml3
-rwxr-xr-xsdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/installer/pom.xml3
-rw-r--r--sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/model/pom.xml3
-rwxr-xr-xsdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/pom.xml3
-rw-r--r--sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/pom.xml52
-rw-r--r--sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java7
-rw-r--r--sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java4
-rw-r--r--sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java3
-rw-r--r--sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java380
-rw-r--r--sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java112
-rw-r--r--sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml38
11 files changed, 454 insertions, 154 deletions
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/feature/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/feature/pom.xml
index 475ba0f28..635d3b97e 100644
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/feature/pom.xml
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/feature/pom.xml
@@ -22,13 +22,14 @@
~ ============LICENSE_END=======================================================
~
-->
+
<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.onap.ccsdk.parent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>2.4.0</version>
+ <version>2.4.1-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/installer/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/installer/pom.xml
index 76993dd1b..0e137d980 100755
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/installer/pom.xml
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/installer/pom.xml
@@ -22,13 +22,14 @@
~ ============LICENSE_END=======================================================
~
-->
+
<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.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>2.4.0</version>
+ <version>2.4.1-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/model/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/model/pom.xml
index a22154353..2354c3a40 100644
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/model/pom.xml
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/model/pom.xml
@@ -22,13 +22,14 @@
~ ============LICENSE_END=======================================================
~
-->
+
<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.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>2.4.0</version>
+ <version>2.4.1-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/pom.xml
index aaf472714..9cbe89787 100755
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/pom.xml
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/pom.xml
@@ -22,13 +22,14 @@
~ ============LICENSE_END=======================================================
~
-->
+
<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.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>2.4.0</version>
+ <version>2.4.1-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/pom.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/pom.xml
index ebb1c63cf..ee4f84f72 100644
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/pom.xml
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/pom.xml
@@ -22,13 +22,14 @@
~ ============LICENSE_END=======================================================
~
-->
+
<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.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>2.4.0</version>
+ <version>2.4.1-SNAPSHOT</version>
<relativePath/>
</parent>
@@ -53,38 +54,44 @@
</properties>
<dependencies>
- <!-- begin for testing -->
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>sdnr-wt-devicemanager-core-provider</artifactId>
+ <artifactId>sdnr-wt-devicemanager-o-ran-sc-oran-model</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
- <!-- end for testing -->
<dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-devicemanager-core-model</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>sdnr-wt-devicemanager-o-ran-sc-oran-model</artifactId>
+ <artifactId>sdnr-wt-netconfnode-state-service-model</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>sdnr-wt-devicemanager-core-model</artifactId>
+ <artifactId>sdnr-wt-websocketmanager-model</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>sdnr-wt-netconfnode-state-service-model</artifactId>
+ <artifactId>sdnr-wt-common</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-data-provider-model</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
@@ -113,6 +120,25 @@
<artifactId>onap-system</artifactId>
<version>${project.version}</version>
</dependency>
+ <!-- begin for testing -->
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-devicemanager-core-provider</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- end for testing -->
+
</dependencies>
<build>
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java
index 279620cf8..a3bd14e3e 100644
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java
@@ -24,8 +24,11 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
+
import org.opendaylight.mdsal.dom.api.DOMEvent;
import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.yangtools.yang.common.QName;
@@ -63,8 +66,8 @@ public class ORanDMDOMUtility {
}
}
- public static List<String> getLeafListValue(DataContainerNode componentEntry, QName leafListQName) {
- List<String> containsChildList = new ArrayList<String>();
+ public static Set<String> getLeafListValue(DataContainerNode componentEntry, QName leafListQName) {
+ Set<String> containsChildList = new HashSet<String>();
try {
DataContainerChild childSet = componentEntry.getChildByArg(new NodeIdentifier(leafListQName));
Collection<?> childEntry = (Collection<?>) childSet.body();
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java
index b157ae4b5..25a54f013 100644
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java
@@ -90,8 +90,8 @@ public class ORanDOMToInternalDataModel {
inventoryResultList.add(oInventory.get());
}
//Walk through list of child keys and add to list
- for (String childUuid : CodeHelpers.nonnull(ORanDMDOMUtility.getLeafListValue(component,
- ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CONTAINS_CHILD))) {
+ for (String childUuid : CodeHelpers.nonnull(new ArrayList<>(ORanDMDOMUtility.getLeafListValue(component,
+ ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CONTAINS_CHILD)))) {
for (MapEntryNode c : getComponentsByName(childUuid, componentList)) {
inventoryResultList = recurseGetInventory(nodeId, c, componentList, treeLevel + 1, inventoryResultList);
}
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java
index b2c669819..e3113db3c 100644
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java
@@ -34,7 +34,6 @@ import javax.xml.stream.XMLStreamReader;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom.util.TestYangParserUtil;
import org.opendaylight.mdsal.dom.api.DOMEvent;
import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity;
@@ -80,7 +79,7 @@ public class TestORanDOMToInternalDataModel {
@BeforeClass
public static void setup() throws IOException {
- schemaContext = TestYangParserUtil.parseYangResourceDirectory("/");
+ schemaContext = YangParserTestUtils.parseYangResourceDirectory("/");
hwContainerSchema = Inference.ofDataTreePath(schemaContext, HW_CONTAINER);
systemSchema = Inference.ofDataTreePath(schemaContext, IETF_CONTAINER);
}
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java
new file mode 100644
index 000000000..80c18aef2
--- /dev/null
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/YangParserTestUtils.java
@@ -0,0 +1,380 @@
+/*
+ * Copyright (c) 2016 Cisco 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
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom;
+
+import com.google.common.annotations.Beta;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.YangConstants;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.api.YangParser;
+import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
+import org.opendaylight.yangtools.yang.parser.api.YangParserException;
+import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
+import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+/**
+ * Utility class which provides convenience methods for producing effective schema context based on the supplied
+ * yang/yin sources or paths to these sources.
+ */
+@Beta
+public final class YangParserTestUtils {
+
+ private static final FileFilter YANG_FILE_FILTER = file -> {
+ // Locale keeps SpotBugs happy. It should not matter that much anyway.
+ final String name = file.getName().toLowerCase(Locale.ENGLISH);
+ return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile();
+ };
+
+ private static final @NonNull YangParserFactory PARSER_FACTORY;
+
+ static {
+ final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator();
+ if (!it.hasNext()) {
+ throw new IllegalStateException("No YangParserFactory found");
+ }
+ PARSER_FACTORY = it.next();
+ }
+
+ private YangParserTestUtils() {
+ // Hidden on purpose
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to
+ * default mode and all YANG features are supported.
+ *
+ * @param resource relative path to the YANG file to be parsed
+ *
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResource(final String resource) {
+ return parseYangResource(resource, YangParserConfiguration.DEFAULT);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG source. All YANG features are supported.
+ *
+ * @param resource relative path to the YANG file to be parsed
+ * @param parserMode mode of statement parser
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config) {
+ return parseYangResource(resource, config, null);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to
+ * default mode.
+ *
+ * @param resource relative path to the YANG file to be parsed
+ * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+ * model are resolved
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResource(final String resource, final Set<QName> supportedFeatures) {
+ return parseYangResource(resource, YangParserConfiguration.DEFAULT, supportedFeatures);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG source.
+ *
+ * @param resource relative path to the YANG file to be parsed
+ * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+ * model are resolved
+ * @param parserMode mode of statement parser
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResource(final String resource, final YangParserConfiguration config,
+ final Set<QName> supportedFeatures) {
+ final YangTextSchemaSource source = YangTextSchemaSource.forResource(YangParserTestUtils.class, resource);
+ return parseYangSources(config, supportedFeatures, source);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+ * default mode and all YANG features are supported.
+ *
+ * @param files YANG files to be parsed
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangFiles(final File... files) {
+ return parseYangFiles(Arrays.asList(files));
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+ * default mode and all YANG features are supported.
+ *
+ * @param files collection of YANG files to be parsed
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangFiles(final Collection<File> files) {
+ return parseYangFiles(YangParserConfiguration.DEFAULT, files);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+ * default mode.
+ *
+ * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+ * models are resolved
+ * @param files YANG files to be parsed
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures, final File... files) {
+ return parseYangFiles(supportedFeatures, Arrays.asList(files));
+ }
+
+ public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures,
+ final Collection<File> files) {
+ return parseYangFiles(supportedFeatures, YangParserConfiguration.DEFAULT, files);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
+ *
+ * @param parserMode mode of statement parser
+ * @param files YANG files to be parsed
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) {
+ return parseYangFiles(config, Arrays.asList(files));
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
+ *
+ * @param parserMode mode of statement parser
+ * @param files collection of YANG files to be parsed
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config,
+ final Collection<File> files) {
+ return parseYangFiles(null, config, files);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources.
+ *
+ * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+ * models are resolved
+ * @param parserMode mode of statement parser
+ * @param files YANG files to be parsed
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures,
+ final YangParserConfiguration config, final File... files) {
+ return parseYangFiles(supportedFeatures, config, Arrays.asList(files));
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources.
+ *
+ * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+ * models are resolved
+ * @param parserMode mode of statement parser
+ * @param files YANG files to be parsed
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangFiles(final Set<QName> supportedFeatures,
+ final YangParserConfiguration config, final Collection<File> files) {
+ return parseSources(config, supportedFeatures,
+ files.stream().map(e->e.toPath()).map(YangTextSchemaSource::forPath).collect(Collectors.toList()));
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+ * default mode and all YANG features are supported.
+ *
+ * @param resourcePath relative path to the directory with YANG files to be parsed
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) {
+ return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
+ *
+ * @param resourcePath relative path to the directory with YANG files to be parsed
+ * @param parserMode mode of statement parser
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath,
+ final YangParserConfiguration config) {
+ return parseYangResourceDirectory(resourcePath, null, config);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+ * default mode.
+ *
+ * @param resourcePath relative path to the directory with YANG files to be parsed
+ * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+ * models are resolved
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath,
+ final Set<QName> supportedFeatures) {
+ return parseYangResourceDirectory(resourcePath, supportedFeatures, YangParserConfiguration.DEFAULT);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources.
+ *
+ * @param resourcePath relative path to the directory with YANG files to be parsed
+ * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+ * models are resolved
+ * @param parserMode mode of statement parser
+ * @return effective schema context
+ */
+ @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles")
+ public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath,
+ final Set<QName> supportedFeatures, final YangParserConfiguration config) {
+ final URI directoryPath;
+ try {
+ directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI();
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Failed to open resource " + resourcePath, e);
+ }
+ return parseYangFiles(supportedFeatures, config, new File(directoryPath).listFiles(YANG_FILE_FILTER));
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+ * default mode and all YANG features are supported.
+ *
+ * @param clazz Resource lookup base
+ * @param resources Resource names to be looked up
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResources(final Class<?> clazz, final String... resources) {
+ return parseYangResources(clazz, Arrays.asList(resources));
+ }
+
+ public static EffectiveModelContext parseYangResources(final Class<?> clazz, final Collection<String> resources) {
+ final List<YangTextSchemaSource> sources = new ArrayList<>(resources.size());
+ for (final String r : resources) {
+ sources.add(YangTextSchemaSource.forResource(clazz, r));
+ }
+ return parseSources(YangParserConfiguration.DEFAULT, null, sources);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+ * default mode.
+ *
+ * @param yangDirs relative paths to the directories containing YANG files to be parsed
+ * @param yangFiles relative paths to the YANG files to be parsed
+ * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+ * models are resolved
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResources(final List<String> yangDirs, final List<String> yangFiles,
+ final Set<QName> supportedFeatures) {
+ return parseYangResources(yangDirs, yangFiles, supportedFeatures, YangParserConfiguration.DEFAULT);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
+ *
+ * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed
+ * @param yangResources relative paths to the YANG files to be parsed
+ * @param statementParserMode mode of statement parser
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs,
+ final List<String> yangResources, final YangParserConfiguration config) {
+ return parseYangResources(yangResourceDirs, yangResources, null, config);
+ }
+
+ /**
+ * Creates a new effective schema context containing the specified YANG sources.
+ *
+ * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed
+ * @param yangResources relative paths to the YANG files to be parsed
+ * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+ * models are resolved
+ * @param statementParserMode mode of statement parser
+ * @return effective schema context
+ */
+ public static EffectiveModelContext parseYangResources(final List<String> yangResourceDirs,
+ final List<String> yangResources, final Set<QName> supportedFeatures,
+ final YangParserConfiguration config) {
+ final List<File> allYangFiles = new ArrayList<>();
+ for (final String yangDir : yangResourceDirs) {
+ allYangFiles.addAll(getYangFiles(yangDir));
+ }
+
+ for (final String yangFile : yangResources) {
+ try {
+ allYangFiles.add(new File(YangParserTestUtils.class.getResource(yangFile).toURI()));
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Invalid resource " + yangFile, e);
+ }
+ }
+
+ return parseYangFiles(supportedFeatures, config, allYangFiles);
+ }
+
+ public static EffectiveModelContext parseYangSources(final YangParserConfiguration config,
+ final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) {
+ return parseSources(config, supportedFeatures, Arrays.asList(sources));
+ }
+
+ public static EffectiveModelContext parseSources(final YangParserConfiguration config,
+ final Set<QName> supportedFeatures, final Collection<? extends SchemaSourceRepresentation> sources) {
+ final YangParser parser = PARSER_FACTORY.createParser(config);
+ if (supportedFeatures != null) {
+ parser.setSupportedFeatures(supportedFeatures);
+ }
+
+ try {
+ parser.addSources(sources);
+ } catch (YangSyntaxErrorException e) {
+ throw new IllegalArgumentException("Malformed source", e);
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Failed to read a source", e);
+ }
+
+ try {
+ return parser.buildEffectiveModel();
+ } catch (YangParserException e) {
+ throw new IllegalStateException("Failed to assemble SchemaContext", e);
+ }
+ }
+
+ @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles")
+ private static Collection<File> getYangFiles(final String resourcePath) {
+ final URI directoryPath;
+ try {
+ directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI();
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Failed to open resource directory " + resourcePath, e);
+ }
+ return Arrays.asList(new File(directoryPath).listFiles(YANG_FILE_FILTER));
+ }
+}
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java
deleted file mode 100644
index 35a66055a..000000000
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/util/TestYangParserUtil.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : ccsdk features
- * ================================================================================
- * Copyright (C) 2022 highstreet technologies GmbH Intellectual Property.
- * All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- *
- */
-package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom.util;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.YangConstants;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.parser.api.YangParser;
-import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
-import org.opendaylight.yangtools.yang.parser.api.YangParserException;
-import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
-import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-
-public final class TestYangParserUtil {
-
- private static final FileFilter YANG_FILE_FILTER = file -> {
- final String name = file.getName();
- return name.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile();
- };
-
- private static final @NonNull YangParserFactory PARSER_FACTORY;
-
- static {
- final Iterator<@NonNull YangParserFactory> it = ServiceLoader.load(YangParserFactory.class).iterator();
- if (!it.hasNext()) {
- throw new IllegalStateException("No YangParserFactory found");
- }
- PARSER_FACTORY = it.next();
- }
-
- public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config, final File... files) {
- return parseYangFiles(config, Arrays.asList(files));
- }
-
- public static EffectiveModelContext parseYangFiles(final YangParserConfiguration config,
- final Collection<File> files) {
- return parseSources(config, files.stream().map(YangTextSchemaSource::forFile).collect(Collectors.toList()));
- }
-
- public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath) {
- return parseYangResourceDirectory(resourcePath, YangParserConfiguration.DEFAULT);
- }
-
- public static EffectiveModelContext parseYangResourceDirectory(final String resourcePath,
- final YangParserConfiguration config) {
- final URI directoryPath;
- try {
- directoryPath = TestYangParserUtil.class.getResource(resourcePath).toURI();
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException("Failed to open resource " + resourcePath, e);
- }
- return parseYangFiles(config, new File(directoryPath).listFiles(YANG_FILE_FILTER));
- }
-
- public static EffectiveModelContext parseYangSources(final YangParserConfiguration config,
- final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) {
- return parseSources(config, Arrays.asList(sources));
- }
-
- public static EffectiveModelContext parseSources(final YangParserConfiguration config,
- final Collection<? extends SchemaSourceRepresentation> sources) {
- final YangParser parser = PARSER_FACTORY.createParser(config);
-
- try {
- parser.addSources(sources);
- } catch (YangSyntaxErrorException e) {
- throw new IllegalArgumentException("Malformed source", e);
- } catch (IOException e) {
- throw new IllegalArgumentException("Failed to read a source", e);
- }
-
- try {
- return parser.buildEffectiveModel();
- } catch (YangParserException e) {
- throw new IllegalStateException("Failed to assemble SchemaContext", e);
- }
- }
-}
diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml
index 433c51cba..60f998630 100644
--- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml
+++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/ietf-hardware.xml
@@ -8,10 +8,10 @@
<admin-state>unlocked</admin-state>
<oper-state>enabled</oper-state>
</state>
- <serial-num>1234</serial-num>
- <software-rev>1.2.3 (2022-10-30 09:34:59)</software-rev>
- <mfg-name>Highstreet</mfg-name>
- <model-name>HS O-RU</model-name>
+ <serial-num>10283</serial-num>
+ <software-rev>3.8.1 (2020-10-30 11:47:59)</software-rev>
+ <mfg-name>ISCO</mfg-name>
+ <model-name>ProteusCPRI Compact</model-name>
<description>HighStreet-ONAP40</description>
<contains-child>chassis-temperature-exhaust</contains-child>
<contains-child>chassis-temperature-inlet</contains-child>
@@ -36,7 +36,7 @@
<sensor-data>
<value>30</value>
<value-type>celsius</value-type>
- <value-timestamp>2022-03-18T19:51:50.3Z</value-timestamp>
+ <value-timestamp>2021-03-18T19:51:50.3Z</value-timestamp>
<oper-status>ok</oper-status>
</sensor-data>
</component>
@@ -53,7 +53,7 @@
<sensor-data>
<value>29</value>
<value-type>celsius</value-type>
- <value-timestamp>2022-03-18T19:51:50.3Z</value-timestamp>
+ <value-timestamp>2021-03-18T19:51:50.3Z</value-timestamp>
<oper-status>ok</oper-status>
</sensor-data>
</component>
@@ -82,7 +82,7 @@
<sensor-data>
<value>4100</value>
<value-type>rpm</value-type>
- <value-timestamp>2022-03-18T19:51:50.3Z</value-timestamp>
+ <value-timestamp>2021-03-18T19:51:50.3Z</value-timestamp>
<oper-status>ok</oper-status>
</sensor-data>
</component>
@@ -212,10 +212,10 @@
</state>
<parent>chassis</parent>
<parent-rel-pos>7</parent-rel-pos>
- <serial-num>1020304050</serial-num>
- <firmware-rev>123456 (0ABC56D1)</firmware-rev>
+ <serial-num>7220530</serial-num>
+ <firmware-rev>12.00.42-S (0F7F1001)</firmware-rev>
<software-rev>0</software-rev>
- <model-name>00AA-SFP-99-BB-CCC</model-name>
+ <model-name>385A-SFP-2P-40-FHL-JC3</model-name>
<contains-child>slot0-temperature</contains-child>
<contains-child>slot0-logical0</contains-child>
<contains-child>slot0-logical1</contains-child>
@@ -263,9 +263,9 @@
<parent>slot0-logical0</parent>
<parent-rel-pos>0</parent-rel-pos>
<o-ran-name xmlns="urn:o-ran:hardware:1.0">slot0-logical0-bbu</o-ran-name>
- <serial-num>ABC12DF3</serial-num>
- <mfg-name>Highstreet</mfg-name>
- <model-name>HS-99-56</model-name>
+ <serial-num>AYR3GA2</serial-num>
+ <mfg-name>FINISAR CORP.</mfg-name>
+ <model-name>FTLX1475D3BTL-E7</model-name>
<contains-child>slot0-logical0-bbu-temperature</contains-child>
</component>
<component>
@@ -296,9 +296,9 @@
<parent>slot0-logical0</parent>
<parent-rel-pos>1</parent-rel-pos>
<o-ran-name xmlns="urn:o-ran:hardware:1.0">slot0-logical0-rrh</o-ran-name>
- <serial-num>ABC78YZ</serial-num>
- <mfg-name>Highstreet</mfg-name>
- <model-name>2W3E4R5T6Y</model-name>
+ <serial-num>AYR3GA9</serial-num>
+ <mfg-name>FINISAR CORP.</mfg-name>
+ <model-name>FTLX1475D3BTL-E7</model-name>
<contains-child>slot0-logical0-rrh-temperature</contains-child>
</component>
<component>
@@ -352,10 +352,10 @@
</state>
<parent>chassis</parent>
<parent-rel-pos>9</parent-rel-pos>
- <serial-num>23561289</serial-num>
- <firmware-rev>12.00.42-S (0ABC45HJ)</firmware-rev>
+ <serial-num>7220718</serial-num>
+ <firmware-rev>12.00.42-S (0F7F1001)</firmware-rev>
<software-rev>0</software-rev>
- <model-name>ABC-123-DEF-XYZ</model-name>
+ <model-name>385A-SFP-2P-40-FHL-JC3</model-name>
<mfg-date>2021-10-12T14:41:55.234Z</mfg-date>
<contains-child>slot2-temperature</contains-child>
<contains-child>slot2-logical0</contains-child>