Plugin Manager updated. Added installation guides.
Change-Id: I1e94c2e63bb2acd239e0e6f4b4d9cfaa2625d9bd
This commit is contained in:
parent
039051b773
commit
f953021d76
|
@ -8,4 +8,5 @@ iotronic_lightningrod.egg-info
|
|||
build
|
||||
AUTHORS
|
||||
Authors
|
||||
ChangeLog
|
||||
ChangeLog
|
||||
*.md
|
12
README.rst
12
README.rst
|
@ -11,7 +11,13 @@ board-side probe.
|
|||
* Source: https://github.com/openstack/iotronic-lightning-rod
|
||||
* Bugs: https://bugs.launchpad.net/iotronic-lightning-rod
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* TODO
|
||||
Installation guides
|
||||
-------------------
|
||||
|
||||
* `Arduino YUN <https://github.com/MDSLab/iotronic-lightning-rod-agent/blob/master/doc/installation/arduino_yun.rst>`_.
|
||||
|
||||
* `Ubuntu 16.04 <https://github.com/MDSLab/iotronic-lightning-rod-agent/blob/master/doc/installation/ubuntu1604.rst>`_.
|
||||
|
||||
* `Raspberry Pi 3 <https://github.com/MDSLab/iotronic-lightning-rod-agent/blob/master/doc/installation/raspberry_pi_3.rst>`_.
|
||||
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
IoTronic Lightning-rod installation guide for Arduino YUN
|
||||
=========================================================
|
||||
|
||||
We tested this procedure on a Arduino YUN board with OpenWRT LininoIO
|
||||
image.
|
||||
|
||||
Install from source code
|
||||
------------------------
|
||||
|
||||
Install requirements
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Install Python and PIP:
|
||||
'''''''''''''''''''''''
|
||||
|
||||
::
|
||||
|
||||
opkg update
|
||||
opkg install python-setuptools
|
||||
easy_install pip
|
||||
|
||||
Install dependencies
|
||||
''''''''''''''''''''
|
||||
|
||||
::
|
||||
|
||||
opkg install git bzip2 python-netifaces
|
||||
pip install --no-cache-dir zope.interface pyserial Babel oslo.config oslo.log
|
||||
easy_install httplib2
|
||||
|
||||
Install Autobahn:
|
||||
'''''''''''''''''
|
||||
|
||||
::
|
||||
|
||||
# Install Twisted:
|
||||
wget --no-check-certificate https://pypi.python.org/packages/source/T/Twisted/Twisted-14.0.2.tar.bz2
|
||||
bzip2 -d Twisted-14.0.2.tar.bz2
|
||||
tar -xvf Twisted-14.0.2.tar
|
||||
cd Twisted-14.0.2/
|
||||
vi setup.py
|
||||
|
||||
comment line 63:
|
||||
#conditionalExtensions=getExtensions(),
|
||||
|
||||
python setup.py install
|
||||
cd /opt/
|
||||
rm -rf /opt/Twisted-14.0.2*
|
||||
|
||||
::
|
||||
|
||||
easy_install autobahn
|
||||
|
||||
Set up environment:
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
mkdir -p /var/lib/iotronic
|
||||
mkdir /var/lib/iotronic/plugins
|
||||
mkdir /var/log/iotronic/
|
||||
mkdir /etc/iotronic
|
||||
|
||||
Install Lightning-rod
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Get source code
|
||||
'''''''''''''''
|
||||
|
||||
::
|
||||
|
||||
cd /var/lib/iotronic
|
||||
git clone git://github.com/MDSLab/iotronic-lightning-rod-agent.git
|
||||
mv iotronic-lightning-rod-agent/ iotronic-lightning-rod/
|
||||
|
||||
Deployment
|
||||
''''''''''
|
||||
|
||||
::
|
||||
|
||||
cd iotronic-lightning-rod/
|
||||
cp etc/iotronic/iotronic.conf /etc/iotronic/
|
||||
cp settings.example.json /var/lib/iotronic/settings.json
|
||||
cp plugins.example.json /var/lib/iotronic/plugins.json
|
||||
cp etc/init.d/lightning-rod /etc/init.d/lightning-rod
|
||||
chmod +x /etc/init.d/lightning-rod
|
||||
touch /var/log/iotronic/lightning-rod.log
|
||||
|
||||
- Edit configuration file:
|
||||
|
||||
nano /var/lib/iotronic/settings.json
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
"iotronic": {
|
||||
"board": {
|
||||
"token": "<REGISTRATION-TOKEN>"
|
||||
},
|
||||
"wamp": {
|
||||
"registration-agent": {
|
||||
"url": "ws://<WAMP-SERVER>:<WAMP-PORT>/",
|
||||
"realm": "<IOTRONIC-REALM>"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- Set up logrotate:
|
||||
|
||||
nano /etc/logrotate.d/lightning-rod.log
|
||||
|
||||
::
|
||||
|
||||
/var/log/iotronic/lightning-rod.log {
|
||||
weekly
|
||||
rotate = 3
|
||||
compress
|
||||
su root root
|
||||
maxsize 5M
|
||||
}
|
||||
|
||||
Building
|
||||
''''''''
|
||||
|
||||
::
|
||||
|
||||
cd /var/lib/iotronic/iotronic-lightning-rod/
|
||||
python setup.py install
|
||||
|
||||
Execution:
|
||||
~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
/etc/init.d/lightning-rod restart
|
||||
|
||||
tail -f /var/log/iotronic/lightning-rod.log
|
|
@ -0,0 +1,99 @@
|
|||
IoTronic Lightning-rod installation guide for Raspberry Pi 3
|
||||
============================================================
|
||||
|
||||
We tested this procedure on a Raspberry Pi 3 board.
|
||||
|
||||
Install from source code
|
||||
------------------------
|
||||
|
||||
Install requirements
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
pip install oslo-config oslo_log twisted autobahn httplib2
|
||||
|
||||
Set up environment:
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
mkdir -p /var/lib/iotronic
|
||||
mkdir /var/lib/iotronic/plugins
|
||||
mkdir /var/log/iotronic/
|
||||
mkdir /etc/iotronic
|
||||
|
||||
Install Lightning-rod
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Get source code
|
||||
'''''''''''''''
|
||||
|
||||
::
|
||||
|
||||
cd /var/lib/iotronic
|
||||
git clone git://github.com/MDSLab/iotronic-lightning-rod-agent.git
|
||||
mv iotronic-lightning-rod-agent/ iotronic-lightning-rod/
|
||||
|
||||
Deployment
|
||||
''''''''''
|
||||
|
||||
::
|
||||
|
||||
cd iotronic-lightning-rod/
|
||||
cp etc/iotronic/iotronic.conf /etc/iotronic/
|
||||
cp settings.example.json /var/lib/iotronic/settings.json
|
||||
cp plugins.example.json /var/lib/iotronic/plugins.json
|
||||
cp etc/systemd/system/s4t-lightning-rod.service /etc/systemd/system/lightning-rod.service
|
||||
chmod +x /etc/systemd/system/lightning-rod.service
|
||||
systemctl daemon-reload
|
||||
|
||||
- Edit configuration file:
|
||||
|
||||
- nano /var/lib/iotronic/settings.json
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
"iotronic": {
|
||||
"board": {
|
||||
"token": "<REGISTRATION-TOKEN>"
|
||||
},
|
||||
"wamp": {
|
||||
"registration-agent": {
|
||||
"url": "ws://<WAMP-SERVER>:<WAMP-PORT>/",
|
||||
"realm": "<IOTRONIC-REALM>"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- setup logrotate:
|
||||
- nano /etc/logrotate.d/lightning-rod.log
|
||||
|
||||
::
|
||||
|
||||
/var/log/iotronic/lightning-rod.log {
|
||||
weekly
|
||||
rotate = 3
|
||||
compress
|
||||
su root root
|
||||
maxsize 5M
|
||||
}
|
||||
|
||||
Building
|
||||
''''''''
|
||||
|
||||
::
|
||||
|
||||
cd /var/lib/iotronic/iotronic-lightning-rod/
|
||||
python setup.py install
|
||||
|
||||
Execution:
|
||||
~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
systemctl restart lightning-rod.service
|
||||
|
||||
tail -f /var/log/iotronic/lightning-rod.log
|
|
@ -0,0 +1,100 @@
|
|||
IoTronic Lightning-rod installation guide for Ubuntu 16.04
|
||||
==========================================================
|
||||
|
||||
We tested this procedure on a Ubuntu 16.04 (also within a LXD
|
||||
container). Everything needs to be run as root.
|
||||
|
||||
Install from source code via Git
|
||||
--------------------------------
|
||||
|
||||
Install requirements
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
pip install oslo-config oslo_log twisted autobahn httplib2
|
||||
|
||||
Set up environment:
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
mkdir -p /var/lib/iotronic
|
||||
mkdir /var/lib/iotronic/plugins
|
||||
mkdir /var/log/iotronic/
|
||||
mkdir /etc/iotronic
|
||||
|
||||
Install Lightning-rod
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Get source code
|
||||
'''''''''''''''
|
||||
|
||||
::
|
||||
|
||||
cd /var/lib/iotronic
|
||||
git clone git://github.com/MDSLab/iotronic-lightning-rod-agent.git
|
||||
mv iotronic-lightning-rod-agent/ iotronic-lightning-rod/
|
||||
|
||||
Deployment
|
||||
''''''''''
|
||||
|
||||
::
|
||||
|
||||
cd iotronic-lightning-rod/
|
||||
cp etc/iotronic/iotronic.conf /etc/iotronic/
|
||||
cp settings.example.json /var/lib/iotronic/settings.json
|
||||
cp plugins.example.json /var/lib/iotronic/plugins.json
|
||||
cp etc/systemd/system/s4t-lightning-rod.service /etc/systemd/system/lightning-rod.service
|
||||
chmod +x /etc/systemd/system/lightning-rod.service
|
||||
systemctl daemon-reload
|
||||
|
||||
- Edit configuration file:
|
||||
|
||||
- nano /var/lib/iotronic/settings.json
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
"iotronic": {
|
||||
"board": {
|
||||
"token": "<REGISTRATION-TOKEN>"
|
||||
},
|
||||
"wamp": {
|
||||
"registration-agent": {
|
||||
"url": "ws://<WAMP-SERVER>:<WAMP-PORT>/",
|
||||
"realm": "<IOTRONIC-REALM>"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- setup logrotate:
|
||||
- nano /etc/logrotate.d/lightning-rod.log
|
||||
|
||||
::
|
||||
|
||||
/var/log/iotronic/lightning-rod.log {
|
||||
weekly
|
||||
rotate = 3
|
||||
compress
|
||||
su root root
|
||||
maxsize 5M
|
||||
}
|
||||
|
||||
Building
|
||||
''''''''
|
||||
|
||||
::
|
||||
|
||||
cd /var/lib/iotronic/iotronic-lightning-rod/
|
||||
python setup.py install
|
||||
|
||||
Execution:
|
||||
~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
systemctl restart lightning-rod.service
|
||||
|
||||
tail -f /var/log/iotronic/lightning-rod.log
|
|
@ -693,7 +693,7 @@ class PluginManager(Module.Module):
|
|||
w_msg = yield WM.WampError(str(err))
|
||||
returnValue(w_msg.serialize())
|
||||
|
||||
def PluginReboot(self, plugin_uuid):
|
||||
def PluginReboot(self, plugin_uuid, parameters=None):
|
||||
"""To reboot an asynchronous plugin (callable = false) into the board.
|
||||
|
||||
:return: return a response to RPC request
|
||||
|
@ -705,6 +705,9 @@ class PluginManager(Module.Module):
|
|||
LOG.info("RPC " + rpc_name + " CALLED for '"
|
||||
+ plugin_uuid + "' plugin:")
|
||||
|
||||
LOG.info(" - plugin restarting with parameters:")
|
||||
LOG.info(" " + str(parameters))
|
||||
|
||||
try:
|
||||
|
||||
plugin_home = iotronic_home + "/plugins/" + plugin_uuid
|
||||
|
@ -721,15 +724,21 @@ class PluginManager(Module.Module):
|
|||
|
||||
worker = PLUGINS_THRS[plugin_uuid]
|
||||
|
||||
# STOP PLUGIN----------------------------------------------
|
||||
|
||||
if worker.isAlive():
|
||||
# STOP PLUGIN------------------------------------------
|
||||
|
||||
LOG.info(" - Thread "
|
||||
+ plugin_uuid + " is running, stopping...")
|
||||
LOG.debug(" - Stopping plugin " + str(worker))
|
||||
worker.stop()
|
||||
|
||||
while worker.isAlive():
|
||||
pass
|
||||
|
||||
# Remove from plugin thread list
|
||||
del PLUGINS_THRS[plugin_uuid]
|
||||
LOG.debug(" - plugin data structure cleaned!")
|
||||
|
||||
# START PLUGIN-------------------------------------------------
|
||||
if os.path.exists(plugin_filename):
|
||||
|
@ -737,13 +746,20 @@ class PluginManager(Module.Module):
|
|||
# Import plugin python module
|
||||
task = imp.load_source("plugin", plugin_filename)
|
||||
|
||||
if os.path.exists(plugin_params_file):
|
||||
if parameters is None:
|
||||
|
||||
with open(plugin_params_file) as conf:
|
||||
plugin_params = json.load(conf)
|
||||
if os.path.exists(plugin_params_file):
|
||||
|
||||
with open(plugin_params_file) as conf:
|
||||
plugin_params = json.load(conf)
|
||||
|
||||
else:
|
||||
plugin_params = None
|
||||
|
||||
else:
|
||||
plugin_params = None
|
||||
plugin_params = parameters
|
||||
LOG.info(" - plugin restarting with parameters:")
|
||||
LOG.info(" " + str(plugin_params))
|
||||
|
||||
worker = task.Worker(
|
||||
plugin_uuid,
|
||||
|
|
|
@ -43,6 +43,7 @@ class Plugin(threading.Thread):
|
|||
threading.Thread.__init__(self)
|
||||
# self.setDaemon(1)
|
||||
self.setName("Plugin " + str(self.name)) # Set thread name
|
||||
LOG.debug("Plugin Name: " + self.name)
|
||||
|
||||
self.uuid = uuid
|
||||
self.name = name
|
||||
|
|
Loading…
Reference in New Issue