SDN学习之Opendaylight浅析(四)
前面主要对ODL的基础进行梳理和总结,其实基础只是学习的很小的一部分,更多的时候还要阅读源码,在官网上面查找资料,当然基础打牢是必须的,比如说在不同版本的odl对事务提交的返回的future也略有不同,但是提交所做的处理在原理上面是相通,只是语法上的区别。总之,ODL学习之路漫漫,要有耐心和恒心,总会遇到各种各样的报错,积极思考耐心解决问题才是王道,这一讲主要针对ODL的feature进行说明。
首先列出官网上面feature的说明
feature文件夹是控制产生feature的分支,在odl里面feature可以看作是一系列bundle组成,由feature分支定义的feature将会在生成karaf容器,在毕竟经典的版本里面,会有一个feature.xml文件专门用来定义feature构成,新版本里面定义feature会更加简单,可以直接在feature文件里面进行定义。
在创建的骨架项目里面会有预定义的feature.xml,如图所示
<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=4 tabstop=4: -->
<!--
Copyright © 2017 My Company and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<features name="odl-traffic-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:org.opendaylight.yangtools/features-yangtools/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.netconf/features-netconf/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.dluxapps/features-dluxapps/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.netconf/features-netconf-connector/{{VERSION}}/xml/features</repository>
<!-- <repository>mvn:org.opendaylight.mdsal.model/ietf-topology/{{VERSION}}/xml/features</repository>-->
<!-- <repository>mvn:mvn:org.opendaylight.netconf/sal-netconf-connector/{{VERSION}}/xml/features</repository>-->
<feature name='odl-traffic-api' version='${project.version}' description='OpenDaylight :: traffic :: api'>
<feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
<feature version="${connector.version}">odl-netconf-connector-all</feature>
<bundle>mvn:org.future.network/traffic-api/{{VERSION}}</bundle>
</feature>
<feature name='odl-traffic' version='${project.version}' description='OpenDaylight :: traffic'>
<feature version="${connector.version}">odl-netconf-connector-all</feature>
<feature version='${mdsal.version}'>odl-mdsal-broker</feature>
<feature version='${project.version}'>odl-traffic-api</feature>
<bundle>mvn:org.future.network/traffic-impl/{{VERSION}}</bundle>
</feature>
<feature name='odl-traffic-rest' version='${project.version}' description='OpenDaylight :: traffic :: REST'>
<feature version="${project.version}">odl-traffic</feature>
<feature version="${restconf.version}">odl-restconf</feature>
</feature>
<feature name='odl-traffic-ui' version='${project.version}' description='OpenDaylight :: traffic :: UI'>
<feature version="${project.version}">odl-traffic-rest</feature>
<feature version="${restconf.version}">odl-mdsal-apidocs</feature>
<feature version="${dluxapps.version}">odl-dluxapps-yangman</feature>
</feature>
<feature name='odl-traffic-cli' version='${project.version}' description='OpenDaylight :: traffic :: CLI'>
<feature version="${project.version}">odl-traffic</feature>
<bundle>mvn:org.future.network/traffic-cli/{{VERSION}}</bundle>
</feature>
</features>
定义首先要定义feature仓库用作引入feature或者bundle,这个仓库的范围一般较大,如图仓库是使用的features开头的feature,这个一般是一个类型里面最大的feature,然后下面就预定义了几个feature,重要如api和impl,feature里面引入了我们写的api和impl的bundle,然后还有一些预定义的如odl-mdsal-broker,例如引入这个可以使用datasore,除了直接引入feature还可以引入一些bundle,需要注意的是bundle必须具有一定的独立性,不然引入很容易报错。
下面我简单举个引入feature的例子,我首先在impl引入了一些代码,于是在pom文件里面添加依赖
然后由于这个是一个bundle,于是寻找其对应的feature,通过查找netconf的源码,我可以发现bundle属于features-netconf-connector这个大分支,
其实,细看bundle是属于odl-netconf-connector这个小feature,但是我们引入可以引入大的feature,可以获得一些其他相关feature的支持。
接着我们在feature分支的pom文件引入依赖,如图
<connector.version>1.2.0-Carbon</connector.version>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>features-netconf-connector</artifactId>
<classifier>features</classifier>
<version>${connector.version}</version>
<type>xml</type>
<scope>runtime</scope>
</dependency>
然后再feature.xml文件做引入
这样引入feature之后,karaf启动时候就会将odl-netconf-connector-all启动,在新版本的项目中,不再有xml文件,相似的通过pom文件进行直接引入,其实提高了引入的便捷性。如图所示新版本的feature分支
可以直接在odl-netconftest的pom文件里面加入依赖,就可以引入feature
上一篇: msm8953 PWM背光
下一篇: android LCM启动流程——LK