0

I am having trouble installing a deployment package remotely, following are the metrics I send on the request topic - $EDC/amir-kura/test-client/DEPLOY-V2/EXEC/download

job.id=12345678910L
dp.uri=file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
dp.name=hello_osgi
dp.version=1.0.0
dp.download.protocol=HTTPS
dp.install.system.update=false

The package gets downloaded successfully as I get the following reply on the Notify topic-$EDC/amir-kura/new-client/DEPLOY-V2/NOTIFY/test-client/download

{dp.download.size=0, 
dp.download.progress=100, 
dp.download.status=COMPLETED, 
job.id=12345678910, 
client.id=test-client}

But, the installation fails. Following is my kura console-

15:06:07,357 [MQTT Call: test-client] INFO  CloudServiceImpl:440  - Message arrived on topic: $EDC/amir-kura/test-client/DEPLOY-V2/EXEC/download
15:06:07,382 [pool-2-thread-2] INFO  CloudDeploymentHandlerV2:459  - About to download and install package at URL file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
15:06:07,382 [pool-2-thread-2] INFO  CloudDeploymentHandlerV2:468  - Downloading package from URL: file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
15:06:07,387 [pool-12-thread-1] INFO  DataServiceImpl:441  - Storing message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/download, priority: 1
15:06:07,389 [pool-12-thread-1] INFO  DataServiceImpl:444  - Stored message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/download, priority: 1
15:06:07,402 [DataServiceImpl:Submit] INFO  MqttDataTransport:512  - Publishing message on topic: $EDC/amir-kura/new-client/DEPLOY-V2/NOTIFY/test-client/download with QoS: 1
15:06:07,403 [pool-12-thread-1] INFO  DownloadImpl:131  - Ready to install
15:06:07,405 [pool-2-thread-2] INFO  DataServiceImpl:441  - Storing message on topic :$EDC/#account-name/new-client/DEPLOY-V2/REPLY/REQUEST_M2UIS65D0O7DFILVRH9QF80QKE, priority: 1
15:06:07,423 [pool-2-thread-2] INFO  DataServiceImpl:444  - Stored message on topic :$EDC/#account-name/new-client/DEPLOY-V2/REPLY/REQUEST_M2UIS65D0O7DFILVRH9QF80QKE, priority: 1
15:06:07,430 [DataServiceImpl:Submit] INFO  MqttDataTransport:512  - Publishing message on topic: $EDC/amir-kura/new-client/DEPLOY-V2/REPLY/REQUEST_M2UIS65D0O7DFILVRH9QF80QKE with QoS: 0
!SESSION 2017-05-16 14:51:45.651 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_121
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_IN
Command-line arguments:  -dev file:/home/amir/eclipse/workspaces/kura/.metadata/.plugins/org.eclipse.pde.core/Kura_Emulator_Linux/dev.properties -os linux -ws gtk -arch x86_64 -consoleLog -console

!ENTRY org.apache.felix.deploymentadmin 4 0 2017-05-16 15:06:07.499
!MESSAGE Stream does not contain a valid deployment package: missing manifest!
15:06:07,500 [pool-12-thread-1] INFO  InstallImpl:135  - Install failed!
15:06:07,509 [pool-12-thread-1] INFO  DataServiceImpl:441  - Storing message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/install, priority: 1
15:06:07,535 [pool-12-thread-1] INFO  DataServiceImpl:444  - Stored message on topic :$EDC/#account-name/new-client/DEPLOY-V2/NOTIFY/test-client/install, priority: 1
15:06:07,550 [DataServiceImpl:Submit] INFO  MqttDataTransport:512  - Publishing message on topic: $EDC/amir-kura/new-client/DEPLOY-V2/NOTIFY/test-client/install with QoS: 1
15:06:07,684 [MQTT Call: test-client] INFO  DataServiceImpl:376  - Confirmed message ID: 1348 to store
15:06:07,935 [MQTT Call: test-client] INFO  DataServiceImpl:376  - Confirmed message ID: 1350 to store

According to the error I am sending an invalid deployment package, as it lacks Manifest, but I have created the .dp file as mentioned in the Hello World Example.

How do I solve this ? Noone else seems to have encountered this problem

4

2 回答 2

0

构建部署包时需要注意两件事。

  1. 清单必须是DP 文件中的第一个条目(它只是一个 ZIP 文件)
  2. 包含的捆绑包的顺序很重要,它们必须按照与清单中声明的​​顺序相同的顺序包含在 DP 中

清单作为第一个条目

MANIFEST.MF 文件包含在META-INF/目录中。根据 ZIP 标准,您可以在文件中添加一个条目来创建目录,并在文件中添加第二个条目。这在 DP 格式中不受支持,因此您必须直接将具有完整路径的文件添加为生成的 DP 文件中的第一个条目

例如,使用maven-antrun-plugin打包 DP,您可以在命令上使用filesonly="true"属性:<jar>

<jar destfile="${basedir}/../you.final.dp_1.0.0.dp"
     manifest="${project.build.directory}/dp_stage/META-INF/MANIFEST.MF"
     includes="" filesonly="true">
    <filelist dir="${project.build.directory}/dp_stage/" files="${sortedFiles}"/>
</jar>

捆绑的顺序

如果您的部署包包含多个捆绑包,则它们必须以与清单相同的顺序包含。您可以使用字母顺序,这是可预测的并且效果很好:-)
将您的 JAR 复制到一个文件夹中并以排序方式将它们添加到 DP。使用相同的maven-antrun-plugin

<copy file="${basedir}/../project/target/first.bundle_1.0.0.jar"
      todir="${project.build.directory}/dp_stage/bundles/" />

<copy file="${basedir}/../project2/target/second.bundle_1.0.0.jar"
      todir="${project.build.directory}/dp_stage/bundles/" />

<!-- Files MUST be included in the jar in the same order as they are declared in the DP MANIFEST.
    I used alphabetical order. -->
<!-- https://ant.apache.org/manual/Tasks/jar.html -->
<local name="sortedFiles"/>
<pathconvert property="sortedFiles" pathsep="${line.separator}">
    <sort>
        <fileset dir="${project.build.directory}/dp_stage/" includes="bundles/*"/>
    </sort>
</pathconvert>

我在 github 上有一个个人项目,它正是这样做的,请查看参考。
POM 调用 maven-antrun-plugin
Ant 任务来构建 DP

于 2017-05-17T07:14:17.657 回答
0

我在@Amir 评论后添加了第二个答案。另一个答案没有解决实际问题,但在其他一些情况下可能会有所帮助。

我认为问题在于发送到DEPLOY-V2cloudlet 的指标。

dp.uri=file:/home/amir/Downloads/org.eclipse.kura.example.hello_osgi/resources/dp/hello_osgi.dp
dp.download.protocol=HTTPS

在通知中也有这个指示:

dp.download.size=0

URI 说它是本地文件系统上的 FILE,但协议说使用 HTTPS。

如果您查看DEPLOY-V2 文档,您会读到

Kura 1.4.0 引入了名为“DEPLOY-V2”的 DEPLOY 应用程序的新版本。引入的主要功能与包分发的不同方法有关:设备不是在 MQTT 消息中接收包,而是仅接收下载请求,其中包含通过 HTTP 执行独立下载所需的所有信息
dp.uri(字符串)。强制的。表示部署包的 URI。 dp.download.protocol (String) 强制。指定用于下载包/shell 脚本的协议。必须设置为 HTTP 或 HTTPS。

您需要提供有效的 HTTP URL 以从中下载 DP。

于 2017-05-19T07:30:05.517 回答