0

我在 /opt/odl_l3vpn/dave/api/src/main/yang 中安装了 OpenDayLight Boron-SR3 和一个测试 YANG 文件。

module DaveTest {

namespace "urn:opendaylight:params:xml:ns:DaveTest";
prefix dm;

import "ietf-inet-types" {
    prefix ietf-yang;
}

description "Dave testing file";

revision "2017-04-17" {
    description "Initial version.";
}



    container testing-vars {

            list test-list {

                    key "vpn-transaction-id";
                    unique "vpn-transaction-id";

                    leaf vpn-transaction-id {
                            type string;
                            description "Generated for the model.";
                    }

                    leaf vpn-id {
                            type string;
                            description "VPN ID for the VPN.";

                    }

            }
    }
}

当我使用“mvn clean install -nsu”编译文件时,出现错误:

[错误] 无法执行目标 org.opendaylight.yangtools:yang-maven-plugin:1.0.3-Boron-SR3:generate-sources (binding) on project dave-api: yang-to-sources: Unable to parse yang 文件来自 /opt/odl_l3vpn/dave/api/src/main/yang:未找到导入的模块 [ietf-inet-types]。[在 META-INF/yang/DaveTest.yang:6:4]

下面的全栈:

[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:1.0.3-Boron-SR3:generate-sources (binding) on project dave-api: yang-to-sources: Unable to parse yang files from /opt/odl_l3vpn/dave/api/src/main/yang: Imported module [ietf-inet-types] was not found. [at META-INF/yang/DaveTest.yang:6:8] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:1.0.3-Boron-SR3:generate-sources (binding) on project dave-api: yang-to-sources: Unable to parse yang files from /opt/odl_l3vpn/dave/api/src/main/yang
at      org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at     org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at     org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: yang-to-sources: Unable to parse yang files from /opt/odl_l3vpn/dave/api/src/main/yang
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.processYang(YangToSourcesProcessor.java:222)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.execute(YangToSourcesProcessor.java:95)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.conditionalExecute(YangToSourcesProcessor.java:118)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesMojo.execute(YangToSourcesMojo.java:119)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: Imported module [ietf-inet-types] was not found. [at META-INF/yang/DaveTest.yang:6:8]
at org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException.throwIf(InferenceException.java:47)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.ImportStatementDefinition$1.prerequisiteFailed(ImportStatementDefinition.java:116)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.ModifierImpl.failModifier(ModifierImpl.java:93)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.failModifiers(SourceSpecificContext.java:294)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.addSourceExceptions(BuildGlobalContext.java:268)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.completePhaseActions(BuildGlobalContext.java:343)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.buildEffective(BuildGlobalContext.java:200)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor$BuildAction.buildEffective(CrossSourceStatementReactor.java:128)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor$BuildAction.buildEffective(CrossSourceStatementReactor.java:145)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.processYang(YangToSourcesProcessor.java:191)
... 25 more

我的 pom.xml 在主目录 /opt/odl_l3vpn/dave 中。我在 'build' 下添加了 'ietf-inet-types 依赖项,但由于我对 pom 文件缺乏了解,可能将其放置在错误的位置。

  <build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <configuration>
      <skip>true</skip>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <configuration>
      <skip>true</skip>
    </configuration>

    <dependencies>
      <dependency>
        <groupId>org.opendaylight.mdsal.model</groupId>
        <artifactId>ietf-inet-types</artifactId>
        <version>2010.09.24.8.5-SNAPSHOT</version>
        <type>bundle</type>
      </dependency>
    </dependencies>

  </plugin>
</plugins>

添加依赖项以便我的 YANG 文件可以编译的合适位置在哪里?或者你能指出我正确的方向吗?提前致谢。

4

2 回答 2

0

感谢大卫,我能够通过执行以下操作找出答案:

我从https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/mdsal/model/ietf-inet-下载了 theietf-yang-types-2010.09.24.9.3-Boron-SR3.jar types/2010.09.24.9.3-Boron-SR3/ 并将其放在 /tmp 目录中。

然后我修改了 project/api/pom.xml 以包含依赖信息。

然后我在项目根目录中运行以下命令: mvn install:install-file -DgroupId=org.opendaylight.mdsal.model -DartifactId=ietf-inet-types -Dversion=2010.09.24.8.5-SNAPSHOT -Dpackaging=bundle -Dfile=/tmp/ietf-yang-types-2010.09.24.9.3-Boron-SR3.jar

'mvn clean install -nsu' 运行良好,一切都已编译。

于 2017-06-12T22:50:52.847 回答
0

哎呀,关于 OpenDaylight 的事情,我实际上可以回答。

在您的日志输出中,您将看到“org.opendaylight.yangtools:yang-maven-plugin”的提及。如果你不配置它,你会得到默认值,这并不多。您将不得不学习如何配置它。您应该能够在 ODL 站点上找到它的文档。如果您有 YangIDE Eclipse 插件(不幸的是不再真正支持它),您可以在它创建的项目中看到示例。

具体来说,我不记得语法,我相信必须将 Yang 依赖项指定为 yang-maven-plugin 配置的一部分。

于 2017-05-24T23:19:44.257 回答