diff --git a/README.rst b/README.rst index bfbefd6..cd82c92 100644 --- a/README.rst +++ b/README.rst @@ -10,7 +10,7 @@ Web Page - Tools and SDK's: https://github.com/rbccps-iisc/ideam-python-sdk Architecture -============= +============ .. image:: https://rbccps.org/smartcity/lib/exe/fetch.php?media=mw_architecture.png Requirements @@ -23,18 +23,19 @@ Requirements Release ======= -smartcity-middleware v0.1.0_ +smartcity-middleware v1.0.0_ -.. _v0.1.0: https://github.com/rbccps-iisc/ideam/releases/latest +.. _v1.0.0: https://github.com/rbccps-iisc/ideam/releases/latest Configuration ============= -``middleware.conf v0.1.0`` +middleware.conf_ v0.1.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. @@ -52,7 +53,7 @@ middleware.conf:: for keeping log files. 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 @@ -77,27 +78,27 @@ After configuring the ``middleware.conf`` file, do the following steps. Comment ======= - Please satisfy the requirements mentioned in ``middleware.conf`` file. -- Password of the root user in docker containers for the 0.1.0 release is rbccps@123456. This will be removed in the later release. -- If the setup fails at any stage for reasons like internet connection issues, you can continue the failed installation using the following command. +- Password of the root user in docker containers for the 1.0.0 release is rbccps@123456. This will be removed in the later release. +- 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. +- 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 | +================================================================+==========================================================+ -| https://smartcity.rbccps.org/api/0.1.0/register | https://localhost:10443/api/0.1.0/register | +| https://smartcity.rbccps.org/api/1.0.0/register | https://localhost:10443/api/1.0.0/register | +----------------------------------------------------------------+----------------------------------------------------------+ -| https://smartcity.rbccps.org/api/0.1.0/publish | https://localhost:10443/api/0.1.0/publish | +| https://smartcity.rbccps.org/api/1.0.0/publish | https://localhost:10443/api/1.0.0/publish | +----------------------------------------------------------------+----------------------------------------------------------+ -| https://smartcity.rbccps.org/api/0.1.0/subscribe?name=testDemo | https://localhost:10443/api/0.1.0/subscribe?name=testDemo| +| https://smartcity.rbccps.org/api/1.0.0/subscribe?name=testDemo | https://localhost:10443/api/1.0.0/subscribe?name=testDemo| +----------------------------------------------------------------+----------------------------------------------------------+ -| https://smartcity.rbccps.org/api/0.1.0/subscribe/bind | https://localhost:10443/api/0.1.0/subscribe/bind | +| https://smartcity.rbccps.org/api/1.0.0/subscribe/bind | https://localhost:10443/api/1.0.0/subscribe/bind | +----------------------------------------------------------------+----------------------------------------------------------+ -| https://smartcity.rbccps.org/api/0.1.0/subscribe/unbind | https://localhost:10443/api/0.1.0/subscribe/unbind | +| https://smartcity.rbccps.org/api/1.0.0/subscribe/unbind | https://localhost:10443/api/1.0.0/subscribe/unbind | +----------------------------------------------------------------+----------------------------------------------------------+ -| https://smartcity.rbccps.org/api/0.1.0/cat | https://localhost:10443/api/0.1.0/cat | +| https://smartcity.rbccps.org/api/1.0.0/cat | https://localhost:10443/api/1.0.0/cat | +----------------------------------------------------------------+----------------------------------------------------------+ -| https://smartcity.rbccps.org/api/0.1.0/historicData | https://localhost:10443/api/0.1.0/historicData | +| https://smartcity.rbccps.org/api/1.0.0/historicData | https://localhost:10443/api/1.0.0/historicData | +----------------------------------------------------------------+----------------------------------------------------------+ For example, registration of device to local middleware is as follows. diff --git a/config/tomcat/RegisterAPI.war b/config/tomcat/RegisterAPI.war index bf49413..7ccca6e 100644 Binary files a/config/tomcat/RegisterAPI.war and b/config/tomcat/RegisterAPI.war differ diff --git a/install.yaml b/install.yaml index 9ed753b..a9a8baa 100644 --- a/install.yaml +++ b/install.yaml @@ -233,6 +233,10 @@ args: chdir: /home/ansible/cat-json-schema-server + - name: Create pwd test + shell: node pwd_script.js local123 + args: + chdir: /home/ansible/cat-json-schema-server/ ### Set up kong environment # This playbook play will install Kong, iptables and api-auth plugin of Kong. Ansible will install and verify # the working of the API at user and admin ports. But this verification will fail in any subsequent runs of diff --git a/tasks/kong/kong_auth_configuration.yml b/tasks/kong/kong_auth_configuration.yml index af550a9..4137501 100644 --- a/tasks/kong/kong_auth_configuration.yml +++ b/tasks/kong/kong_auth_configuration.yml @@ -1,38 +1,5 @@ --- ## Kong Auth Configuration - - name: (WILL BE REMOVED) Add test-api to kong - uri: - url: http://localhost:8001/apis/ - method: POST - body: 'name={{ kong_api_name }}&hosts=example.com&upstream_url=http://httpbin.org' - status_code: [201, 409] - return_content: yes - register: request - until: (request.status == 409) or (request.status == 201) - retries: 5 - - - name: (WILL BE REMOVED) GET test-api from kong - uri: - url: http://127.0.0.1:8000/ - method: GET - headers: - Host: 'example.com' - status_code: [200, 401] - return_content: yes - register: request - until: (request.status == 200) or (request.status == 401) - retries: 2 - - - name: (WILL BE REMOVED) Add key-auth plugin to kong - uri: - url: http://localhost:8001/apis/test-api/plugins/ - method: POST - body: 'name=key-auth' - status_code: [201, 409] - return_content: yes - register: request - until: (request.status == 201) or (request.status == 409) - retries: 5 - name: Add file-log plugin to kong uri: @@ -45,16 +12,6 @@ until: (request.status == 201) or (request.status == 409) retries: 5 - - name: Add bad-request plugin to kong - uri: - url: http://localhost:8001/plugins/ - method: POST - body: 'name=badrequest' - status_code: [201, 409] - return_content: yes - register: request - until: (request.status == 201) or (request.status == 409) - retries: 5 - name: Add request-size-limiting plugin to kong uri: @@ -67,43 +24,31 @@ until: (request.status == 201) or (request.status == 409) retries: 5 - - name: (WILL BE REMOVED) GET test-api from kong without key [401 error case] - uri: - url: http://localhost:8000/ - method: GET - headers: - Host: 'example.com' - status_code: [200,401] - return_content: yes - register: request - until: (request.status == 200) or (request.status == 401) - retries: 5 - - - name: (WILL BE REMOVED) Add consumer ansible to kong + - name: (WILL BE REMOVED) Add consumer guest to kong uri: url: http://localhost:8001/consumers/ method: POST - body: 'username=ansible&custom_id=ansible' + body: 'username=guest&custom_id=guest' status_code: [201, 409] return_content: yes register: request until: (request.status == 201) or (request.status == 409) retries: 5 - - name: (WILL BE REMOVED) Add consumer ansible's apikey + - name: (WILL BE REMOVED) Add consumer guest's apikey uri: - url: http://localhost:8001/consumers/ansible/key-auth/ + url: http://localhost:8001/consumers/guest/key-auth/ method: POST - body: 'key=d1fd0ddee6b94d048f4bbb4a854ce56b' + body: 'key=guest' status_code: [201, 409] return_content: yes register: request until: (request.status == 201) or (request.status == 409) retries: 5 - - name: (WILL BE REMOVED) Add consumer ansible to provider + - name: (WILL BE REMOVED) Add consumer guest to provider uri: - url: http://localhost:8001/consumers/ansible/acls + url: http://localhost:8001/consumers/guest/acls method: POST body: 'group=provider' status_code: [201, 409, 400] @@ -112,32 +57,18 @@ until: (request.status == 201) or (request.status == 409) or (request.status == 400) retries: 5 - - name: (WILL BE REMOVED) GET test-api from kong with api-key [200 success] - uri: - url: http://localhost:8000/ - method: GET - headers: - Host: 'example.com' - apikey: 'd1fd0ddee6b94d048f4bbb4a854ce56b' - status_code: [200] - return_content: yes - tags: getapikey - register: request - until: request.status == 200 - retries: 5 - - - name: Creating "/api/0.1.0/register" at kong (http://tomcat:8080) + - name: Creating "/api/1.0.0/register" at kong (http://tomcat:8080) uri: url: http://localhost:8001/apis/ method: POST - body: 'name=register&upstream_url=http://tomcat:8080/RegisterAPI/rest/register&uris=/api/0.1.0/register&methods=GET' + body: 'name=register&upstream_url=http://tomcat:8080/RegisterAPI/rest/newregister&uris=/api/1.0.0/register&methods=POST' status_code: [201, 409] return_content: yes register: request until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding key-auth to "/api/0.1.0/register" + - name: Adding key-auth to "/api/1.0.0/register" uri: url: http://localhost:8001/apis/register/plugins method: POST @@ -148,7 +79,7 @@ until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding acl "provider" group to "/api/0.1.0/register" + - name: Adding acl "provider" group to "/api/1.0.0/register" uri: url: http://localhost:8001/apis/register/plugins method: POST @@ -159,30 +90,18 @@ until: (request.status == 201) or (request.status == 409) retries: 5 - - name: (TESTING) "/api/0.1.0/register" with a new device "test" and provider "ansible" - uri: - url: http://127.0.0.1:8000/api/0.1.0/register - method: GET - headers: - apikey: 'd1fd0ddee6b94d048f4bbb4a854ce56b' - resourceID: "test" - serviceType: "publish,subscribe,historicData" - status_code: [200] - tags: api - retries: 1 - - - name: Creating "/api/0.1.0/publish" at kong (http://rabbitmq:8000/publish) + - name: Creating "/api/1.0.0/publish" at kong (http://rabbitmq:8000/publish) uri: url: http://localhost:8001/apis/ method: POST - body: 'name=publish&upstream_url=http://rabbitmq:8000/publish&uris=/api/0.1.0/publish&methods=POST' + body: 'name=publish&upstream_url=http://rabbitmq:8000/publish&uris=/api/1.0.0/publish&methods=POST' status_code: [201, 409] return_content: yes register: request until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding key-auth to "/api/0.1.0/publish" + - name: Adding key-auth to "/api/1.0.0/publish" uri: url: http://localhost:8001/apis/publish/plugins method: POST @@ -193,7 +112,7 @@ until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding acl "publish" group to "/api/0.1.0/publish" + - name: Adding acl "publish" group to "/api/1.0.0/publish" uri: url: http://localhost:8001/apis/publish/plugins method: POST @@ -204,33 +123,20 @@ until: (request.status == 201) or (request.status == 409) retries: 5 - - name: (TESTING) Posting to "/api/0.1.0/publish" via kong - uri: - url: http://127.0.0.1:8000/api/0.1.0/publish - method: POST - body: > - { "exchange": "amq.topic", "key": "test" ,"priority": 99 ,"body": "hahaha" } - status_code: [200, 401] - return_content: yes - body_format: json - register: request - until: (request.status == 200) or (request.status == 401) - retries: 2 - - - name: Creating "/api/0.1.0/subscribe/bind" at kong (http://rabbitmq:8000/queue/bind) + - name: Creating "/api/1.0.0/follow" at kong (http://rabbitmq:8000/queue/bind) uri: url: http://localhost:8001/apis/ method: POST - body: 'name=bind&methods=POST&upstream_url=http://rabbitmq:8000/queue/bind&uris=/api/0.1.0/subscribe/bind' + body: 'name=follow&methods=POST&upstream_url=http://rabbitmq:8000/queue/bind&uris=/api/1.0.0/follow' status_code: [201, 409] return_content: yes register: request until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding key-auth to "/api/0.1.0/subscribe/bind" + - name: Adding key-auth to "/api/1.0.0/follow" uri: - url: http://localhost:8001/apis/bind/plugins + url: http://localhost:8001/apis/follow/plugins method: POST body: 'name=key-auth' status_code: [201, 409] @@ -239,9 +145,9 @@ until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding acl "subscribe" group to "/api/0.1.0/subscribe/bind" + - name: Adding acl "subscribe" group to "/api/1.0.0/follow" uri: - url: http://localhost:8001/apis/bind/plugins + url: http://localhost:8001/apis/follow/plugins method: POST body: 'name=acl&config.whitelist=subscribe' status_code: [201, 409] @@ -250,20 +156,20 @@ until: (request.status == 201) or (request.status == 409) retries: 5 - - name: Creating "/api/0.1.0/subscribe/unbind" at kong (http://rabbitmq:8000/queue/bind) + - name: Creating "/api/1.0.0/follow" DELETE at kong (http://rabbitmq:8000/queue/bind) uri: url: http://localhost:8001/apis/ method: POST - body: 'name=unbind&methods=DELETE&upstream_url=http://rabbitmq:8000/queue/bind&uris=/api/0.1.0/subscribe/unbind' + body: 'name=unfollow&methods=DELETE&upstream_url=http://rabbitmq:8000/queue/bind&uris=/api/1.0.0/follow' status_code: [201, 409] return_content: yes register: request until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding key-auth to "/api/0.1.0/subscribe/unbind" + - name: Adding key-auth to "/api/1.0.0/follow" uri: - url: http://localhost:8001/apis/unbind/plugins + url: http://localhost:8001/apis/unfollow/plugins method: POST body: 'name=key-auth' status_code: [201, 409] @@ -272,9 +178,9 @@ until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding acl "subscribe" group to "/api/0.1.0/subscribe/unbind" + - name: Adding acl "subscribe" group to "/api/1.0.0/follow" uri: - url: http://localhost:8001/apis/unbind/plugins + url: http://localhost:8001/apis/unfollow/plugins method: POST body: 'name=acl&config.whitelist=subscribe' status_code: [201, 409] @@ -283,18 +189,18 @@ until: (request.status == 201) or (request.status == 409) retries: 5 - - name: Creating "/api/0.1.0/subscribe?name=q1" at kong (http://rabbitmq:8000/queue?name=q1) + - name: Creating "/api/1.0.0/subscribe?name=q1" at kong (http://rabbitmq:8000/queue?name=q1) uri: url: http://localhost:8001/apis/ method: POST - body: 'name=subscribe&methods=GET&upstream_url=http://rabbitmq:8000/queue&uris=/api/0.1.0/subscribe' + body: 'name=subscribe&methods=GET&upstream_url=http://rabbitmq:8000/queue&uris=/api/1.0.0/subscribe' status_code: [201, 409] return_content: yes register: request until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding key-auth to "/api/0.1.0/subscribe?name=q1" + - name: Adding key-auth to "/api/1.0.0/subscribe?name=q1" uri: url: http://localhost:8001/apis/subscribe/plugins method: POST @@ -305,7 +211,7 @@ until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding acl "subscribe" group to "/api/0.1.0/subscribe?name=q1" + - name: Adding acl "subscribe" group to "/api/1.0.0/subscribe?name=q1" uri: url: http://localhost:8001/apis/subscribe/plugins method: POST @@ -316,29 +222,29 @@ until: (request.status == 201) or (request.status == 409) retries: 5 - - name: Creating "/api/0.1.0/cat" at kong (http://hypercat:8000/cat) + - name: Creating "/api/1.0.0/cat" at kong (http://hypercat:8000/cat) uri: url: http://localhost:8001/apis/ method: POST - body: 'name=catGET&methods=GET&upstream_url=http://hypercat:8000/cat&uris=/api/0.1.0/cat' + body: 'name=catGET&methods=GET&upstream_url=http://hypercat:8000/cat&uris=/api/1.0.0/cat' status_code: [201, 409] return_content: yes register: request until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Creating Catalog-POST API "/api/0.1.0/cat" at kong (http://hypercat:8000/cat) + - name: Creating Catalog-POST API "/api/1.0.0/cat" at kong (http://hypercat:8000/cat) uri: url: http://localhost:8001/apis/ method: POST - body: 'name=catPOST&methods=POST&upstream_url=http://hypercat:8000/cat&uris=/api/0.1.0/cat' + body: 'name=catPOST&methods=POST&upstream_url=http://hypercat:8000/cat&uris=/api/1.0.0/cat' status_code: [201, 409] return_content: yes register: request until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding key-auth to "/api/0.1.0/cat" Catalog-POST API + - name: Adding key-auth to "/api/1.0.0/cat" Catalog-POST API uri: url: http://localhost:8001/apis/catPOST/plugins method: POST @@ -349,7 +255,7 @@ until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding acl "provider" group to "/api/0.1.0/cat" Catalog-POST API + - name: Adding acl "provider" group to "/api/1.0.0/cat" Catalog-POST API uri: url: http://localhost:8001/apis/catPOST/plugins method: POST @@ -360,20 +266,20 @@ until: (request.status == 201) or (request.status == 409) retries: 5 - - name: Creating "historicData" API at kong + - name: Creating "database" API at kong uri: url: http://localhost:8001/apis/ method: POST - body: 'name=historicData&methods=GET&upstream_url=http://elasticsearch:9200/sensor_data*/_search&uris=' + body: 'name=database&methods=GET&upstream_url=http://elasticsearch:9200/sensor_data*/_search&uris=/api/1.0.0/db' status_code: [201, 409] return_content: yes register: request until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding key-auth to "/api/0.1.0/historicData" to historicData API + - name: Adding key-auth to "/api/1.0.0/db" to database API uri: - url: http://localhost:8001/apis/historicData/plugins + url: http://localhost:8001/apis/database/plugins method: POST body: 'name=key-auth' status_code: [201, 409] @@ -382,11 +288,11 @@ until: (request.status == 409) or (request.status == 201) retries: 5 - - name: Adding acl "historicData" group to "/api/0.1.0/historicData" historicData API + - name: Adding acl "database" group to "/api/1.0.0/db" database API uri: - url: http://localhost:8001/apis/historicData/plugins + url: http://localhost:8001/apis/database/plugins method: POST - body: 'name=acl&config.whitelist=historicData' + body: 'name=acl&config.whitelist=db' status_code: [201, 409] return_content: yes register: request diff --git a/tests/test_setup.sh b/tests/test_setup.sh index ec47634..5cec02d 100644 --- a/tests/test_setup.sh +++ b/tests/test_setup.sh @@ -19,4 +19,4 @@ sudo mkdir -p /data/logs/tomcat sudo usermod -aG docker $USER ssh-keygen sudo chmod -R 777 /data/* -sudo csysctl -w vm.max_map_count=662144 +sudo sysctl -w vm.max_map_count=662144