Creating a "Component Meta-Feature"
Introduction
Example and guidline of creating an OSGi Meta-Feature or Feature-All or Feature-aggregator.
The Component here is an SDN-R microservice consisting of two OSGi bundles.
More specific:
Microservice name: northbound
Included OSGi bundles: helloworld, goodbyworld
Meta-Feature: sdnr-northbound-all
Content
Goodbye World
The next step after Creating an Instance of SDNR and Creating and Installing a New Feature into SDNR is to create a "component meta-feature" or "feature aggregator" that groups the SDNR northbound features together and enables them to be installed into OpenDaylight using a single reference. The first step is to create a second feature (Goodbye World) in the same repository as Hello World, shown here. Goodbye World is identical to Hello World except for name changes.
The feature pom.xml file for goodbyeworld - shown below - is simpler than the file we discussed earlier because there is no longer any residual code from the "pre-Casablanca" method for installing features into karaf. It is straightforward and simply generates the features.xml file in the local maven repository.
Executing 'mvn clean install' in helloworld and goodbyeworld generates the corresponding features and zip files in the local maven repository.
These are the key files used by ccsdk/distribution/odlsli/pom.xml when constructing the docker container.
The component meta-feature "features" directory
The next step is to create a features directory in ccsdk/features/sdnr/northbound with this structure and content.
We discuss each file and folder in turn, beginning with features/pom.xml.
ccsdk-features-sdnr-northbound-all
Most of the work in done in the ccsdk-features-sdnr-northbound-all module. Its pom file is shown here.
Installer pom.xml file
Now we look at features/installer/pom.xml. The file is very similar to the pom.xml file for the sliapi installer, although it is simpler because it does not include the "pre-Casablanca" code. Its dependency is the sdnr-northbound-all artifact created immediately above, and it copies the maven repositories of all the features.xml files with the groupId org.onap.ccsdk.features.sdnr.northbound.
mvn clean install
We now execute 'mvn clean install' and see the output. As a reminder, this is the initial state of the features directory.
And this shows the critical files afterwards: feature.xml and sdnr-northbound-all-0.3.0-SNAPSHOT-repo.xml.
Here is the content of the zip file, which - as expected - is the maven repository for the generated features.xml file.
%: unzip -Z installer/target/stage/sdnr-northbound-all-0.3.0-SNAPSHOT-repo.zip
Archive: installer/target/stage/sdnr-northbound-all-0.3.0-SNAPSHOT-repo.zip
Zip file size: 3497 bytes, number of entries: 13
drwxrwxr-x 2.0 unx 0 b- stor 18-Aug-31 22:15 system/
drwxrwxr-x 2.0 unx 0 b- stor 18-Aug-31 22:15 system/org/
drwxrwxr-x 2.0 unx 0 b- stor 18-Aug-31 22:15 system/org/onap/
drwxrwxr-x 2.0 unx 0 b- stor 18-Aug-31 22:15 system/org/onap/ccsdk/
drwxrwxr-x 2.0 unx 0 b- stor 18-Aug-31 22:15 system/org/onap/ccsdk/features/
drwxrwxr-x 2.0 unx 0 b- stor 18-Aug-31 22:15 system/org/onap/ccsdk/features/sdnr/
drwxrwxr-x 2.0 unx 0 b- stor 18-Aug-31 22:15 system/org/onap/ccsdk/features/sdnr/northbound/
drwxrwxr-x 2.0 unx 0 b- stor 18-Aug-31 22:15 system/org/onap/ccsdk/features/sdnr/northbound/sdnr-northbound-all/
drwxrwxr-x 2.0 unx 0 b- stor 18-Aug-31 22:15 system/org/onap/ccsdk/features/sdnr/northbound/sdnr-northbound-all/0.3.0-SNAPSHOT/
-rw-rw-r-- 2.0 unx 318 b- defN 18-Aug-31 22:15 system/org/onap/ccsdk/features/sdnr/northbound/sdnr-northbound-all/maven-metadata-local.xml
-rw-rw-r-- 2.0 unx 869 b- defN 18-Aug-31 22:15 system/org/onap/ccsdk/features/sdnr/northbound/sdnr-northbound-all/0.3.0-SNAPSHOT/sdnr-northbound-all-0.3.0-SNAPSHOT-features.xml
-rw-rw-r-- 2.0 unx 622 b- defN 18-Aug-31 22:15 system/org/onap/ccsdk/features/sdnr/northbound/sdnr-northbound-all/0.3.0-SNAPSHOT/maven-metadata-local.xml
-rw-rw-r-- 2.0 unx 190 b- defN 18-Aug-31 22:15 system/org/onap/ccsdk/features/sdnr/northbound/sdnr-northbound-all/0.3.0-SNAPSHOT/_remote.repositories
And here is the content of the features.xml file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="sdnr-northbound-all">
<repository>mvn:org.onap.ccsdk.features.sdnr.northbound/sdnr-helloworld/0.3.0-SNAPSHOT/xml/features</repository>
<repository>mvn:org.onap.ccsdk.features.sdnr.northbound/sdnr-goodbyeworld/0.3.0-SNAPSHOT/xml/features</repository>
<feature name="sdnr-northbound-all" description="ccsdk-features-sdnr-northbound :: features :: sdnr-northbound-all" version="0.3.0.SNAPSHOT">
<details>Root POM to be used in place of odlparent for CCSDK based projects</details>
<feature version="0.3.0.SNAPSHOT" prerequisite="false" dependency="false">sdnr-helloworld</feature>
<feature version="0.3.0.SNAPSHOT" prerequisite="false" dependency="false">sdnr-goodbyeworld</feature>
</feature>
</features>
And the local maven repository has been updated with these files.
We have all of the files that we need.
Modifying Construction of the ODLSLI Container
Two files need to be modified:
ccsdk/distribution/odlsli/pom.xml
ccsdk/distribution/odlsli/src/main/docker/Dockerfile
ccsdk/distribution/odlsli/pom.xml
ccsdk/distribution/odlsli/src/main/docker/Dockerfile
Smoke Test
Now that everything is in place, we can execute the pom.xml file in ccsdk/distribution/odlsli.
Success! And to show that it actually works.