在 apache karaf 发布时安装预编程功能 [英] Pre-programmed feature installs at apache karaf launch

查看:32
本文介绍了在 apache karaf 发布时安装预编程功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 apache karaf 的 opendaylight 项目.在程序开始时,我需要 karaf 来安装一些功能.目前(并且这有效)我手动将其输入到 shell 中并安装了功能:

I am working on an opendaylight project that uses apache karaf. At the start of the program, I need karaf to have some features installed. Currently (and this works) I manually type this into the shell and the features get installed:

$ bin/karaf
Apache Karaf starting up. Press Enter to open the shell now...
100% [========================================================================]
Karaf started in 9s. Bundle stats: 409 active, 410 total

    ________                       ________                .__  .__       .__     __
    \_____  \ ______   ____   ____ \______ \ _____  ___.__.|  | |__| ____ |  |___/  |_
     /   |   \\____ \_/ __ \ /    \ |    |  \\__  \<   |  ||  | |  |/ ___\|  |  \   __\
    /    |    \  |_> >  ___/|   |  \|    `   \/ __ \\___  ||  |_|  / /_/  >   Y  \  |
    \_______  /   __/ \___  >___|  /_______  (____  / ____||____/__\___  /|___|  /__|
            \/|__|        \/     \/        \/     \/\/            /_____/      \/


Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight.

opendaylight-user@root>feature:install odl-restconf odl-mdsal-apidocs odl-openflowplugin-flow-services-rest odl-openflowplugin-app-table-miss-enforcer odl-openflowplugin-nxm-extensions odl-restconf-all odl-openflowplugin-flow-services
opendaylight-user@root>

所有这些都有效.但是,我需要的是在开始时自动安装此功能.我知道有一个 shell.init.script 文件,我试图将此行添加到它的底部:

All this works. However, what I need is for this feature install to occur at the start automatically. I am aware there is a shell.init.script file and I have attempted to add this line to the botton of it:

<代码>功能:安装 odl-restconf odl-mdsal-apidocs odl-openflowplugin-flow-services-rest odl-openflowplugin-app-table-miss-enforcer odl-openflowplugin-nxm-extensions odl-restconf-all odl-openflowplugin-flow-services

但是当我这样做时,我收到以下错误:

But when I do this, I get the following error:

/opt/opendaylight-0.11.0/etc/shell.init.script:找不到命令:功能:安装

我也知道将 featuresBoot 元素添加到 org.apache.karaf.features.cfg

I am also aware that adding a featuresBoot element to org.apache.karaf.features.cfg

featuresBoot = odl-restconf(为了便于测试,我将其缩短为一个特性)

featuresBoot = odl-restconf (I shortened it to just one feature for ease of testing)

我收到此错误:

org.apache.felix.resolver.reason.ReasonException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=odl-restconf; type=karaf.feature; version="[1.10.0,1.10.0]"; filter:="(&(osgi.identity=odl-restconf)(type=karaf.feature)(version>=1.10.0)(version<=1.10.0))" [caused by: Unable to resolve odl-restconf/1.10.0: missing requirement [odl-restconf/1.10.0] osgi.identity; osgi.identity=odl-restconf-nb-rfc8040; type=karaf.feature; version="[1.10.0,1.10.0]" [caused by: Unable to resolve odl-restconf-nb-rfc8040/1.10.0: missing requirement [odl-restconf-nb-rfc8040/1.10.0] osgi.identity; osgi.identity=odl-restconf-common; type=karaf.feature; version="[1.10.0,1.10.0]" [caused by: Unable to resolve odl-restconf-common/1.10.0: missing requirement [odl-restconf-common/1.10.0] osgi.identity; osgi.identity=odl-mdsal-broker; type=karaf.feature; version="[1.10.0,1.10.0]" [caused by: Unable to resolve odl-mdsal-broker/1.10.0: missing requirement [odl-mdsal-broker/1.10.0] osgi.identity; osgi.identity=org.opendaylight.controller.sal-binding-broker-impl; type=osgi.bundle; version="[1.10.0,1.10.0]"; resolution:=mandatory [caused by: Unable to resolve org.opendaylight.controller.sal-binding-broker-impl/1.10.0: missing requirement [org.opendaylight.controller.sal-binding-broker-impl/1.10.0] osgi.wiring.package; filter:="(&(osgi.wiring.package=org.osgi.service.blueprint)(version>=1.0.0)(!(version>=2.0.0)))"]]]]]

所以,我可以说 karaf 至少承认了 shell.init.script 和 org.apache.karaf.features.cfg,但是我显然使用了错误的语法.我已经用尽我的谷歌搜索找到正确的语法或找到这样的例子.事实上,当我针对这个问题使用 google 搜索时,我得到的建议是使用 shell.init.script"文件,但没有示例或文档链接以了解如何使用它.

So, I can tell that karaf is at least acknowledging the shell.init.script and org.apache.karaf.features.cfg, however I am clearly using the wrong syntax. I have exhausted my googling in finding the right syntax or finding examples of this. In fact, when I do google for this issue, I get advice along the lines of "use the shell.init.script" file, without an example or a link to documentation for how to use it.

例如,这里有一个类似的问题 在 apache karaf 开始时运行命令的脚本,但答案确实不是't 完整或完整.我不知道把建议的命令等放在哪里.

For example, here is a similar question script to run commands at start of apache karaf but the answers really aren't full or complete. I don't know where to put the suggested commands, etc.

无论如何,我希望这里有人可以告诉我在 shell.init.script 或 org.apache.karaf.features.cfg 中使用什么特定命令来实现这一目标.(目标是完成我可以手动成功完成的等效初始化命令,如顶部所述)

Anyway, I hope someone here can show me what specific command one uses in either shell.init.script or org.apache.karaf.features.cfg to accomplish this goal. (The goal being the equivalent initialization command to accomplish what I can successfully do manually as noted at the top)

更新:我也试过这种类型的命令:

Update: I also tried this type of command:

echo "feature:install odl-restconf odl-mdsal-apidocs odl-openflowplugin-flow-services-rest odl-openflowplugin-app-table-miss-enforcer odl-openflowplugin-nxm-extensions odl-restconf-所有 odl-openflowplugin-flow-services" |/opt/opendaylight-0.11.0/bin/karaf

这也不起作用.我没有收到任何错误消息,我只知道我的 restconf 不起作用.有趣的是,我确实看到所有功能都通过管道传输到 karaf shell 中,并且 shell 似乎确实冻结了(似乎正在处理命令)但在光标返回给我后却无法运行.

Which also didn't work. I don't get any error messages, I just know my restconf isn't working. Funny enough I did see all the features getting piped into the karaf shell, and the shell did seem to freeze up (seemingly like it was processing the command) but no-go after the cursor returned to me.

感谢@jamo,他的回答让我找到了答案.我只需要将此添加到 etc/org.apache.karaf.features.cfg:

Thanks to @jamo as his answer lead me to the answer. I needed to only add this to etc/org.apache.karaf.features.cfg:

featuresBoot = odl-restconf,odl-mdsal-apidocs,odl-openflowplugin-flow-services-rest,odl-openflowplugin-app-table-miss-enforcer,odl-openflowplugin-nxm-extensions,odl-restconf-all,odl-openflowplugin-flow-services, 25921329-8d07-420b-af13-94948bf1a78d

我相信诀窍是使用最终的 25921329-8d07-420b-af13-94948bf1a78d,这是默认 cfg 文件中的一些十六进制值,我确保它留在那里.

I believe the trick was having the final 25921329-8d07-420b-af13-94948bf1a78d which is some hex value that is in the default cfg file and I ensure it stayed in there.

推荐答案

我们只在上游 ODL 中使用 org.apache.karaf.features.cfg 文件系统测试.您可以在此日志中看到它,但具体来说,这里是它看起来像我们的 yangtools 工作之一:

we use the org.apache.karaf.features.cfg file exclusively in upstream ODL system test. you can see it inside this log, but specifically, here is what it looks like for one of our yangtools jobs:

################################################################################
#
#    Licensed to the Apache Software Foundation (ASF) under one or more
#    contributor license agreements.  See the NOTICE file distributed with
#    this work for additional information regarding copyright ownership.
#    The ASF licenses this file to You under the Apache License, Version 2.0
#    (the "License"); you may not use this file except in compliance with
#    the License.  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#
################################################################################

#
# Comma separated list of features repositories to register by default
#
featuresRepositories = mvn:org.opendaylight.integration/features-test/0.12.1-SNAPSHOT/xml/features,mvn:org.apache.karaf.decanter/apache-karaf-decanter/1.2.0/xml/features, file:${karaf.etc}/5edc7e82-415e-4254-9731-f87670633bcb.xml

#
# Comma separated list of features to install at startup
#
featuresBoot = odl-infrautils-ready,odl-restconf, a3fb0299-0563-4506-b1a0-059253ab43b4

#
# Resource repositories (OBR) that the features resolver can use
# to resolve requirements/capabilities
#
# The format of the resourceRepositories is 
# resourceRepositories=[xml:url|json:url],...
# for Instance:
#
#resourceRepositories=xml:http://host/path/to/index.xml
# or
#resourceRepositories=json:http://host/path/to/index.json
#

#
# Defines if the boot features are started in asynchronous mode (in a dedicated thread)
#
featuresBootAsynchronous=false

#
# Service requirements enforcement
#
# By default, the feature resolver checks the service requirements/capabilities of
# bundles for new features (xml schema >= 1.3.0) in order to automatically installs
# the required bundles.
# The following flag can have those values:
#   - disable: service requirements are completely ignored
#   - default: service requirements are ignored for old features
#   - enforce: service requirements are always verified
#
#serviceRequirements=default

#
# Store cfg file for config element in feature
#
#configCfgStore=true

#
# Configuration of features processing mechanism (overrides, blacklisting, modification of features)
# XML file defines instructions related to features processing
# versions.properties may declare properties to resolve placeholders in XML file
# both files are relative to ${karaf.etc}
#
#featureProcessing=org.apache.karaf.features.xml
#featureProcessingVersions=versions.properties

你在 featuresBook 的问题中有一个错字,但我猜那是只是一个错字,不是你的问题.功能很奇怪:安装工作,但不是 featuresBoot.

You have a typo in your question with featuresBook, but I am guessing that's just a typo on not your problem. It's very strange that feature:install works, but not featuresBoot.

这篇关于在 apache karaf 发布时安装预编程功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆