Skip to content

Commit

Permalink
deb: development of debian package for ideam (#56)
Browse files Browse the repository at this point in the history
* Fix: avoid pathlib requirement, use ideam.conf
* Fix: cache failure in ubuntu-ssh image, issue: #57

Signed-off-by: Harish Anand <harishanand95@gmail.com>
  • Loading branch information
harishanand95 authored Apr 2, 2018
1 parent dad1eec commit c84dca7
Show file tree
Hide file tree
Showing 18 changed files with 212 additions and 330 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**/.DS_Store
.vagrant/
**/*.tar.gz
**/*.tgz
config/apt_repo/keys/ansible.pub
config/certificate_authority/keys/id_rsa-cert.pub
hosts
Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
sudo: required
dist: trusty
before_install:
- ./build/build.sh
- ./tests/test_setup.sh
- ./tests/install.sh
language: python
install:
- python smartcity-middleware.py install -f middleware.conf
- python smartcity-middleware.py start
- ideam install
- ideam start
script:
- python ./tests/pytest.py
219 changes: 26 additions & 193 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,73 +20,59 @@ Requirements
============
- ``Docker``: `Installation steps for Docker in Ubuntu/Debian <https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#os-requirements>`_
- ``Ansible``: `Installation steps for Ansible <http://docs.ansible.com/ansible/latest/intro_installation.html>`_
- ``Python-pip``: Python package dependency (pathlib2). Use the command ``python -m pip install pathlib2``
- ``ssh-keygen``: Generate a RSA Key Pair for the user who will install the script.



Release
=======

smartcity-middleware v1.0.0_
ideam v1.0.0_

Use the ideam deb file to install in Linux machines after satisfying the requirements. ``dpkg -i ideam.deb`` .


.. _v1.0.0: https://github.com/rbccps-iisc/ideam/releases/latest

Configuration
=============

middleware.conf_ v1.0.0

.. _middleware.conf: https://github.com/rbccps-iisc/ideam/blob/master/middleware.conf
middleware.conf::

DESCRIPTION

middleware.conf is the configuration file for the smartcity-middleware application.

KONG, RABBITMQ, TOMCAT, CATALOGUE, LDAP docker containers requires a persistent data, config storage locations.
ideam.conf_ v1.0.0

DATA_STORAGE: Specify an empty directory in the system that docker could use
for keeping data files. Here, providing separate directories for kong, rabbitmq,
tomcat, catalogue is recommended. Give all user rwx permission to these directories.
- Config file is located at ``/etc/ideam/ideam.conf``.

CONFIG_STORAGE: Specify an empty directory in the system that docker could use
for keeping config files.
- The data files or docker persistent storage is at ``/var/ideam/data`` directory.

LOG_LOCATION: Specify an empty directory in the system that docker could use
for keeping log files.
- The persistent storage can be changed by modifying the ``ideam.conf`` before installation.

SSH and other service ports can be mapped to host machine ports.

SYSTEM_CONFIG specify system specific configurations for the installation steps.

SSH_PUBLIC_KEY: Specify a ssh public key which will be used in ssh authentication of the user to
docker containers.
.. _ideam.conf: https://github.com/rbccps-iisc/ideam/blob/master/ideam.conf


Steps to Install
================

After configuring the ``middleware.conf`` file, do the following steps.
After downloading and installing the deb file, do the following steps.

+---------------------------------------+-----------------------------------------------------------------------------+
| Installation | ``python smartcity-middleware.py install --config-file middleware.conf`` |
| Installation | ``ideam install`` or if you cloned ``./ideam install`` |
+---------------------------------------+-----------------------------------------------------------------------------+
| Start Middleware | ``python smartcity-middleware.py start`` |
| Start Ideam | ``ideam start`` or if you cloned ``./ideam start`` |
+---------------------------------------+-----------------------------------------------------------------------------+
| Serving Middleware at | ``https://localhost:10443`` |
| Serving Ideam at | ``https://localhost:10443`` |
+---------------------------------------+-----------------------------------------------------------------------------+

- The application will be serving with a self-signed certificate.
If you want to use your certificate, have your .crt and .key file as ``/usr/share/ideam/config/kong/default_443.crt`` and
``/usr/share/ideam/config/kong/default_443.key`` respectively and do a fresh installation.

- If installation fails at some instance, all the time-dated logs are available at ``/tmp/ideam-%Y-%m-%d-%H-%M.log``.



Comment
=======
- Please satisfy the requirements mentioned in ``middleware.conf`` file.
- If the setup fails at any stage for reasons like internet connection issues, you can continue the failed installation using the following command.
``python smartcity-middleware.py install --config-file middleware.conf -l kong,tomcat,hypercat,ldapd,elasticsearch,rabbitmq,apt_repo,pushpin``
- The application will be serving with a self-signed certificate. If you want to use your certificate, have your .crt and .key file as ``config/kong/default_443.crt`` and ``config/kong/default_443.key`` respectively and do a fresh installation.

+----------------------------------------------------------------+----------------------------------------------------------+
| RBCCPS MIDDLEWARE API URLs | MIDDLEWARE API URLs |
| RBCCPS IoT MIDDLEWARE IDEAM API URL | INSTALLED IOT MIDDLEWARE IDEAM API URLs |
+================================================================+==========================================================+
| https://smartcity.rbccps.org/api/1.0.0/register | https://localhost:10443/api/1.0.0/register |
+----------------------------------------------------------------+----------------------------------------------------------+
Expand All @@ -101,171 +87,18 @@ Comment
| https://smartcity.rbccps.org/api/1.0.0/db | https://localhost:10443/api/1.0.0/db |
+----------------------------------------------------------------+----------------------------------------------------------+

For example, registration of device to local middleware is as follows.

command::

curl -X POST \
https://smartcity.rbccps.org/api/1.0.0/register \
-H 'apikey: guest' \
-H 'content-type: application/json' \
-d '{
"entitySchema": {
"refCatalogueSchema": "generic_iotdevice_schema.json",
"resourceType": "streetlight",
"tags": ["onstreet", "Energy", "still under development!"],
"refCatalogueSchemaRelease": "0.1.0",
"latitude": {
"value": 13.0143335,
"ontologyRef": "http://www.w3.org/2003/01/geo/wgs84_pos#"
},
"longitude": {
"value": 77.5678424,
"ontologyRef": "http://www.w3.org/2003/01/geo/wgs84_pos#"
},
"owner": {
"name": "IISC",
"website": "http://www.iisc.ac.in"
},
"provider": {
"name": "Robert Bosch Centre for Cyber Physical Systems, IISc",
"website": "http://rbccps.org"
},
"geoLocation": {
"address": "80 ft Road, Bangalore, 560012"
},
"data_schema": {
"type": "object",
"properties": {
"dataSamplingInstant": {
"type": "number",
"description": "Sampling Time in EPOCH format",
"units": "seconds",
"permissions": "read",
"accessModifier": "public"
},
"caseTemperature": {
"type": "number",
"description": "Temperature of the device casing",
"units": "degreeCelsius",
"permissions": "read",
"accessModifier": "public"
},
"powerConsumption": {
"type": "number",
"description": "Power consumption of the device",
"units": "watts",
"permissions": "read",
"accessModifier": "public"
},
"luxOutput": {
"type": "number",
"description": "lux output of LED measured at LED",
"units": "lux",
"permissions": "read",
"accessModifier": "public"
},
"ambientLux": {
"type": "number",
"description": "lux value of ambient",
"units": "lux",
"permissions": "read",
"accessModifier": "public"
},
"targetPowerState": {
"type": "string",
"enum": ["ON", "OFF"],
"units": "dimensionless",
"description": "If set to ON, turns ON the device. If OFF turns OFF the device. Writeable parameter. Writeable only allowed for authorized apps",
"permissions": "read-write",
"accessModifier": "protected"
},
"targetBrightnessLevel": {
"type": "number",
"description": "Number between 0 to 100 to indicate the percentage brightness level. Writeable only allowed for authorized apps",
"units": "percent",
"permissions": "read-write",
"accessModifier": "protected"
},
"targetControlPolicy": {
"enum": ["AUTO_TIMER", "AUTO_LUX", "MANUAL"],
"units": "dimensionless",
"permissions": "read-write",
"description": "Indicates which of the behaviours the device should implement. AUTO_TIMER is timer based, AUTO_LUX uses ambient light and MANUAL is controlled by app. Writeable only allowed for authorized apps",
"accessModifier": "protected"
},
"targetAutoTimerParams": {
"type": "object",
"permissions": "read-write",
"properties": {
"targetOnTime": {
"type": "number",
"description": "Indicates time of day in seconds from 12 midnight when device turns ON in AUTO_TIMER. Writeable only allowed for authorized apps",
"units": "seconds",
"accessModifier": "protected"
},
"targetOffTime": {
"type": "number",
"description": "Indicates time of day in seconds from 12 midnight when device turns OFF in AUTO_TIMER. Writeable only allowed for authorized apps",
"units": "seconds",
"accessModifier": "protected"
}
}
},
"targetAutoLuxParams": {
"type": "object",
"permissions": "read-write",
"properties": {
"targetOnLux": {
"type": "number",
"description": "Indicates ambient lux when device turns ON in AUTO_LUX. Writeable only allowed for authorized apps",
"units": "lux",
"accessModifier": "protected"
},
"targetOffLux": {
"type": "number",
"description": "Indicates ambient lux when device turns OFF in AUTO_LUX. Writeable only allowed for authorized apps",
"units": "lux",
"accessModifier": "protected"
}
}
}
},
"additionalProperties": false
},
"serialization_from_device": {
"format": "protocol-buffers",
"schema_ref": {
"type": "proto 2",
"mainMessageName": "sensor_values",
"link": "https://raw.githubusercontent.com/rbccps-iisc/applications-streetlight/master/proto_stm/txmsg/sensed.proto"
}
},
"serialization_to_device": {
"format": "protocol-buffers",
"schema_ref": {
"type": "proto 2",
"mainMessageName": "targetConfigurations",
"link": "https://raw.githubusercontent.com/rbccps-iisc/applications-streetlight/master/proto_stm/rxmsg/actuated.proto"
}
},
"id": "streetLight_1A_212"
}
}'


NOTE
====
- Installation in Linux machines can fail for the following reasons.
- If you are in a corporate network that blocks Google DNS Servers, the ``docker build`` command fails.
- If you are in a corporate network that blocks Google DNS Servers, the ``ideam install`` command fails.

To fix it, add your corporate DNS servers in DOCKER_OPTS in /etc/default/docker. (for SysV machines)

DOCKER_OPTS="--dns 208.67.222.222 --dns 208.67.220.220"
DOCKER_OPTS="--dns 208.67.222.222 --dns 208.67.220.220"

If this fails to set the DNS properly, try updating /etc/docker/daemon.json with the following (for systemd machines)

{ "dns": ["208.67.222.222", "208.67.220.220"] }
{ "dns": ["208.67.222.222", "208.67.220.220"] }

- Middleware has been tested on macOS as well.
- IDEAM has been tested on MacOS as well.

6 changes: 6 additions & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
*/
!debian/
!debian/*
!.gitignore
!build.sh
26 changes: 26 additions & 0 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
cd ./build/
mkdir ideam_0.0-1
mkdir -p ideam_0.0-1/usr/local/bin
mkdir -p ideam_0.0-1/usr/share/ideam
mkdir -p ideam_0.0-1/etc/ideam
mkdir -p ideam_0.0-1/DEBIAN
mkdir -p ideam_0.0-1/var/ideam/data/kong
mkdir -p ideam_0.0-1/var/ideam/data/kong-config
mkdir -p ideam_0.0-1/var/ideam/data/catalogue
mkdir -p ideam_0.0-1/var/ideam/data/rabbitmq
mkdir -p ideam_0.0-1/var/ideam/data/ldap
mkdir -p ideam_0.0-1/var/ideam/data/tomcat
mkdir -p ideam_0.0-1/var/ideam/data/logs/kong
mkdir -p ideam_0.0-1/var/ideam/data/logs/rabbitmq
mkdir -p ideam_0.0-1/var/ideam/data/logs/tomcat
cp ../ideam.py ideam_0.0-1/usr/local/bin/ideam
cp debian/control ideam_0.0-1/DEBIAN/control
cp ../ideam.conf ideam_0.0-1/etc/ideam/
chmod +x ideam_0.0-1/usr/local/bin/ideam
cd ../
tar --exclude='./build' --exclude='./.git' --exclude='./.idea' --exclude='*.retry' --exclude='*.tar.gz' --exclude='./ideam.tgz' --exclude='*.DS_Store' --exclude='./.gitignore' -zcvf ideam.tgz ./
tar -xvzf ideam.tgz -C build/ideam_0.0-1/usr/share/ideam/
cd build/
chmod -R 777 ideam_0.0-1/var/ideam/data/logs/kong
dpkg-deb --build ideam_0.0-1/
9 changes: 9 additions & 0 deletions build/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: ideam
Version: 0.0-1
Section: devel
Priority: optional
Architecture: all
Depends: ansible, python-pkg-resources, python-setuptools, docker-ce
Maintainer: Harish Anand <harishanand95@gmail.com>
Description: IoT Data Exchange And Middleware
(IDEAM) for smartcities.
7 changes: 0 additions & 7 deletions delete.sh

This file was deleted.

Loading

0 comments on commit c84dca7

Please sign in to comment.