Fix odl-yanglib feature usage 87/104087/12
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 13:08:37 +0000 (14:08 +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>
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 a7d3cbe22f48f32e1d7e40bdef5a705b48d147bc..59f623eb083c07a9e51e8b16884eb22519f10546 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 fa50dffbe7503ff1f993580303369e8f74161c59..f03474368e9d5ae1e769eac4cd998208481dc8f2 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 fddef45d58d396f3fbbb7dacd12033c6fe7ed81d..246b91782af15c41bee896b37dcade7237cc7805 100644 (file)
@@ -10,5 +10,8 @@
     <feature name="odl-yanglib" version="${project.version}">
         <feature version="[12,13)">odl-karaf-feat-jetty</feature>
         <feature version="[11,12)">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 88df6d807604bf91caec41babe70a19726815cef..a9cc3a1c810cc2871f7246e47d0e1fef6df21e88 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 5235d7df51281a0a424020e446b274f0557c3d37..68f9b2d4c34802da0502dca0ee186c9c0e201424 100644 (file)
@@ -88,7 +88,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