How to deploy self-developed bundle to Opendaylight production environment

来源:互联网 发布:360登录 网络错误 编辑:程序博客网 时间:2024/05/10 11:30

 

 

Howto deploy self-developed bundle to Opendaylight production environment

 

1    Introduction

Apache Karaf provides many convenient ways for bundles installation. But when we develop our user-defined bundles with Opendaylight archtype, it is difficult to deploy these bundles into production environment.

Searching WWW can’t  provide useful help. So write this post to record the steps in case someday had been forgotten.

 

Usually we start our bundle development with mvn command:

mvn archetype:generate \

-DarchetypeGroupId=org.opendaylight.controller \

-DarchetypeArtifactId=opendaylight-startup-archetype \

-DarchetypeVersion=ODLVER\

-DarchetypeRepository=https://nexus.opendaylight.org/content/repositories/public/ \

-DarchetypeCatalog=https://nexus.opendaylight.org/content/repositories/public/archetype-catalog.xml

 

Where ODLVER  may be “1.2.1-Boron-SR1”, “1.1.4-Beryllium-SR4”or others. All available ODLVER  values can be achieved from here:

https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/controller/opendaylight-startup-archetype/

 

After successful creation, our project contains at least three submodules: api, impl, and features, carefully write down their “groupId” and “artifactId”. All the submodules have the same“groupId” and different “artifactId”.

Assume project name is “PROJECT”, then their artifactId may be “PROJECT-aggregator”, “PROJECT-api”,and “PROJECT-features”. In the following, symbols of “PROJECT-ID”, “PROJECT-API-ID”and “PROJECT-FEATURES-ID” refer to as their values.

 

There are two methods to deploy this PROJECT into Opendaylight distribution.

  • Build a complete distribution ODL with this PROJECT.
  • Singly deploy this PROJECT to a running ODL distribution.

 

2    Build a complete distribution ODL with this PROJECT

First build ODL distribution, then add this PROJECT into distribution.

1)      Checkout  ODL distribution from git and build

mvn command:

$ git clone https://git.opendaylight.org/gerrit/integration/distribution

$ cd distribution

$ git tag

$ git checkout release/beryllium-sr4(release/boron-sr1)

$ mvn clean install

 

2)     Add this PROJECT to distribution features

In ODL distribution directory,

File “pom.xml”, add one line as:

<PROJECT.version>here is PROJECT’s version</PROJECT.version>

 

File “features-index/pom.xml”, add dependency:

<dependency>

  <groupId>PROJECT-GROUPID</groupId>

  <artifactId>PROJECT-FEATURES-ID</artifactId>

  <version>${PROJECT.version}</version>

  <classifier>features</classifier>

  <type>xml</type>

</dependency>

 

File “features-index/src/main/resources/features.xml”, add one line:

<repository>mvn:PROJECT-GROUPID/PROJECT-FEATURES-ID/${PROJECT.version}/xml/features</repository>

 

3)     Build a newly distribution which contains this PROJECT.

$ mvn clean install

 

The newly distribution is created in directory “distribution-karaf\target”

 

3  Individually  deploy PROJECT to a running ODL distribution environment

 

Apache karaf can load bundles from maven repository. In a running ODL distribution, directory “system” is the maven format directory which contains bundles to load and run.

 

When our PROJECT develops correctly with no  failures of command “mvn clean install”, our PROJECT bundles reside in local  maven repository which directory is usually at “~/.m2”.

1)    Copy the PROJECT’s bundles to running ODL distribution’s repository “system”

For example from local maven directory:

$ cp –R ~/.m2/repository/org/bupt/    ~/distribution-karaf-0.4.4-Beryllium-SR4/system/org


Or from current PROJECT’s directory (RECOMMENDED!):

$ cp  –R  karaf/target/assembly/system/org/bupt   ~/distribution-karaf-0.4.4-Beryllium-SR4/system/org

 

2)    Add PROJECT’s  features to ODL  feature-integration-index xml file

 

Open the running ODL distribution’s  “features-integration-index-[RELEASE-VERSION]-features.xml

For example with Beryllium-SR4, file path is:

distribution-karaf-0.4.4-Beryllium-SR4/system\org\opendaylight\integration\features-integration-index\0.4.4-Beryllium-SR4/features-integration-index-0.4.4-Beryllium-SR4-features.xml

Then add one line of PROJECT’s feature  repository  as following:

<repository>mvn:PROJECT-GROUPID/PROJECT-FEATURES-ID/${PROJECT.version}/xml/features</repository>


3)    (Optional) Start odl, and install features  repo.

$ ./bin/karaf

opendaylight@root> feature:repo-add  mvn:PROJECT-GROUPID/PROJECT-FEATURES-ID/PROJECT-VERSION/xml/features

opendaylight@root> feature:list

opendaylight@root>feature:install  <your features>

  

That is all!

 

0 0
原创粉丝点击