Fix odl-yanglib feature usage 92/104392/1
authorYaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Thu, 19 Jan 2023 11:55:38 +0000 (13:55 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 14 Feb 2023 18:49:05 +0000 (19:49 +0100)
The problem is that Initialization stops working correctly and
expect non-empty YanglibConfig provided by blueprint.

Were set default cache-folder to cache/schema, binding-addr to
localhost and binding-port port 8181 by creating new config
file.

JIRA: NETCONF-909
Change-Id: I76455310d014a5ad87051cb0ac749f5ce9f010c1
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 11ced7438f39559415565864c085fc0ec4422f4d)

artifacts/pom.xml
features/yanglib/odl-yanglib/pom.xml
features/yanglib/odl-yanglib/src/main/feature/feature.xml
netconf/yanglib/pom.xml
netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibProvider.java
netconf/yanglib/src/main/resources/OSGI-INF/blueprint/yanglib.xml
netconf/yanglib/src/main/resources/initial/yanglib-config.xml [new file with mode: 0644]

index b6f7d6755ef8230cc510a0a01556a4238dbbaded..86a52858c2536712104f5cde41a55bd9f8656387 100644 (file)
                 <artifactId>yanglib</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.opendaylight.netconf</groupId>
+                <artifactId>yanglib</artifactId>
+                <version>${project.version}</version>
+                <classifier>config</classifier>
+                <type>xml</type>
+            </dependency>
 
             <dependency>
                 <groupId>org.opendaylight.netconf</groupId>
index 87d95fb77b13c937670426a6342fea75448a05dc..4bde2e016477e7169bdd47eb3cd55f6b98323dda 100644 (file)
             <groupId>org.opendaylight.netconf</groupId>
             <artifactId>yanglib</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.netconf</groupId>
+            <artifactId>yanglib</artifactId>
+            <type>xml</type>
+            <classifier>config</classifier>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.netconf</groupId>
             <artifactId>odl-restconf</artifactId>
index 246a253956c19d0b61115cb99c26a8fdc57685c6..b8ac52e5944f59ec01892031bfed261d6e8c617f 100644 (file)
@@ -10,5 +10,8 @@
     <feature name="odl-yanglib" version="${project.version}">
         <feature version="[10,11)">odl-karaf-feat-jetty</feature>
         <feature version="[9,10)">odl-mdsal-model-rfc8525</feature>
+        <configfile finalname="etc/opendaylight/datastore/initial/config/yanglib-config.xml">
+            mvn:org.opendaylight.netconf/yanglib/${project.version}/xml/config
+        </configfile>
     </feature>
 </features>
index f9aa104a871b114fce6257a44374c2ed7c16386a..a44fab734a74082222f2e18c2a66424b535b86b4 100644 (file)
                     </instructions>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <phase>package</phase>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>${project.build.directory}/classes/initial/yanglib-config.xml</file>
+                                    <type>xml</type>
+                                    <classifier>config</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 
index e523dd81d60be4d218c071aaddfca4a1329b98bb..2ef3d10f69956b787d00eee5c36e3642d4e79b79 100644 (file)
@@ -90,7 +90,12 @@ public class YangLibProvider implements AutoCloseable, SchemaSourceListener, Yan
         }
 
         final File cacheFolderFile = new File(yanglibConfig.getCacheFolder());
-        checkArgument(cacheFolderFile.exists(), "cache-folder %s does not exist", cacheFolderFile);
+        if (cacheFolderFile.exists()) {
+            LOG.info("cache-folder {} already exists", cacheFolderFile);
+        } else {
+            checkArgument(cacheFolderFile.mkdirs(), "cache-folder %s cannot be created", cacheFolderFile);
+            LOG.info("cache-folder {} was created", cacheFolderFile);
+        }
         checkArgument(cacheFolderFile.isDirectory(), "cache-folder %s is not a directory", cacheFolderFile);
 
         final FilesystemSchemaSourceCache<YangTextSchemaSource> cache =
index be4b5cf3edc86cc8a7bc8ad5d07849673bcfddcc..9fe5243513b3e8d38350502c713434e57787ceaf 100644 (file)
@@ -10,7 +10,7 @@
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
            odl:use-default-for-reference-types="true">
 
-  <odl:clustered-app-config id="yanglibConfig"
+  <odl:clustered-app-config id="yanglibConfig" default-config-file-name="yanglib-config.xml"
       binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.yanglib.impl.rev141210.YanglibConfig"/>
 
   <reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
diff --git a/netconf/yanglib/src/main/resources/initial/yanglib-config.xml b/netconf/yanglib/src/main/resources/initial/yanglib-config.xml
new file mode 100644 (file)
index 0000000..fd1ab99
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<yanglib-config xmlns="urn:opendaylight:params:xml:ns:yang:controller:yanglib:impl">
+    <cache-folder>cache/schema</cache-folder>
+    <binding-addr>localhost</binding-addr>
+    <binding-port>8181</binding-port>
+</yanglib-config>
\ No newline at end of file