Export Insert Data in PostgreSQL

Recently, I was involved a SDN App which is using PostgreSQL database as backend. After finally developing the app and doing upgrades, we stumbled upon the migration scenario where data export of the existing database was needed. Hence I started researching about, how to export data (basically only insert statements) in PostgreSQL.

Though it seemed very every easy to do this from pgAdmin GUI tool, we needed to do it from console due to firewalls and it took us some time to figure out the right command to do it.

PostgreSQL Version: 9.2

Login as postgres admin user

su - postgres

Run the export command below:

.\pg_dump --username "postgres" --format plain --section data --inserts --file "<backup file name>" "<db to backup>"

Hope it helps!

Advertisements

Path of a packet with OpenDaylight managing OpenFlow devices

What I have tried to stitch together in this post is how a packet flows between a OpenFlow enabled network device to the controller which processes it (& how or using which interfaces) and return back path of the packet.

You might have seen the standard OpenDaylight architecture as below already.

ODL_ArchitectureFirst, it is important to understand the above diagram briefly, to lay the expectations:

  1. OpenFlow Enabled Devices: This is the network infrastructure that is managed via OpenDaylight. In this case OpenFlow plug-in.
  2. Protocol Plugins: OpenDaylight supports these protocols for managing your network devices. One of the plugins is OpenFlow.
  3. Service Abstraction Layer (SAL): Magic! This layer does all the plumbing between the applications and the underlying plugins.
  4. Controller Platform: These are the applications that come pre-bundled with OpenDaylight to manage the network. (You can write your’s too!)
  5. Network Applications: These are applications with leverage REST NBI of OpenDaylight to build intelligence. Here is a sample Network Statistics SDN Application that I have done!

Now, below is how packet flow from network to OpenDaylight & back to network takes place:

ODL_Packet_Lifecycle

  1. A packet arriving at a network device will be sent to the appropriate protocol plugin of OpenDaylight which is managing the switch.
  2. IPluginOutDataPacketService: The plugin (in our case OpenFlow Plug-in) will parse the packet, generate an event for Service Abtraction Layer (SAL) for further processing.
  3. IListenDataPacket: SAL will dispatch the packet to all the modules listening for DataPacket. These could be existing OpenDaylight applications like ARP Handler of your applications.
  4. IDataPacketService: Application/Module does the processing on the packet as per the business logic built and sends a PACKET_OUT using IDataPacketService.
  5. IPluginInDataPacketService: SAL recieves the DataPacket and dispatches it to the modules listening for plug-in DataPackets. In this case OpenFlow plugin.
  6. OpenFlow plugin then sends the packet back to the switch from where the packet was originated.

This is as per my understanding & if you think I have missed something or you need more details and code samples, let me know.

What is Mininet? Simple explaination

Starting on to experiment or learn SDN concepts? So where do you start?

Baseline requirement to do/experiment anything in SDN is the need of network devices with OpenFlow. So, how do you go about it and how do you get it?

First way to go about it is buy real hardware from vendors who have OpenFlow enabled switches in market, which can be extremely expensive, time exhausting and bad way to experiment.

Second, you could get Mininet.

Mininet is a software emulator for prototyping a network on a single machine.

Simply put, this is all it takes:

  1. Run just one command (sudo mn) on Mininet, and you get,
  2. Network topology with hosts & devices, which is connected to
  3. A bundled SDN Controller

mininet

So, Mininet can be used to quickly create a realistic virtual network running actual kernel, switch and software application code on a personal computer.

Now, with Mininet in your hands, you can experiment with OpenFlow, play with the topology you want, learn concepts and also, build SDN applications easily.

Mininet proved to be a great kickstarter for me & opened up the space for me. There is already so much help available on Mininet but I’ll write as I find new or different things in it.

Network Statistics Sample SDN Application With OpenDaylight

I have been working on SDN applications for quite some time now and wanted to create a demo/sample app that could be reference or bootstrap app for people willing to explore more.

So I took some time out to come up with a idea of doing a very basic (some might call it no-brainer) SDN app for learning.

This application helps demonstrate following:
  • Demonstrate how REST API’s of a SDN Controller (in my case OpenDaylight) can be used to build a app.
  • I did not want to use any server-side programming/code to do this. This really shows the power of REST & SDN architecture.
  • Simple app that is easy to understand and replicate for someone learning this stuff.
  • Help you understand some concepts of SDN NBI that people talk about.
What is Network Statistics SDN Application ?

Bundled into a beautiful GUI, Network Statistics SDN Application runs on-top of a OpenDaylight SDN Controller and tracks port & table statistics of devices/nodes managed via OpenDaylight SDN Controller. Pure jQuery/Bootstrap and HTML based application without any server-side code.

Complete set of UI Screens developed for the application.

Things you can do in this application:

  1. Supply the URL/Username/Password of your OpenDaylight SDN Controller. Start tracking Nodes!
  2. View all the nodes managed by OpenDaylight in Network Devices section.
  3. View Port and Table statistics of each node found.

This is kind of no-brainier, but you can come up with more use cases around it etc, what this app if for? Its just for the kick-start.

If you are interested in running it:
  1. You can get the complete code from my git or if that’s too much work and you don’t intend to change code & just want to see it in action, download the file of this application from here (do “Save Link As“, this is .png, rename it to .war).
  2. Run the application either from code or by dropping the .war into tomcat/jetty/jboss (some web server)
  3. Supply your pre-installed OpenDaylight credentials and see it in action at http://localhost:8080/NetworkStatsApplication/
Assumptions:
  • I assume that you have a mininet and OpenDaylight setup working already as that is a per-requisite to building any application.
  • I prefer you read Brent’s blog on this which I refer whenever I’m stuck at things he has written about.

How I built this application and the code walk thru I have explained it in part-2 of this post as this blog was getting too long for everything.