eclipse-kura / kura

Eclipse Kura™ is a versatile framework to supercharge your edge devices, streamlining the process of configuring your gateway, connecting sensors, and IoT devices to seamlessly collect, process, and send data to the cloud.
https://eclipse.dev/kura/
Eclipse Public License 2.0
499 stars 306 forks source link

Multiple Cloud Support - Web UI does not allow to select new installed cloud service #444

Closed pgufAtIBM closed 8 years ago

pgufAtIBM commented 8 years ago

I have created a bundle that allows to connect to Watson IoT Cloud (based on https://github.com/eclipse/kura/wiki/Multiple-Cloud-Connections and with help of Cristiano De Alti). I successfully installed my bundle on Kura gateway on my Raspberry Pi (https://eclipse.org/kura/downloads.php -> Raspbian (Model 2) - Stable version). When I start the bundle, no errors are shown and the bundle changes to state ACTIVE.

In the kura.log following entry is added: INFO o.e.k.c.c.ConfigurationServiceImpl - Registering metatype pid: org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud with ocd: org.eclipse.kura.core.configuration.metatype.Tocd@b55bde ...

Then I switch to the Web UI, select "Status" -> "Connect" the newly installed bundle for cloud connection does not show up.

Is there a way to activate the bundle over console? If yes, how? Can I deactivate in the meantime the default bundle so that only my bundle is connected to Watson IoT (cause both would use the same MqttDataTransport configuration...

Thank you for your help!

cdealti commented 8 years ago

@pgufAtIBM I copy here the contents of the email I've just set you:

I've installed your bundle. There are no configurations of your org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud (see below).

You have to create at least one configuration or nothing will show up in the Web UI. The simplest way is to add a gogo shell command in declarative service of your CloudServiceFactory. Please take a look to:

https://github.com/eclipse/kura/blob/develop/kura/org.eclipse.kura.core.cloud/OSGI-INF/cloudServiceFactory.xml

You basically have to provide a command to the gogo shell setting to properties:

<property name="osgi.command.scope" type="String" value="kura.cloud"/>
<property name="osgi.command.function" type="String">
createConfiguration
</property>

Just make sure you use a different command scope, for example watson.iot.cloud.

Then from the gogo shell just type:

watson.iot.cloud:createConfiguration <configuration pid>

This should create a configuration and the services should appear in the Web UI.

osgi> ls
All Components:
ID    State            Component Name            Located in bundle
1    Active        org.eclipse.kura.usb.UsbService            org.eclipse.kura.emulator.usb(bid=5)
2    Active        org.eclipse.kura.clock.ClockService            org.eclipse.kura.emulator.clock(bid=7)
3    Active        org.eclipse.kura.crypto.CryptoService            org.eclipse.kura.core.crypto(bid=8)
4    Active        org.eclipse.kura.watchdog.WatchdogService            org.eclipse.kura.emulator.watchdog(bid=21)
5    Active        org.eclipse.kura.certificate.CertificatesService            org.eclipse.kura.core.certificates(bid=24)
6    Active        org.eclipse.kura.status.CloudConnectionStatusService            org.eclipse.kura.core.status(bid=26)
7    Active        org.eclipse.kura.log.LoggerService            org.eclipse.kura.core.log(bid=33)
8    Active        org.eclipse.kura.cloud.app.command.CommandCloudApp            org.eclipse.kura.core.cloud(bid=34)
9    Active        org.eclipse.kura.core.cloud.factory.DefaultCloudServiceFactory            org.eclipse.kura.core.cloud(bid=34)
10    Active        org.eclipse.kura.cloud.CloudCallService            org.eclipse.kura.core.cloud(bid=34)
11    Active        org.eclipse.kura.cloud.CloudService            org.eclipse.kura.core.cloud(bid=34)
12    Active        org.eclipse.kura.core.comm.CommConnectionFactory            org.eclipse.kura.core.comm(bid=36)
13    Active        org.eclipse.kura.deployment.agent            org.eclipse.kura.deployment.agent(bid=39)
14    Active        org.eclipse.kura.position.PositionService            org.eclipse.kura.emulator.position(bid=42)
15    Active        org.eclipse.kura.emulator.Emulator            org.eclipse.kura.emulator(bid=43)
16    Active        org.eclipse.kura.web.Console            org.eclipse.kura.web(bid=47)
17    Active        org.eclipse.kura.system.SystemAdminService            org.eclipse.kura.core(bid=52)
18    Active        org.eclipse.kura.ssl.SslManagerService            org.eclipse.kura.core(bid=52)
19    Active        org.eclipse.kura.db.DbService            org.eclipse.kura.core(bid=52)
20    Active        org.eclipse.kura.system.SystemService            org.eclipse.kura.core(bid=52)
21    Active        org.eclipse.kura.data.DataService            org.eclipse.kura.core(bid=52)
22    Active        org.eclipse.kura.core.data.transport.mqtt.MqttDataTransport            org.eclipse.kura.core(bid=52)
23    Active        org.eclipse.equinox.event            org.eclipse.equinox.event(bid=59)
24    Active        org.eclipse.kura.net.NetworkService            org.eclipse.kura.emulator.net(bid=61)
25    Active        org.eclipse.kura.configuration.ConfigurationService            org.eclipse.kura.core.configuration(bid=62)
26    Active        org.eclipse.kura.core.configuration.CloudConfigurationHandler            org.eclipse.kura.core.configuration(bid=62)
27    Active        org.eclipse.kura.gpio.GPIOService            org.eclipse.kura.emulator.gpio(bid=63)
28    Active        org.eclipse.kura.core.deployment.CloudDeploymentHandlerV2            org.eclipse.kura.core.deployment(bid=67)
29    Unsatisfied        org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud            org.eclipse.kura.core.cloud.watsoniot(bid=75)
30    Active        org.eclipse.kura.core.cloud.watsoniot.factory.WatsonIoTCloudServiceFactory            org.eclipse.kura.core.cloud.watsoniot(bid=75)
osgi> comp 29
    Component[
    name = org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud
    activate = activate
    deactivate = deactivate
    modified = updated
    configuration-policy = require
    factory = null
    autoenable = true
    immediate = false
    implementation = org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloudServiceImpl
    state = Unsatisfied
    properties = {service.pid=org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud}
    serviceFactory = false
    serviceInterface = [org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud, org.eclipse.kura.configuration.ConfigurableComponent]
    references = {
        Reference[name = DataService, interface = org.eclipse.kura.data.DataService, policy = static, cardinality = 1..1, target = null, bind = setDataService, unbind = unsetDataService]
    }
    located in bundle = org.eclipse.kura.core.cloud.watsoniot_1.0.0.201608092134 [75]
]
Dynamic information :
  The component is satisfied
  All component references are satisfied
  Component configurations :
  *The component has NO built configurations! The reason might be that it requires initialization by configuration provided by Configuration Admin but none was found
cdealti commented 8 years ago

Is there a way to activate the bundle over console? If yes, how? Can I deactivate in the meantime the default bundle so that only my bundle is connected to Watson IoT (cause both would use the same MqttDataTransport configuration...

You don't need to deactivate the default Kura connection. You CloudServiceFactory should create its own instances of the DataService and MqttDataTransport.

pgufAtIBM commented 8 years ago

I have modified now my bundle project and added a cloudServiceFactory.xml in folder OSGI-INF with following content: `<?xml version="1.0" encoding="UTF-8"?>

createConfiguration ` Then I built the bundle, installed it on kura (osgi> install file:/home/pi/....), started the bundle (osgi> start ) and then executed following command: osgi> watson.iot.cloud:createConfiguration org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud Executing this command, an exception follows: gogo: KuraException: Generic Error - INVALID_PARAMETER: org.eclipse.kura.cloud.WatsonIoTCloud I looked up in the logs, there I found following entry: ConfigurationServiceImpl - Registering metatype pid: org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud with ocd: org.eclipse.kura.core.configuration.metatype.Tocd@b55bde ... kura.log 2016-08-10 09:53:03,320 [Thread-13] INFO o.e.k.c.c.ConfigurationServiceImpl - Creating new configuration for factory pid org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud and pid org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud 2016-08-10 09:53:03,321 [Thread-13] INFO o.e.k.c.c.ConfigurationServiceImpl - Updating newly created configuration for pid org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud 2016-08-10 09:53:03,322 [Thread-13] INFO o.e.k.c.c.ConfigurationServiceImpl - Merging configuration for pid: org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud 2016-08-10 09:53:03,345 [Thread-13] INFO o.e.k.c.c.ConfigurationServiceImpl - Registration of ConfigurableComponent org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud by org.eclipse.kura.core.configuration.ConfigurationServiceImpl@1d9638b... 2016-08-10 09:53:03,375 [Thread-13] INFO o.e.k.c.c.ConfigurationServiceImpl - Seeding updated configuration for pid: org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud 2016-08-10 09:53:03,377 [ConfigurationListener Event Queue] INFO o.e.k.c.c.ConfigurationServiceImpl - ConfigurationEvent for tracked ConfigurableComponent with pid: org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud 2016-08-10 09:53:03,378 [ConfigurationListener Event Queue] INFO o.e.k.c.c.ConfigurationServiceImpl - Writing snapshot - Getting component configurations... 2016-08-10 09:53:03,394 [Thread-13] WARN o.e.k.KuraException - Could not load Exception Messages Bundle for Locale en_US 2016-08-10 09:53:03,609 [ConfigurationListener Event Queue] WARN o.e.k.n.a.v.l.WpaSupplicantConfigReader - WPA in client mode is not configured 2016 According to kura-console.log the watson iot bundle cannot be activated (according to ss command the bundle is activated). The corresponding log entries: !ENTRY org.eclipse.kura.core.cloud.watsoniot 4 0 2016-08-10 09:53:03.522 !MESSAGE FrameworkEvent ERROR !STACK 0 org.osgi.framework.ServiceException: Exception in org.eclipse.equinox.internal.ds.ServiceReg.getService() at org.eclipse.osgi.internal.serviceregistry.ServiceUse.getService(ServiceUse.java:151) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:468) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:467) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.getService(BundleContextImpl.java:594) at org.osgi.util.tracker.ServiceTracker.addingService(ServiceTracker.java:411) at org.eclipse.kura.core.configuration.ConfigurableComponentTracker.addingService(ConfigurableComponentTracker.java:109) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1) at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:894) at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.setProperties(ServiceRegistrationImpl.java:171) at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.modify(ServiceComponentProp.java:197) at org.eclipse.equinox.internal.ds.InstanceProcess.modifyComponent(InstanceProcess.java:690) at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationChange(SCRManager.java:523) at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:385) at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:303) at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:91) at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70) Caused by: org.osgi.service.component.ComponentException: [SCR] Cannot activate instance org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloudServiceImpl@57db34 of component Component[ name = org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud activate = activate deactivate = deactivate modified = updated configuration-policy = require factory = null autoenable = true immediate = false implementation = org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloudServiceImpl state = Unsatisfied properties = {service.pid=org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud} serviceFactory = false serviceInterface = [org.eclipse.kura.core.cloud.watsoniot.WatsonIoTCloud, org.eclipse.kura.configuration.ConfigurableComponent] references = { Reference[name = DataService, interface = org.eclipse.kura.data.DataService, policy = static, cardinality = 1..1, target = null, bind = setDataService, unbind = unsetDataService] } located in bundle = org.eclipse.kura.core.cloud.watsoniot_1.0.0.201608112203 [73] ]! The specified activate method was not found! When I execute the ls command, the state of the watsoniotcloud bundle is unsatisfied. I looked at the default cloud project and compared it to watson iot project. In both projects, in manifest file the activate field is empty, no value is set. Can you please provide me more guidance what configuration is wrong. Thank you!!
cdealti commented 8 years ago

@pgufAtIBM Closing this because the issue is not tracked in #515. Please comment #515.