Configure broker URL automatically [message #1746512] |
Mon, 31 October 2016 13:23 |
Nyiri András Messages: 14 Registered: September 2016 |
Junior Member |
|
|
Hello,
I want to install Kura on multiple Raspberrys automatically.
Can I configure the MqttDataTransport broker URL somehow in a configuration file before starting Kura? I can use the MQTT calls to configure services after this has been configured...
I'm thinking maybe I should upload a previously created snapshot to its snapshots directory, but haven't tried yet. Could that work? Whats exactly stored inside these snapshots?
Thanks!
EDIT:
Tryed out the snapshots, the problem is that I need to configure the broker URL at runtime, so a fixed configuration snapshot is not good for me and it looks like I can't dynamically change the IP in the snapshot because I can not deserialize it.
[Updated on: Mon, 31 October 2016 14:03] Report message to a moderator
|
|
|
|
Re: Configure broker URL automatically [message #1746671 is a reply to message #1746599] |
Wed, 02 November 2016 18:01 |
Nyiri András Messages: 14 Registered: September 2016 |
Junior Member |
|
|
Yes, what you recommended was the first think I tried but unfortunately it is not good enough for me, because I have to configure all PIs differently, like adding different MQTT client ID (I know the default MAC is unique but I need something different in my case), and also the MQTT broker URL have to be configurable because it is different in every environment. The problem is that these snapshot files doesn't look editable.
If I write a HTTP servlet, place it in the right directory for Kura to automatically start it and after started I provide the necessary configuration parameters via it's REST API, I could change the MqttDataTransport configuration this way dynamically, right?
[Updated on: Wed, 02 November 2016 18:04] Report message to a moderator
|
|
|
|
Re: Configure broker URL automatically [message #1747360 is a reply to message #1746805] |
Sun, 13 November 2016 18:43 |
Nyiri András Messages: 14 Registered: September 2016 |
Junior Member |
|
|
Thank you for you answer.
Now I'm trying to deploy a simple web bundle which would receive the new MQTT configurations via REST and set it via ConfigurationService.
I'm looking at the org.eclipse.kura.web project as an example for this but trying a simplified approach. Unfortunately it looks like my bundles activate method is not called.
My OSGI-INF/web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
activate="activate"
configuration-policy="require"
deactivate="deactivate"
modified="updated"
name="my.project.RestConfigurator">
<implementation class="my.project.RestConfigurator"/>
<property name="servlet.alias.root" value="/configurator"/>
<reference name="HttpService"
bind="setHttpService"
unbind="unsetHttpService"
interface="org.osgi.service.http.HttpService"/>
<property name="app.root" type="String" value="/configurator"/>
<property name="service.pid" type="String" value="my.project.RestConfigurator"/>
<service>
<provide interface="my.project.RestConfigurator"/>
</service>
</scr:component>
MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: my.project
Bundle-SymbolicName: my.project;singleton:=true
Bundle-Version: 1.0.0.qualifier
Service-Component: OSGI-INF/*.xml
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: javax.servlet;version="2.6.0",
javax.servlet.http;version="2.6.0",
org.eclipse.kura.configuration;version="[1.0,2.0)",
org.eclipse.kura.configuration.metatype;version="[1.0,2.0)",
org.eclipse.kura.core.configuration;version="[1.0,2.0)",
org.eclipse.kura.core.configuration.metatype;version="[1.0,2.0)",
org.eclipse.kura.core.configuration.util;version="[1.0,2.0)",
org.eclipse.kura.core.net.util;version="[1.0,2.0)",
org.osgi.framework;version="1.7.0",
org.osgi.service.http,
org.slf4j;version="1.6.4"
I also have these methods in my activator class:
public void setHttpService(HttpService httpService) {
s_logger.info("Setting HttpService...");
this.m_httpService = httpService;
}
public void unsetHttpService(HttpService httpService) {
s_logger.info("Unsetting HttpService...");
this.m_httpService = null;
}
Does anyone have any idea what could cause that my activator method is not called (I know its not because I have a comment in the beginning of it)?
Also, the setHttpService method is not called...
[Updated on: Sun, 13 November 2016 18:44] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03680 seconds