Installing Docker-based opennsa in Linux 14.04 (JRA1 Lab virtual machine)

In order for the JRA1 team to have a Docker based opennsa playground, the complete environment was installed in one of the Ubunto 14.04 virtualmachines. This installation includes the PostgreSQL DBMS, the required databases, python, the opennsa distrubution and the Docker installation.

When correctly installed, this setup allows you to do the following:

# activate the opennsa python environment (put in your .bashrc?)
cd /data/opennsa
. /python/virtualenv/opennsa/bin/activate
# start the GTS simulation (end it with CRTL-C)
docker-compose up
# (in a second terminal) list the running docker container
docker ps
# connect to a running virtual machine
docker exec -i -t opennsa-ams /bin/bash
# make a opennsa reservation in the GTS simulation (dud devices)
./onsa reserve -v -p main -s ams.gts.nsi.geant.net:topology:server2-0#vlan=12 -d bra.gts.nsi.geant.net:topology:server2-0#vlan=11
# query an opennsa reservation
./onsa query -p main -c GT-f7f10869d8
But first, we need to install the Docker based GTS simulation.

Update the virtual machine


taas@OpenNSA-dev-13:~$ uname -a
Linux OpenNSA-dev-13 4.4.0-83-generic #106~14.04.1-Ubuntu SMP Mon Jun 26 18:10:19 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
sudo apt update
sudo apt upgrade
sudo apt install git libssl-dev libffi-dev
sudo locale-gen "nl_NL.UTF-8"
sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales


Install the opennsa distribution


Clone the opennsa distribution in a 'standard' place, and add the Docker specific files (you will need docker-compose.yml and opennsa-config.tgz. The latter contains Dockerfile and several 'dud'-based configuration files).

. /python/virtualenv/opennsa/bin/activate
sudo mkdir /data
sudo chown taas:taas /data
git clone https://code.geant.net/stash/scm/ccs/opennsa.git
cd opennsa
git checkout domainagg
cp ~/docker-compose.yml .
mkdir build
cd build
tar -zxvf ~/opennsa-config.tgz

Install Postgresql


Install Postgresql and adjust its configuration so external hosts (ie the Docker containers) can access their databases.

sudo apt install postgresql libpq-dev
cd /etc/postgresql/9.3/main
sudo cp pg_hba.conf pg_hba.conf.orig
sudo cp postgresql.conf postgresq.conf.orig
sudo vi pg_hba.conf

Changes to pg_hba.conf:

taas@OpenNSA-dev-13:/etc/postgresql/9.3/main$ sudo diff pg_hba.conf pg_hba.conf.orig 

90c90
< local all all md5
---
> local all all peer
100,102d99
< # Allow access from remote
< host all all 0.0.0.0/0 trust
<
sudo vi postgresql.conf

Changes to postgresql.conf

(opennsa)taas@OpenNSA-dev-13:/etc/postgresql/9.3/main$ sudo diff postgresql.conf postgresql.conf.orig 
59d58
< listen_addresses = '*'

sudo -u postgres psql
postgres=# CREATE USER opennsa WITH PASSWORD 'secretpassword';
sudo service postgresql restart



The DBMS is now polished and ready for creating the databases:

cd /data/opennsa
sudo -u postgres createdb -O opennsa opennsa-ams
sudo -u postgres psql -U opennsa -W opennsa-ams < datafiles/schema.sql
sudo -u postgres createdb -O opennsa opennsa-bra
sudo -u postgres psql -U opennsa -W opennsa-bra < datafiles/schema.sql
sudo -u postgres createdb -O opennsa opennsa-ham
sudo -u postgres psql -U opennsa -W opennsa-ham < datafiles/schema.sql
sudo -u postgres createdb -O opennsa opennsa-lon
sudo -u postgres psql -U opennsa -W opennsa-lon < datafiles/schema.sql
sudo -u postgres createdb -O opennsa opennsa-mad
sudo -u postgres psql -U opennsa -W opennsa-mad < datafiles/schema.sql
sudo -u postgres createdb -O opennsa opennsa-mil
sudo -u postgres psql -U opennsa -W opennsa-mil < datafiles/schema.sql
sudo -u postgres createdb -O opennsa opennsa-par
sudo -u postgres psql -U opennsa -W opennsa-par < datafiles/schema.sql
sudo -u postgres createdb -O opennsa opennsa-prg
sudo -u postgres psql -U opennsa -W opennsa-prg < datafiles/schema.sql
sudo -u postgres createdb -O opennsa opennsa-main
sudo -u postgres psql -U opennsa -W opennsa-main < datafiles/schema.sql


Install Python and virtual environments


In order to run ./onsa in the host operating system, we need a beefed-up python:

taas@OpenNSA-dev-13:~$ python --version
Python 2.7.6
sudo apt install python-virtualenv python-pip python-dev python-openssl
sudo mkdir /python
sudo chown taas:taas /python
cd /python
mkdir virtualenv
cd virtualenv
virtualenv opennsa
. /python/virtualenv/opennsa/bin/activate
cd /data/opennsa
pip install -r build/config/requirements.txt

Install Docker and Docker-Compose


Install the latest/current Docker for ubuntu  (according to https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04)


curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-cache policy docker-ce
sudo apt-get install -y docker-ce
sudo usermod -aG docker ${USER}
<log-out-and-in to activate the new docker group membership.>
<do not enter the opennsa virtual-env>
sudo pip install docker-compose

Create the opennsa image


Now we have our environment ready, create the image given the Dockerfile.


cd /data/opennsa
docker build -t opennsa_img -f build/config/docker/Dockerfile .

With this image in place in our local Docker store, it is time to create our GTS containers using the docker compose file:

cd /data/opennsa
docker-compose up

Everything is up and running now. Check this by attaching to one of the containers:

docker exec -i -t opennsa-ams /bin/bash

But much more convincing is to create our first reservation in the simulation of the GTS network. We are going to use the ./onsa command-line script, so first we
need to create some defaults in ~/.opennsa-cli:

bandwidth=200
host=10.50.0.1
port=7080
starttime=+20
endtime=+260

nsa=main,gts.nsi.geant.net:2013:nsa,http://10.50.0.7:9443/NSI/services/CS2


And now for our first reservation:

cd /data/opennsa
. /python/virtualenv/opennsa/bin/activate
(opennsa)taas@OpenNSA-dev-13:/data/opennsa$ ./onsa reserve -v -p main -s ams.gts.nsi.geant.net:topology:server2-0#vlan=12 -d bra.gts.nsi.geant.net:topology:server2-0#vlan=11
Defaults:
nsa : {'main': ('gts.nsi.geant.net:2013:nsa', 'http://10.50.0.7:9443/NSI/services/CS2')}
host : 10.50.0.1
bandwidth : 200
starttime : 2017-07-05 12:43:03.067573
endtime : 2017-07-05 12:47:03.067636
port : 7080
Requester URL: http://10.50.0.1:7080/NSI/services/ConnectionService
Site starting on 7080
Received SOAP request. Action: "http://schemas.ogf.org/nsi/2013/12/connection/service/reserveConfirmed". Length: 1637
Connection created and held. Id GT-f7f10869d8 at urn:ogf:network:gts.nsi.geant.net:2013:nsa
Source - Destination: <STP ams.gts.nsi.geant.net:topology:server2-0?vlan=12> - <STP bra.gts.nsi.geant.net:topology:server2-0?vlan=11>
Received SOAP request. Action: "http://schemas.ogf.org/nsi/2013/12/connection/service/reserveCommitConfirmed". Length: 789
Reservation committed at urn:ogf:network:gts.nsi.geant.net:2013:nsa
(TCP Port 7080 Closed)


With the reservation made, we can query it:

(opennsa)taas@OpenNSA-dev-13:/data/opennsa$ ./onsa query -p main -c GT-f7f10869d8
Site starting on 7080
Query results:

Connection GT-f7f10869d8 (urn:ogf:network:gts.nsi.geant.net:2013:nsa)
Description Test Connection
States ReserveStart, Released, Created
Dataplane Active : False, Version: 0, Consistent False
Start-End 2017-07-05 12:43:03.067573 - 2017-07-05 12:47:03.067636
Path ams.gts.nsi.geant.net:topology:server2-0?vlan=12 -- bra.gts.nsi.geant.net:topology:server2-0?vlan=11
Bandwidth 200
Direction Bidirectional

(TCP Port 7080 Closed)





  • No labels