SDN-OpenDaylight(Solium版本)应用开发入门Toster_opendaylight开发一个应用

71 阅读3分钟
<modules>
	<module>odl-mytoaster</module>
	<module>odl-mytoaster-provider</module>
	<module>features-mytoaster</module> 
</modules> 
```

 

在features中添加三个目录,odl-mytoaster,odl-mytoster-provider,features-mytoaster。

mkdir odl-mytoaster odl-mytoster-provider features-mytoaster

 

添加前

添加后

 之后,在三个目录下分别添加pom.xml文件,内容如下

odl-mytoaster下的pom.xml文件内容

<?xml version="1.0" encoding="UTF-8"?>
<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.opendaylight.odlparent</groupId>
    <artifactId>feature-repo-parent</artifactId>
    <version>5.0.5</version>
    <relativePath/>
  </parent>

  <groupId>org.opendaylight.controller.samples</groupId>
  <artifactId>features-mytoaster</artifactId>
  <version>1.10.3-SNAPSHOT</version>
  <packaging>feature</packaging>
  <name>ODL::org.opendaylight.mytoaster::${project.artifactId}</name>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>odl-mytoaster-provider</artifactId>
      <version>${project.version}</version>
	  <type>xml</type>
	  <classifier>features</classifier>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>odl-mytoaster</artifactId>
	  <version>${project.version}</version>
	  <type>xml</type>
	  <classifier>features</classifier>
    </dependency>
  </dependencies>
</project>

odl-mytoaster下的pom.xml内容

<?xml version="1.0" encoding="UTF-8"?>
<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.opendaylight.odlparent</groupId>
    <artifactId>single-feature-parent</artifactId>
    <version>5.0.5</version>
    <relativePath/>
  </parent>

  <groupId>org.opendaylight.controller.samples</groupId>
  <artifactId>odl-mytoaster</artifactId>
  <version>1.10.3-SNAPSHOT</version>
  <packaging>feature</packaging>
  <name>OpenDaylight::mytoaster::Impl[Karaf Feature]</name>

  <dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.opendaylight.controller</groupId>
			<artifactId>mdsal-artifacts</artifactId>
			<version>1.10.2</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
  </dependencyManagement>
  <dependencies>
	<dependency>
		<groupId>org.opendaylight.controller</groupId>
		<artifactId>odl-mdsal-broker</artifactId>
		<type>xml</type>
		<classifier>features</classifier>
	</dependency>
	<dependency>
		<groupId>${project.groupId}</groupId>
		<artifactId>sample-toaster</artifactId>
		<version>${project.version}</version>
	</dependency>
  </dependencies>

</project>

features-mytoaster的内容

<?xml version="1.0" encoding="UTF-8"?>
<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.opendaylight.odlparent</groupId>
    <artifactId>single-feature-parent</artifactId>
    <version>5.0.5</version>
    <relativePath/>
  </parent>

  <groupId>org.opendaylight.controller.samples</groupId>
  <artifactId>odl-mytoaster-provider</artifactId>
  <version>1.10.3-SNAPSHOT</version>
  <packaging>feature</packaging>
  <name>OpenDaylight::mytoaster::Impl[Karaf Feature]</name>

  <dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.opendaylight.controller</groupId>
			<artifactId>mdsal-artifacts</artifactId>
			<version>1.10.2</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
  </dependencyManagement>

  <dependencies>
	<dependency>
		<groupId>org.opendaylight.controller</groupId>
		<artifactId>odl-mdsal-broker</artifactId>
		<type>xml</type>
		<classifier>features</classifier>
	</dependency>
	<dependency>
		<groupId>${project.groupId}</groupId>
		<artifactId>sample-toaster</artifactId>
		<version>${project.version}</version>
	</dependency>
		<dependency>
		<groupId>${project.groupId}</groupId>
		<artifactId>sample-toaster-provider</artifactId>
		<version>${project.version}</version>
	</dependency>
  </dependencies>

</project>

再次编译

进入controller-stable-sodium/opendaylight/md-sal/samples

在该目录下再次执行以下命令

mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true

耗时5分半...

再次编译成功

添加toaster到opendaylight中

我选择了上篇文章SDN-OpenDaylight(Solium版本)应用开发入门HelloWorld中创建的helloworld项目。

在helloworld/karaf/target/assembly/system/org/opendaylight/controller下创建一个名为 samples的目录在改目录中创建如下几个文件夹 features-mytoaster odl-mytoaster-consumer sample-toaster-consumer features_mytoaster odl-mytoaster-provider sample-toaster-provider odl-mytoaster  sample-toaster

mkdir samples
cd samples
mkdir features-mytoaster odl-mytoaster-consumer sample-toaster-consumer features_mytoaster odl-mytoaster-provider sample-toaster-provider odl-mytoaster sample-toaster

添加目录

在每个目录中创建和 toaster 项目中对应 module version 相同名称的目录,即创建1.10.3-SNAPSHOT目录

mkdir 1.10.3-SNAPSHOT

其他目录也有,共8个

在 odl 开头的目录中(odl-mytoaster、odl-mytoaster-provider),将前面 toaster 构建的 target目录 中找到 feature目录并将其每一个目录中的feature.xml放入创建的和版本名相同的目录(1.10.3-SNAPSHOT)中

使用cp命令

在以 sample 开头的目录(三个)中放入对应模块构建的 jar 包,不要结尾有sources的,另外两个同理。

添加jar包

feature:repo-add mvn:org.opendaylight.controller.samples/features-mytoaster/1.10.3-SNAPSHOT/xml/features

添加mytoaster

显示mytoaster已安装

Postman测试

未做面包

制作面包

面包机工作,制作数量为1

更多SDN相关内容,请查看:SDN-自学笔记

有问题请下方评论,转载请注明出处,并附有原文链接,谢谢!如有侵权,请及时联系。