Tuesday, July 26, 2016

Setting up Tyk Portal and Developer Registrations

There was this long running bug that is hitting us from setting up the Tyk portal. The issue was with Tyk not allowing custom domains from being set up as portal. While the settings as advised in Tyk mention the dashboard and portal port as 3000, ideally it should be set as 80 to get the portal configured seamlessly. I learned it hard-way after so many attempts on getting this done on port 3000.


Setting up Portal Domain
Add to /etc/hosts file:
127.0.0.1 dashboard.tyk-local.com
127.0.0.1 portal.tyk-local.com
Most probably Apache2 or some other web server would already be listening on the port 80. Make sure to stop it to release the port.

Stop Apache2 Web Server

/etc/init.d/apache2 stop

Configure Tyk Gateway

sudo /opt/tyk-gateway/install/setup.sh --dashboard=http://dashboard.tyk-local.com --listenport=8080 --redishost=localhost --redisport=6379 --domain=""


Configure Tyk Dashboard

sudo /opt/tyk-dashboard/install/setup.sh --listenport=80 --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics --tyk_api_hostname=127.0.0.1 --tyk_node_hostname=http://127.0.0.1 --tyk_node_port=8080 --portal_root=/portal --domain="dashboard.tyk-local.com"


Configure Tyk Pump

sudo /opt/tyk-pump/install/setup.sh --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics


Initial start to set up the Tyk license


sudo service tyk-pump start
sudo service tyk-dashboard start

Access http://dashboard.tyk-local.com/ and add the license in the prompt.

Restart the Tyk Dashboard and start the Tyk Gateway
sudo service tyk-dashboard restart
sudo service tyk-gateway start


Fix the Tyk bootstrap script to listen at port 80

gedit /opt/tyk-dashboard/install/bootstrap.sh and remove :3000 from all the references, since we are going to use the default port 80, instead of port 3000 as the dashboard port.


#!/bin/bash
# Usage ./bootstrap.sh DASHBOARD_HOSTNAME

LOCALIP=$1
RANDOM_USER=$(env LC_CTYPE=C tr -dc "a-z0-9" < /dev/urandom | head -c 10)
PASS="test123"

echo "Creating Organisation"
ORGDATA=$(curl --silent --header "admin-auth: 12345" --header "Content-Type:application/json" --data '{"owner_name": "Default Org.","owner_slug": "default", "cname_enabled": true, "cname": ""}' http://$LOCALIP/admin/organisations 2>&1)
#echo $ORGDATA
ORGID=$(echo $ORGDATA | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["Meta"]')
echo "ORGID: $ORGID"

echo "Adding new user"
USER_DATA=$(curl --silent --header "admin-auth: 12345" --header "Content-Type:application/json" --data '{"first_name": "John","last_name": "Smith","email_address": "'$RANDOM_USER'@default.com","password":"'$PASS'", "active": true,"org_id": "'$ORGID'"}' http://$LOCALIP/admin/users 2>&1)
#echo $USER_DATA
USER_CODE=$(echo $USER_DATA | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["Message"]')
echo "USER AUTH: $USER_CODE"

USER_LIST=$(curl --silent --header "authorization: $USER_CODE" http://$LOCALIP/api/users 2>&1)
#echo $USER_LIST

USER_ID=$(echo $USER_LIST | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["users"][0]["id"]')
echo "NEW ID: $USER_ID"

echo "Setting password"
OK=$(curl --silent --header "authorization: $USER_CODE" --header "Content-Type:application/json" http://$LOCALIP/api/users/$USER_ID/actions/reset --data '{"new_password":"'$PASS'"}')

echo ""

echo "DONE"
echo "===="
echo "Login at http://$LOCALIP/"
echo "User: $RANDOM_USER@default.com"
echo "Pass: $PASS"
echo ""


Save and exit the bootstrap script and execute it.

sudo /opt/tyk-dashboard/install/bootstrap.sh dashboard.tyk-local.com



root@llovizna:/home/pradeeban#  sudo /opt/tyk-dashboard/install/bootstrap.sh dashboard.tyk-local.com
Creating Organisation
ORGID: 579794145ee8571e46000001
Adding new user
USER AUTH: 6936a780a8e448fd73e3d7ef64eb8059
NEW ID: 5797941458149ac06a14e801
Setting password

DONE
====
Login at http://dashboard.tyk-local.com/
User: c9og13fnc8@default.com
Pass: test123

Tyk Developer Portal
Now you are good to log in to the Tyk Dashboard with the given credentials.

Set Portal domain
portal.tyk-local.com

This would give a message, "CNAME updated"
Now if you access http://portal.tyk-local.com/portal/ it would says "Home page not found". This is expected as you have not set up the portal and the welcome page yet. 

Follow the below document to get this set up.

Once you have set this up, your portal is ready for the developers to register, log in, and consumes the APIs defined in the API catalogue.

Monday, July 11, 2016

Tyk Dashboard crashed after setting the portal domain

So I set the portal domain to be as the same with the dashboard. Later, I was instructed that it is not permitted to have the portal domain same as the dashboard.

However, now I am left with the below error which does not simply disappear when I reconfigure Tyk.

panic: http: multiple registrations for dashboard.tyk-local.com:3000/

goroutine 1 [running]:
panic(0xa60f80, 0xc820370be0)
    /usr/local/go/src/runtime/panic.go:464 +0x3e6
net/http.(*ServeMux).Handle(0xc820356d50, 0xc82036f7e0, 0x1d, 0x7f5a221595d8, 0xc82027af20)
    /usr/local/go/src/net/http/server.go:1926 +0x297
main.GenerateRoutes()
    /home/tyk/go/src/github.com/lonelycode/tyk-analytics/Main.go:733 +0x41b7
main.main()
    /home/tyk/go/src/github.com/lonelycode/tyk-analytics/Main.go:750 +0x59


I basically had to drop the Mongo table, and then reconfigure Tyk to get everything back in place.

In Mongo shell:
> use tyk_analytics
switched to db tyk_analytics
> db.dropDatabase();
{ "dropped" : "tyk_analytics", "ok" : 1 }

Sunday, July 10, 2016

Long walks of a gypsy student

Flowers on my way, Atlanta
I was attending a conference in San Francisco, and one of my peers reminded me that I did not blog much recently. I realized, that is because of the limited time, and also I am getting used to rapid changes. When I came to Portugal in 2012, everything seemed fresh, and moving to a foreign country for the first time made me feel like I was reborn or starting my life afresh. However, after living in 2 other countries (Sweden and Croatia), I came to the US which is in fact my 4th country to live outside Sri Lanka. These international travels, and frequent migrations all has become part of our life.

Since we always have to be ready for our next migration, we also learn to live light-weight. I did not purchase unnecessary large items recently. More like a life of a monk. :) In addition to my past migrations, we are getting back to Portugal in October. Then I have to join my second host institution in Belgium. There have been a discussion on moving to Saudi Arabia, and all so many plans with travels across 4 countries in 3 continents.

Probably I should write a book or something when time permits. "4 countries 3 continents. A year in the life of a modern day gypsy student." I am not even sure which city and country are we going to celebrate the new year this time. Since I moved to Portugal in 2012, it has always been Lisboa.

The new Asus laptop and the elephant speaker
Being a student volunteer in a conference was a remarkable experience. I was able to involve deeply in organizing the conference event on-site, and experience how things are done. I was able to get a first hand experience and have a different perspective as I have never been in the other side of the table. I was always a participant. This 2nd of July, I also won a laptop in a lucky draw. It was interesting as I have never won any lucky draws before. :) Also we all received a beautiful elephant speaker.

Some walks are always remarkable and hard to forget. To mention a few: my nightly walks from my office in Colombo to the bus stop through Flower Road (2010 - 2012), my walks to IST from my apartment in Lisboa (2012 - 2013), long forest walks in Stockholm/Farsta Strand (2013), long walks to our apartment in Benfica Lisboa (2015), zig-zag walks in Rijeka since the sidewalks are present only on one side and at intervals (2015), and now my daily walks to the lab from our apartment in Atlanta. I should note that I am good at walking - long distances. :) Since I walk or use public transport almost always, I can be confident that my carbon footprint always remained minimal - unlike those stars who fly in private jets and then plant some trees and go on preaching. :)

I should however note that Atlanta is not pedestrian friendly. There are streets with no pedestrian paths or side walks. You may be walking leisurely in a side walk, which would end abruptly in the street, where you will be forced to walk amid the traffic. Sudden installation of water pumps by the apartments along the side walks that will soak you as you walk along. If you are careful, you will still have to cross the street. Worse, there are not enough crosswalks, with fast moving traffic. Bus stops in the middle - with no sidewalk in one side with no crosswalk to reach the other side that has the sidewalk. Overall, no one paid attention to the pedestrians in a developed city. No walk - then drive to the gym for a treadmill. Despite all these rants, I still love my daily walk. Running squirrels and chipmunks. Hot and humid summer making you feel that you just reached a sauna. Dense vegetation still could not relieve the hot sunlight. No pollution. All good.

There are some events or time intervals in the past that always remain the best of the memories - such as the 2013 year end in Nordic countries and 2015 summer in Balcans. That reminds me that I miss the summer in Europe.

Wednesday, July 6, 2016

Tyk 2.0 in Centos

There are some minor changes in setting up Tyk 1.9 and Tyk 2.0, and also some differences between setting up on Ubuntu vs Centos.

Installing Tyk 2.0 on Centos is described here.

sudo /opt/tyk-gateway/install/setup.sh --dashboard=http://lion.bmi.emory.edu:3000 --listenport=8080 --redishost=localhost --redisport=6379 --domain=""


sudo /opt/tyk-dashboard/install/setup.sh --listenport=3000 --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics --tyk_api_hostname=localhost --tyk_node_hostname=http://localhost --tyk_node_port=8080 --portal_root=/portal --domain="lion.bmi.emory.edu"



sudo /opt/tyk-pump/install/setup.sh --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics


sudo service tyk-pump start
sudo service tyk-dashboard start

http://lion.bmi.emory.edu:3000/


sudo service tyk-dashboard restart
sudo service tyk-gateway start


sudo /opt/tyk-dashboard/install/bootstrap.sh  lion.bmi.emory.edu

Thursday, June 30, 2016

Building Blocks of Mayan: Componentizing the eScience Workflows Through Software-Defined Service Composition




Today, I presented my paper titled, "Building Blocks of Mayan: Componentizing the eScience Workflows Through Software-Defined Service Composition" at ICWS 2016 in San Francisco. The presentation slides can be found above. This paper was based on the short-term scientific mission (STSM) I had at the University of Rijeka, Croatia last year.

Abstract: eScience consists of computation-intensive workflows executing on highly distributed networks. Service compositions aggregate web services to automate scientific and enterprise business processes. Along with the increased demand for data quality and Quality of Service (QoS) for an accurate outcome in a shorter completion time, execution of the eScience workflows and service compositions are also required to be distributed efficiently across various geo-distributed nodes. This paper presents Mayan, a Software-Defined Networking (SDN) based approach for service composition.

Mayan i) facilitates an adaptive execution of scientific workflows, ii) offers a more efficient service composition by leveraging distributed execution frameworks, in addition to the traditional web service engines, and iii) enables a very large-scale reliable service composition by finding and consuming the current best-fit among the multiple implementations or deployments of the same service.