apache karaf启动时安装了预编程功能

问题描述 投票:0回答:1

我正在使用apache karaf的opendaylight项目中工作。在程序开始时,我需要karaf安装一些功能。当前(并且有效),我手动在外壳中键入了此功能,并安装了功能:

$ 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文件,并且我试图将此行添加到它的底部:

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

但是执行此操作时,出现以下错误:

/opt/opendaylight-0.11.0/etc/shell.init.script: Command not found: feature:install

我也知道向org.apache.karaf.features.cfg添加featuresBoot元素>

[featuresBook = odl-restconf(为了简化测试,我将其简化为一个功能)

我收到此错误:

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”文件的建议,没有示例或如何使用它的文档链接。

例如,这是一个类似的问题script to run commands at start of apache karaf,但答案确实不完整或不完整。我不知道将建议的命令放在哪里,等等。

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

更新:我也尝试过这种命令:

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-all odl-openflowplugin-flow-services" | /opt/opendaylight-0.11.0/bin/karaf

这也没有用。我没有收到任何错误消息,只是知道我的restconf无法正常工作。有趣的是,我确实看到所有功能都通过管道传递到了karaf shell中,并且该shell确实冻结了(似乎就像在处理命令一样),但是在光标返回给我之后却停了下来。

我正在使用apache karaf的opendaylight项目中工作。在程序开始时,我需要karaf安装一些功能。当前(并且可行),我手动将其键入到...

apache-karaf opendaylight apache-karaf-feature
1个回答
0
投票

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

################################################################################
#
#    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
© www.soinside.com 2019 - 2024. All rights reserved.