Simple remote connectors¶
Prerequisites¶
git checkout origin/osp-web-configuration .
Checkout¶
To checkout this example (first checkout prerequisites)
git checkout origin/simple_remote_connector .
Description¶
This example explains how to create a random value generated by a remote connector.
Steps¶
1. Create an empty module.remote
file in the modules path.¶
The definition of a remote module is done with a single step - define an empty file name module.remote
instead of the module.service
modules/waveforms/waveforms-1/module.remote
# This file is empty
Add the module configuration, as for a normal module, but replace the rabbit
value with the IP of your stack.
modules/waveforms/waveforms-1/module.waveforms
{
"messagingConfiguration":
{
"clientId": "osp-waveforms-1",
"host": "rabbit"
}
}
2. Create a random value generator¶
root/random/value.ospp
{
"name" : "Waveform",
"description" : "",
"type" : "DECIMAL"
}
root/random/owner.waveforms
{
"moduleId": "modules.waveforms.waveforms-1",
"waveformConfigurationEntity": {
"min": 0,
"max": 100,
"type": "DISCRETE_RANDOM",
"seed": 111
},
"samplePeriod": {
"unit": "SECONDS",
"value": 1
}
}
3. Add a dashboard with a value subscription widget¶
root/dashboard.view
{
"configuration": [
{
"valueSubscriptions": {
"values": [
{
"id": "root.random",
"right": "READ_WRITE",
"type": "INTEGER"
}
]
},
"id": "oK1dVAne",
"type": "ValueSubscription",
"title": ""
}
],
"layout": {
"lg": [
{
"w": 4,
"h": 3,
"x": 0,
"y": 0,
"i": "oK1dVAne"
}
]
},
"breakpoints": {
"lg": 1200,
"md": 996,
"sm": 768,
"xs": 480,
"xxs": 0
},
"cols": {
"lg": 12,
"md": 10,
"sm": 6,
"xs": 4,
"xxs": 2
},
"rowHeight": 150
}
4. Push the configuration¶
git add .
git commit -m "Add module.waveform (remote connector)"
git push
5. Check the current configuration¶
Check exposed port
The dispatcher will restart and expose port 10000
(which will be reached by the remote connector to retrieve the configuration).
$ docker service logs | grep dispatcher
sf1f5dux1b0l osp-stack-1_modules_configuration-dispatcher_main replicated 1/1 osp-configuration-dispatcher:<version> *:5022->5022/tcp, *:9102->9100/tcp, *:10000->10000/tcp
Hint
The port is exposed by the service, not by the docker, because the network used is the overlay in SWARM mode.
Check no waveform is running
$ docker service logs | grep waveforms
Check frontend value is unknown for root.random
6. Connect a remote connector¶
In this example, we’ll use the docker container, but a docker service can also be created. Even a SWARM can be created to share the certificate.
Creating a directory for remote certificates :
mkdir /tmp/example-cert
cp /tmp/onsphere/certs/remote-module/modules_waveforms_waveforms-1.crt /tmp/example-cert/module.crt
cp /tmp/onsphere/certs/remote-module/modules_waveforms_waveforms-1.key /tmp/example-cert/module.key
cp /tmp/onsphere/certs/ca/ca.crt /tmp/example-cert/ca.crt
Replace in the following command:
HOST : The Ip of your SWARM
VERSION : The version of your OnSphere stack
docker container run --detach --name=waveform-remote --restart=always --env DISPATCHER_HOST="[HOST]" --env DISPATCHER_PORT="10000" -v /tmp/example-cert:/run/secrets nexus.sdnroot.net/osp-waveforms:[VERSION]