From 1dc897d36be96bdae5318b5363426f08f0dbb48d Mon Sep 17 00:00:00 2001 From: Vaibhav Kohli Date: Wed, 23 Aug 2017 03:04:51 +0530 Subject: [PATCH] Liota-lite Code Changes remove pip dependency and resolving paths --- README.md | 20 +++++++++++----- config/liota.conf | 10 ++++---- liota-lite/README.md | 33 ++++++++++++++++++++++++++ liota-lite/requirements.txt | 1 - liota-lite/setup.py | 11 +++------ packages/README.md | 4 ++-- packages/dev_disc/README.md | 18 +++++++------- packages/dev_disc/liota_devsim_pipe.sh | 2 +- packages/dev_disc/liota_disc_pipe.sh | 2 +- scripts/autostartliota | 2 +- setup.py | 2 +- 11 files changed, 70 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 15fac14c..e759c890 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: @@ -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 @@ -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! diff --git a/config/liota.conf b/config/liota.conf index b77a6cfe..b0e844f5 100644 --- a/config/liota.conf +++ b/config/liota.conf @@ -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 @@ -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 diff --git a/liota-lite/README.md b/liota-lite/README.md index 849afc48..0ec50ed5 100644 --- a/liota-lite/README.md +++ b/liota-lite/README.md @@ -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 +``` diff --git a/liota-lite/requirements.txt b/liota-lite/requirements.txt index cc00ea7c..3074e955 100644 --- a/liota-lite/requirements.txt +++ b/liota-lite/requirements.txt @@ -1,4 +1,3 @@ -CoAPthon==4.0.2 aenum==1.4.5 linux-metrics==0.1.4 mock==2.0.0 diff --git a/liota-lite/setup.py b/liota-lite/setup.py index 44d7db49..a3c94f6b 100644 --- a/liota-lite/setup.py +++ b/liota-lite/setup.py @@ -35,9 +35,7 @@ # import os -# import pip import sys -# from pip.req import parse_requirements from setuptools import setup, find_packages # @@ -45,7 +43,7 @@ # PACKAGE_NAME = "liota" -PACKAGE_VERSION = "0.2.1" +PACKAGE_VERSION = "0.3.1" # # Functions @@ -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') @@ -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 @@ -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, diff --git a/packages/README.md b/packages/README.md index bb21c6c5..872fb391 100644 --- a/packages/README.md +++ b/packages/README.md @@ -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. @@ -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] diff --git a/packages/dev_disc/README.md b/packages/dev_disc/README.md index 63909466..cec5af43 100644 --- a/packages/dev_disc/README.md +++ b/packages/dev_disc/README.md @@ -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 @@ -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, @@ -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). @@ -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. @@ -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: @@ -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 @@ -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) @@ -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 diff --git a/packages/dev_disc/liota_devsim_pipe.sh b/packages/dev_disc/liota_devsim_pipe.sh index ac0f32d6..0d9489d5 100755 --- a/packages/dev_disc/liota_devsim_pipe.sh +++ b/packages/dev_disc/liota_devsim_pipe.sh @@ -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 diff --git a/packages/dev_disc/liota_disc_pipe.sh b/packages/dev_disc/liota_disc_pipe.sh index 8b1fffe1..7f1d4a20 100755 --- a/packages/dev_disc/liota_disc_pipe.sh +++ b/packages/dev_disc/liota_disc_pipe.sh @@ -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 diff --git a/scripts/autostartliota b/scripts/autostartliota index ad86f6fb..d912bc28 100755 --- a/scripts/autostartliota +++ b/scripts/autostartliota @@ -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 diff --git a/setup.py b/setup.py index 5c15bda0..429cd4d0 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ # PACKAGE_NAME = "liota" -PACKAGE_VERSION = "0.2.1" +PACKAGE_VERSION = "0.3.1" # # Functions