Install flows in OpenDaylight using Java

Although I had already done a similar post for this here, guess there are a lot of folks who are not able get everything working together without the actual source code.

So I thought it might be helpful if I provide with some ready to use project/code for installing flows using java.

1. Download the source code.

Download the source code of project “OpenDaylightFlowInstall” from my GitHub here. This will give you the following:

  1. FlowManager Class – Responsible for adding/deleting flows
  2. Tester Class – Responsible for actually passing the data & calling FlowManager class to install/delete flows.
  3. ODL Class – Responsible for OpenDaylight settings.

2. Import/Setup the code

You can import the code into eclipse as a java project or setup your command. Whatever you prefer.

To import the code in eclipse use “Import as Java Project” option and make sure that your “Project –> Build Automatically” is switched on.

e1

Also make sure that the two jars in lib folder are in classpath else compilation will fail.

3. Network & OpenDaylight Setup

I have a mininet running with one switch and two hosts which are able to ping each other & connected to OpenDaylight.

2

odl

4 Running the program

If you are using eclipse, simply right clicking on the tester class and saying “Run as Java Application” should run the code. Make sure of two things:

  1. Supply the right Src/Dest IP & Node details in the Tester.java

  2. Correct values in ODL.java under settings.

Once you run the program, the action DROP will be installed and ping will stop working.

3 odl2

Let me know, if you get stuck & i’ll try to help.

Skeleton OpenDaylight Application for Hydrogen

We have been writing OpenDaylight applications for quite some time & I see that there are lot of samples already available, but what I most of the times want is a skeleton project which I could just import in eclipse & its good to go with writing code. So a skeleton project with all the wiring already done is my frequent need.

So I have created a skeleton project for OpenDaylight which has everything bare minimum needed to start with a OpenDaylight application.

Prerequisite

  • You should already have OpenDaylight Hydrogen source code downloaded & working with eclipse.

Setup

  1. Pull the code of a blank/dummy hack application from my git.
  2. Copy this project under “controller/opendaylight/” where other opendaylight modules are present.
  3. Import this project into eclipse as a Maven project.
  4. Start putting in your code & you are good to go.

Testing

Once you build the above project, it will install a jar in target folder of the project. There are two ways of testing.

  1. Copy this jar manually into plugins folder of distribution.
  2. Make a entry into the parent & opendaylight root pom for this new module & rebuild.

Let me know, if you find any issues in deploying this hack or setting it up, in comments below.

OpenDaylight REST NBI Documentation

After the Helium release of OpenDaylight, I had this common problem of “How to refer REST NBI of Hydrogen release”. Wiki doesn’t work, I work with the distribution most of the time & same is with my friends.

So I thought of hosting the REST NBI Documentation of Hydrogen Release of OpenDaylight to help myself and in turn others who want to refer it.

I have put together a basic wiki type page where you can refer the NBI’s, model’s, URL’s etc of all the Hydrogen released northbound interfaces.

Please visit: http://opendaylight.nbi.sdngeeks.com

ODL_NBI

OpenFlow ALL Vs FLOOD Action

There has been always a confusion in my mind regarding the difference between OpenFlow ALL and FLOOD action. If you are one of them, go on!

Technically, the spec definition says:

FLOOD: Flood the packet along the minimum spanning tree, not including the incoming interface.

ALL: Send the packet out all interfaces, not including the incoming interface.

So, what’s the difference?

ALL action is pretty much clear in what it says. What is implied by saying “along the minimum spanning tree” is that flood the packet on all the ports where STP is disabled.

Now if we take a case of Juniper Junos OS with OpenFlow which do not support STP, in that case all the ports will have STP disabled due to lack of feature and both ALL & FLOOD actions will behave in the same way.

Hope it helps!

Install PostgreSQL on CentOS 6.x

While working on my last assignments I had to install/re-install PostgreSQL multiple times and initially didn’t find a consolidated tutorial as to how to do it step-by-step on CentOS 6.x.

So here is a step-by-step guide on “How to install PostgreSQL on CentOS 6.x”

Install PostgreSQL

You first need to add the PostgreSQL repository to yum and update it.

CentOS 6.x 32bit:

rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-centos94-9.4-1.noarch.rpm

CentOS 6.x 64bit:

rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm

Finally update the yum package.

yum update

Install & Initialize PostgreSQL:

yum install postgresql94-server postgresql94-contrib
service postgresql-9.4 initdb

Start PostgreSQL service and make it to start automatically on every reboot.

service postgresql-9.4 start
chkconfig postgresql-9.4 on

Adjust iptables for external access of PostGreSQL.

vi /etc/sysconfig/iptables

Add the following line:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Save and exit the file. Restart iptables service.

service iptables restart

Configure PostgreSQL-MD5 Authentication:

MD5 authentication requires the client to supply an MD5-encrypted password for authentication.

vi /var/lib/pgsql/9.4/data/pg_hba.conf

Add or Modify the lines as shown below

[...]
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             192.168.1.0/24          md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
[...]

Restart PostgreSQL service:

service postgresql-9.4 restart

Access PostgreSQL command prompt

The default database name and database user are “postgres”. To access PostgreSQL related operations:

su - postgres 
bash#psql

Sample Output:

psql (9.4.0)
Type "help" for help.
postgres=#

To exit from PosgreSQL prompt, type \q.

Set “postgres” user password, login to PostgreSQL prompt,

su - postgres 
bash#psql

Set postgres password:

postgres=# \password postgres 
Enter new password: 
Enter it again: 
postgres=# \q

Create New User and Database

For example, let us create a new user called “saurabh” with password “agarwal”, and database called “mypostgres”.

Switch to postgres user:

su - postgres

Create user saurabh.

$ createuser saurabh

Create database:

$ createdb mypostgres

Login to the psql prompt and set password and grant access:

bash# psql
postgres=# alter user senthil with encrypted password 'agarwal';
ALTER ROLE
postgres=# grant all privileges on database mypostgres to saurabh;
GRANT
postgres=#

Hope this helps someone, starting afresh with PostgreSQL installation.

Let me know (in comments below) if something is missed.