Предварительно запрограммированная функция устанавливается при запуске apache karaf
Я работаю над проектом opendaylight, который использует apache karaf. В начале программы мне нужен 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
Я также знаю, что добавление элемента featuresBoot в org.apache.karaf.features.cfg
featuresBoot = 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, чтобы найти правильный синтаксис или найти примеры этого. На самом деле, когда я решаю эту проблему в Google, я получаю совет типа "используйте файл shell.init.script" без примера или ссылки на документацию о том, как его использовать.
Например, вот сценарий аналогичного вопроса для запуска команд при запуске 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, и оболочка, казалось, зависла (похоже, что она обрабатывала команду), но после того, как курсор вернулся ко мне, ничего не было.
Спасибо @jamo, поскольку его ответ привел меня к ответу. Мне нужно было только добавить это в 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 по умолчанию, и я гарантирую, что оно осталось там.
1 ответ
Мы используем файл org.apache.karaf.features.cfg исключительно в тесте исходной системы ODL. вы можете увидеть это в этом журнале, но, в частности, вот как это выглядит для одной из наших задач 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
У вас есть опечатка в вопросе с featuresBook, но я предполагаю, что это просто опечатка, а не ваша проблема. Очень странно, что фича: установка работает, но не фичи Boot.