You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在OpenDaylight Nitrogen版本中添加功能?Karaf检测异常求助

我帮你排查下OpenDaylight Nitrogen版本添加l2switch、dlux、restconf这些功能时遇到的问题——从Carbon到Nitrogen,特性管理的逻辑有一些关键变化,你之前的操作可能没覆盖到新版本的要求:

1. 先确认Karaf是否能找到目标特性仓库

Nitrogen版本中,restconf、l2switch这类核心功能的特性定义都存放在独立的特性仓库里,只在pom.xml加依赖还不够,得让Karaf知道去哪找这些仓库。

先在Karaf控制台执行命令,查看已注册的仓库:

feature:repo-list

如果找不到org.opendaylight.netconf:features-restconforg.opendaylight.l2switch:features-l2switchorg.opendaylight.dlux:features-dlux这类仓库,手动添加:

feature:repo-add mvn:org.opendaylight.netconf/features-restconf/${odl-version}/xml/features
feature:repo-add mvn:org.opendaylight.l2switch/features-l2switch/${odl-version}/xml/features
feature:repo-add mvn:org.opendaylight.dlux/features-dlux/${odl-version}/xml/features

记得把${odl-version}替换成Nitrogen的具体版本(比如正式发布版0.7.3)。

2. 修正项目pom.xml的依赖配置

你在项目features模块的pom.xml里加依赖时,要补充关键的类型和分类器,不然Maven没法正确拉取特性定义文件:

<dependency>
    <groupId>org.opendaylight.netconf</groupId>
    <artifactId>features-restconf</artifactId>
    <version>${odl-version}</version>
    <type>xml</type>
    <classifier>features</classifier>
</dependency>
<!-- l2switch和dlux的依赖也照这个格式修改 -->

3. 在项目features.xml里显式引用目标特性

你自己项目的features.xml需要把这些外部特性包含到自定义特性中,比如:

<feature name="your-custom-feature" version="your-project-version">
    <!-- 引入所需的OpenDaylight官方特性 -->
    <feature>odl-restconf-all</feature>
    <feature>odl-l2switch-all</feature>
    <feature>odl-dlux-core</feature>
</feature>

注意这里的特性名称要和Nitrogen官方仓库里的定义完全匹配,比如restconf的全量特性是odl-restconf-all,l2switch的是odl-l2switch-all

4. 刷新仓库并重新安装特性

完成上述配置后,在Karaf里执行以下命令更新仓库并安装你的自定义特性:

feature:repo-refresh
feature:install your-custom-feature

之后用feature:list | grep odl就能检查这些功能是否已经成功安装了。

另外提个常见的小坑:Nitrogen对依赖顺序要求更严格,如果你遇到安装失败,可以先执行feature:install odl-base-all确保基础核心环境到位。

内容的提问来源于stack exchange,提问作者Haitham

火山引擎 最新活动