Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Liota-lite Code Changes remove pip dependency and resolving paths
Browse files Browse the repository at this point in the history
  • Loading branch information
KohliDev committed Aug 22, 2017
1 parent 1bab7fa commit 1dc897d
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 35 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ In general, liota can be installed:
$ sudo pip install liota
```

Post liota-installation either you can manually copy the config files from "/usr/lib/liota/config/" to "/etc/liota".
Post liota-installation either you can manually copy the config files from "/usr/lib/liota/config/" to "/etc/liota" and create "/var/log/liota" directory.
Or you can use the helper script "post-install-setup.sh" to copy the config files which exist at the path "/usr/lib/liota". The script on execution by default checks if the "liota" non-root user exist if it doesn't then non-root "liota" user is required to be created manually.
If you require Liota to be installed with other non-root user which pre-exists in the system then the script will be required to be executed in the following way:
If you require Liota to be installed as the different non-root user which pre-exists on the system then the script will be required to be executed in the following way:

```bash
$ cd /usr/lib/liota
Expand Down Expand Up @@ -138,7 +138,7 @@ liota.conf provides path to find out various configuration & log files. When ini
* Looks in the current working directory '.'
* User's home directory '~'
* A LIOTA_CONF environment variable
* Finally the default location for every installation: /etc/liota/. (note this will need to be copied from the system doc directory, typically /usr/lib/liota/)
* Finally the default configuration file location for every installation: /etc/liota/. (note this will need to be copied from the system doc directory, typically /usr/lib/liota/config)

Here is the default liota.conf file:

Expand All @@ -153,9 +153,9 @@ log_path = /var/log/liota
uuid_path = /etc/liota/uuid.ini

[IOTCC_PATH]
dev_file_path = /etc/liota/devs
entity_file_path = /etc/liota/entity
iotcc_path = /etc/liota/iotcc.json
dev_file_path = /etc/liota/conf/devs
entity_file_path = /etc/liota/conf/entity
iotcc_path = /etc/liota/conf/iotcc.json

[PKG_CFG]
pkg_path = /usr/lib/liota/packages
Expand Down Expand Up @@ -204,6 +204,14 @@ The default location for log files generated during Liota operation can be found
```
If the above directory is not available or is not writeable then modify the log location in the file logging.json (find it as described above in the section on liota.conf)

## Uninstall Liota

Liota can be uninstalled easily as per the steps below:
```bash
$ pip uninstall liota
$ rm -rf /usr/lib/liota/ /etc/liota/ /var/log/liota/
```

## Contributing to Liota

Want to hack on Liota and add your own DCC component? Awesome!
Expand Down
10 changes: 5 additions & 5 deletions config/liota.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ collect_thread_pool_size = 30
[PKG_CFG]
pkg_path = /usr/lib/liota/packages
pkg_msg_pipe = /var/tmp/liota/package_messenger.fifo
pkg_list = /etc/liota/packages/packages_auto.txt
pkg_list = /usr/lib/liota/packages/packages_auto.txt

[DISC_CFG]
disc_cmd_msg_pipe = /etc/liota/packages/dev_disc/disc_cmd_messenger.fifo
disc_cmd_msg_pipe = /usr/lib/liota/packages/dev_disc/disc_cmd_messenger.fifo

[DEVICE_TYPE_TO_UNIQUEKEY_MAPPING]
Press64 = serial
Expand All @@ -36,16 +36,16 @@ Apple56 = iotcc_mqtt, iotcc
Banana23 = iotcc

[DEVSIM_CFG]
devsim_cmd_msg_pipe = /etc/liota/packages/dev_disc/devsim_cmd_messenger.fifo
devsim_cmd_msg_pipe = /usr/lib/liota/packages/dev_disc/devsim_cmd_messenger.fifo

[DISC_ENDPOINT_LIST]
disc_msg_pipe = /etc/liota/packages/dev_disc/discovery_messenger.fifo
disc_msg_pipe = /usr/lib/liota/packages/dev_disc/discovery_messenger.fifo

[DISC_MQTT_CFG]
enable_authentication = True
broker_username = User_Name
broker_password = Password
broker_root_ca_cert = /etc/liota/packages/dev_disc/certs/mqtt_ca.crt
broker_root_ca_cert = /usr/lib/liota/packages/dev_disc/certs/mqtt_ca.crt
edge_system_cert_file = None
edge_system_key_file = None
cert_required = CERT_NONE
Expand Down
33 changes: 33 additions & 0 deletions liota-lite/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
# Liota-Lite
Little IoT Agent-lite (liota) is the trimmed version of actual Liota, it doesn't include any example files,user-packages and additional libraries required for various DCC`s.

# Installation
Clone the Liota Repo or download the [Liota release](https://github.com/vmware/liota/releases)

Liota requires a Python 2.7.9+ environment already installed.

Copy MANIFEST.in, requirements.txt and setup.py to the main directory (one directory above) to install Liota-lite.
```bash
$ cd liota/liota-lite
$ cp MANIFEST.in requirements.txt setup.py ../
$ cd ../
```

Liota-lite can be installed as per the command below:
```bash
$ sudo python setup.py install
```

Post liota installation either you can manually copy the config files from "/usr/lib/liota/config/" to "/etc/liota" and create "/var/log/liota" directory.
Or you can use the helper script "post-install-setup.sh" to copy the config files which exist at the path "/usr/lib/liota". The script on execution by default checks if the "liota" non-root user exist if it doesn't then non-root "liota" user is required to be created manually.
If you require Liota to be installed with the different non-root user which pre-exists on the system then the script will be required to be executed in the following way:

```bash
$ cd /usr/lib/liota
$ LIOTA_USER="non-root user" ./post-install-setup.sh
```

It Liota is required to be installed as root user (not the preferred way) then the script should be executed in the following way:

```bash
$ cd /usr/lib/liota
$ LIOTA_USER="root" ./post-install-setup.sh
```
1 change: 0 additions & 1 deletion liota-lite/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CoAPthon==4.0.2
aenum==1.4.5
linux-metrics==0.1.4
mock==2.0.0
Expand Down
11 changes: 3 additions & 8 deletions liota-lite/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@
#

import os
# import pip
import sys
# from pip.req import parse_requirements
from setuptools import setup, find_packages

#
# Useful Variables
#

PACKAGE_NAME = "liota"
PACKAGE_VERSION = "0.2.1"
PACKAGE_VERSION = "0.3.1"

#
# Functions
Expand Down Expand Up @@ -114,9 +112,6 @@ def get_data_files():
with open('requirements.txt') as f:
required = f.read().splitlines()

# requirements = [str(requirement.req) for requirement in parse_requirements(
# 'requirements.txt', session=pip.download.PipSession())]

# Python Version check
if not sys.version_info[0] == 2:
sys.exit('Python 3 is not supported')
Expand All @@ -134,7 +129,7 @@ def get_data_files():
name=PACKAGE_NAME,
version=PACKAGE_VERSION,
packages=find_packages(exclude=["*.json", "*.txt",]),
description='Little IoT Agent (liota)-lite',
description='Little IoT Agent (liota)',
long_description=long_description,
# include_package_data=True

Expand Down Expand Up @@ -162,7 +157,7 @@ def get_data_files():
# 'Programming Language :: Python :: 3.5',
],

keywords='iot liota-lite agent',
keywords='iot liota agent',

# Installation requirement
install_requires=required,
Expand Down
4 changes: 2 additions & 2 deletions packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Load a package with the specified name and its sha1 checksum. For example, linux
"./liotapkg.sh load filename sha1_checksum".

A python file of cal_sha1sum.py is also provided to help you calculate checksum for a file:
python cal_sha1sum.py file_name (could be relative or absolute file name). For example, under /etc/liota/packages,
python cal_sha1sum.py file_name (could be relative or absolute file name). For example, under /usr/lib/liota/packages,
python cal_sha1sum.py iotcc_mqtt.py

If the specified package provides with a list of dependencies, recursively load all its dependencies. If more than one package names are specified, load them (as well as their dependencies) in a batch and no package will be loaded twice or reloaded.
Expand Down Expand Up @@ -47,7 +47,7 @@ Remove a package with the specified name. By default, the removed package will b

###Package Load Automation

Load Liota Packages automatically when Package Manager starts by listing package names and checksums in the file specified by pkg_list in [PKG_CFG] of liota.conf, e.g., by default /etc/liota/packages/packages_auto.txt (Should NOT have " " around ":"):
Load Liota Packages automatically when Package Manager starts by listing package names and checksums in the file specified by pkg_list in [PKG_CFG] of liota.conf, e.g., by default /usr/lib/liota/packages/packages_auto.txt (Should NOT have " " around ":"):
package_name:sha1_checksum
[package_name:sha1_checksum]

Expand Down
18 changes: 9 additions & 9 deletions packages/dev_disc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Device Discovery could be started through the Liota package of 'dev_disc.py' und
To be reminded, to let discovered devices registered to user specified DCCs, at least one DCC package should be loaded.

In details, after installation with (sudo python setup.py install or pip install liota), you can do the following:
# Configuration A (under /etc/liota/conf, inside liota.conf, default/example settings are available)
# Configuration A (under /etc/liota/, inside liota.conf, default/example settings are available)
[IOTCC_PATH]

dev_file_path = /etc/liota/conf/devs # the folder where store discovered device information files
Expand All @@ -34,7 +34,7 @@ entity_file_path = /etc/liota/conf/entity # the folder where store discovered de

[DISC_CFG]

disc_cmd_msg_pipe = /etc/liota/packages/dev_disc/disc_cmd_messenger.fifo # the named pipe path for discovery CmdMessengerThread
disc_cmd_msg_pipe = /usr/lib/liota/packages/dev_disc/disc_cmd_messenger.fifo # the named pipe path for discovery CmdMessengerThread

[DEVICE_TYPE_TO_UNIQUEKEY_MAPPING] # device discovery can only process device types which are listed here, among its attributes,

Expand All @@ -58,13 +58,13 @@ Banana23 = iotcc # Later user could create Liota Package for discovered devices

[DEVSIM_CFG]

devsim_cmd_msg_pipe = /etc/liota/packages/dev_disc/devsim_cmd_messenger.fifo # named pipe for Device Simulator CmdMessengerThread
devsim_cmd_msg_pipe = /usr/lib/liota/packages/dev_disc/devsim_cmd_messenger.fifo # named pipe for Device Simulator CmdMessengerThread

[DISC_ENDPOINT_LIST] # Endpoing list where you want discovery listens on and simulator send messages to

# if no item in this list, Device Discovery will not be started

disc_msg_pipe = /etc/liota/packages/dev_disc/discovery_messenger.fifo # currently, support these 4 types (currently,
disc_msg_pipe = /usr/lib/liota/packages/dev_disc/discovery_messenger.fifo # currently, support these 4 types (currently,

socket = 127.0.0.1:5000 # coap and socket are not allowed for security consideration).

Expand Down Expand Up @@ -108,7 +108,7 @@ ConnectDisconnectTimeout = 10
* When MQTT broker also sits on the edge system, MQTT subscriber can listen on 127.0.0.1/localhost with a unique port (rather than well-known 1883) and use basic authentication
to guarantee secured communication with MQTT broker. It's MQTT broker and MQTT publisher's responsibility to guarantee MQTT broker and external world communicate securely.

# Configuration B (under /etc/liota/packages, inside sampleProf.conf)
# Configuration B (under /usr/lib/liota/packages, inside sampleProp.conf)

Since when device is discovered, it will be registered to DCC based on your [DEVICE_TYPE_TO_DCC_MAPPING] in liota.conf,
it will use DCC credentials. Therefore, please guarantee IOTCC or Graphite section in sampleProf.conf are configured well.
Expand All @@ -127,7 +127,7 @@ GraphitePort = 2003

To be reminded, if DCC Liota package is not loaded, i.e., no corresponding DCC instance, although discovery thread can still listens on end points, device registration will not be carried out.

# Start Device Discovery Liota Package (dev_disc.py under /etc/liota/packages/)
# Start Device Discovery Liota Package (dev_disc.py under /usr/lib/liota/packages/)

a). when keep dev_disc inside packages_auto.txt:

Expand Down Expand Up @@ -162,7 +162,7 @@ messages should be printed out to stdout, e.g.,

(if running or started are printed out, listeners are started successfully)

You can also use CmdMessage to check certain information (under /etc/liota/packages/dev_disc)
You can also use CmdMessage to check certain information (under /usr/lib/liota/packages/dev_disc)

sudo ./liota_disc_pipe.sh list th

Expand All @@ -172,7 +172,7 @@ You can also use CmdMessage to check certain information (under /etc/liota/packa

### How to Start Device Simulator
Device Simulator Must BE started after Device Discovery module is imported; and should be started
separately by (under /etc/liota/packages/dev_disc)
separately by (under /usr/lib/liota/packages/dev_disc)

sudo python liota_devsim_load.py (add & is optional)

Expand All @@ -194,7 +194,7 @@ Verification messages are as followings.

SocketSimulator is running...

You can also use CmdMessage to check certain information (under /etc/liota/packages/dev_disc)
You can also use CmdMessage to check certain information (under /usr/lib/liota/packages/dev_disc)

sudo ./liota_devsim_pipe.sh list th

Expand Down
2 changes: 1 addition & 1 deletion packages/dev_disc/liota_devsim_pipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# THE POSSIBILITY OF SUCH DAMAGE. #
# ----------------------------------------------------------------------------#

liota_config="/etc/liota/conf/liota.conf"
liota_config="/etc/liota/liota.conf"
discovery_messenger_pipe=""

if [ ! -f "$liota_config" ]; then
Expand Down
2 changes: 1 addition & 1 deletion packages/dev_disc/liota_disc_pipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# THE POSSIBILITY OF SUCH DAMAGE. #
# ----------------------------------------------------------------------------#

liota_config="/etc/liota/conf/liota.conf"
liota_config="/etc/liota/liota.conf"
discovery_messenger_pipe=""

if [ ! -f "$liota_config" ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/autostartliota
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin

do_start() {
sudo python /etc/liota/packages/liotad.py &
sudo python /usr/lib/liota/packages/liotad.py &
}

case "$1" in
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#

PACKAGE_NAME = "liota"
PACKAGE_VERSION = "0.2.1"
PACKAGE_VERSION = "0.3.1"

#
# Functions
Expand Down

0 comments on commit 1dc897d

Please sign in to comment.