Saturday, March 21, 2015

OpenStack and SDN - The neutron buzz !!

Lately, I have been reading quite a lot about OpenStack and all the buzz around neutron and SDN. You would find many links and a plethora of information online. This post is an effort to highlight or describe in simple words, the role of OpenStack neutron in connection to SDN. So without wasting any time, lets start.

We all know that Neutron is the OpenStack's project to offer Network as a Serivce - NaaS. Neutron started as a separate project after it was separated from nova-network.
With the growing interest in OpenStack, a lot of companies are making efforts to integrate their SDN solutions with OpenStack.

How are they (companies) doing it ?



The above figure is the answer to what the companies are doing. The top layer is the application layer which calls the neutron service APIs(1). The neutron service APIs are the APIs which are exposed to OpenStack services, say horizon (For example, when you do some network configuration from the OpenStack GUI). 

Between the neutron service API and physical layer, lies the neutron plugin.
To write a neutron plugin, the vendor/company/individual should adhere with the below rule:
1. Implement the interface called by Neutron service APIs(3).
Thus, at any point, interface 1 remains unchanged and the network function is realized using the same APIs - the neutron service APIs. This helps in keeping the application logic independent of the actual networking hardware.
Additionally, if a vendor wants to provide some additional functionality, he can provide several high-level APIs(2) via the API extension layer. These APIs also interact with the neutron plugin(3) to realize a high-level APIs(2) on the hardware. Using this, a vendor X can also integrate his switches with OpenStack solution. 



Companies are thus integrating their SDN solutions with OpenStack by means of neutron plugin. Refer this link to know more about various solutions available.

Writing OpenStack application - A simple example

Finally, after reading Brent Salisbury's post I got my OpenStack-ODL environment up and running. So, I thought of writing a small application on OpenStack using the novaclient.v1_1.client package.

Setup Environment:

  • As described in this post till the line "The state of OVS after the stack should be the following:" [Just grep this line and do everything done before this.]
  • 2 VM running instances namely test_vm1, test_vm
  • The script should run on the Controller VM.


If you have your own setup, then you can take down the below details

  • Python version 2.7.5
  • Below packages need to be installed
  • pip install python-keystoneclient
  • pip install python-novaclient
Lets look at the below sample script.

  1 #!/usr/bin/env python
  2 import novaclient.v1_1.client as nvclient
  3
  4 # Replace the values below  the ones from your local config,
  5 auth_url = "http://192.168.56.104:5000/v2.0"
  6 username = "admin"
  7 password = "admin"
  8 tenant_name = "demo"
  9 project_id = "demo"
 10
 11
 12 nova = nvclient.Client(auth_url=auth_url, username=username,
 13                            api_key=password, project_id=project_id)
 14
 15 # Get the list of VMs
 16 srv_list =  nova.servers.list()
 17 server = nova.servers.find(name="test_vm1")
 18 print server
 19 print 'Rebooting server '+'test_vm1 ...'
 20 server.reboot()
 21 print 'test_vm1 rebooted'


Line 2 is used for importing nova package with.
Line 5-9 describe your local settings. When you run the controller node using devstack, you'll get the below output:
Horizon is now available at http://192.168.56.104/
Keystone is serving at http://192.168.56.104:5000/v2.0/
The IP Address here is the IP on which horizon service is running.
On line 5, the port number 5000 is used. You may also use port number 35357. Port 5000, 35357 are keystone's port numbers of public and administrative end-points.
For more details on port numbers, check this.

Line 12 is used to create a nova client object against which nova API calls would be made.
Line 16 and 17 are used to obtain the list of VMs and get the object of instance with name "test_vm1".
API call on line 20 finally reboots the instance.
Refer this to see the list of Server module APIs.

*********************************OUTPUT************************************
[fedora@fedora-odl-1 ~]$ python os_sample.py
[, ]
Rebooting server test_vm1 ...
test_vm1 rebooted
[fedora@fedora-odl-1 ~]$


Dashboard state before running the script.

After running the script os_sample, you'll see the rebooting message in the Power state column.

Acknowledgements:
This post is incomplete without acknowledging this wonderful link.

Wednesday, June 22, 2011

Static v/s Dynamic Library

What is a static library?

First of all, a library is a set of functions complied into an object code that is used by applications. When we compile a program that uses a static library, the entire object code gets included in the executable code thus increasing the size of executable. Lets say, the library is altered. Now in this case, you need to recompile the library and recompile your application. The other disadvantage is that if there are several applications running that use the static library, then it leads to wastage of space as the library is included in all the executables. Static libraries are also called as archives(.a extension). Try exploring the makefile, it will have loads of .a libraries in the dependency list.

Dynamic Library:
It consists of routines or functions that are loaded at runtime if a reference exists. In this case, instead of including the entire object code, we include a reference to the library and define the rules on how to find this reference(basically tell the linker where to locate the library for eg, /usr/lib). You can keep it anywhere but just mention the path in the linker search path. They have the advantage that if your library gets changes, the application using the library need not be compiled, it just keeps running. If more than one application using this dynamic library is running, then only a single copy is loaded into the memory which is used by all the applications. These have ".so" extension.

Tuesday, March 16, 2010

Virtual Memory

Hi again. In this post Im gonna discuss about virtual memory.Yes... youll find loads of material on virtual memory on the web.For all those preparing for interviews, its a sure shot question. Its kinda interviewers favorite question... So lets hit it....

Virtual Memory:
When we open some applications on our computer like an internet browser,mp3 player,text editors etc all at the same time, the pages of these applications are brought into RAM by computer. Now lets say, there is only 64MB of RAM in your computer and lets forget the concept of virtual memory. If there was no thing called virtual memory then this would mean that when your applications occupied 64MB in your RAM, then your computer would stop obeying your orders of opening new applications. Wont that be unfair to you, u spent lotsa money on that box and it defies you....

Here comes the role of virtual memory.....
This concept is based on the fact that when you run an application, not all the pages of the application are needed at once and also that about 10-20% of the pages are required to keep the application running...
Virtual memory lets you to bring the pages required at a particular instant into RAM and swap out those which are not being used.
These swapped out pages are kept on the hard disk. In linux, we have the swap filesystem whereas in windows we have pagefile.sys for this purpose.
The user is unaware of this whole mechanism and gets an illusion that there is indefinite amount of RAM at his disposal for him to open several applicatoins.

Let me also discuss now how the various memories are organized.

CACHE-------RAM------VIRTUAL MEMORY | HARD DISK

When a page is needed, the CPU first checks the page in cache memory. If the page is not found in cache, then cpu looks up for it in RAM. If found in RAM, the CPU keeps a copy of the page in cache so that, it is available for next demand from the cache itself.
If the page is neither found in RAM nor in the Cache, then the page is loaded from the virtual memory, which resides on the hard disk, into the RAM

Wednesday, March 10, 2010

Linux - .profile file

Hey, ur all back...once again !!!
Ive been working on Linux for quite long, but with lot of discontinuities. But this time, while working I thought of learning about .profile and writing one for myself.. Better late than never suits me, isn't it... Ok, enuf talking...Lets get on, like always with BASICS!!!

What is .profile ?
This file is the first file which gets executed when you login to a shell. It has some initializations, aliases, exports etc to make you go easy while working on command line. It is present in the user's home directory and its a hidden file as it begins with a dot(.). So use ls -a.

What do we usually put in .profile ?
Lets say you have a directory /home/mydir/mydir1/ with a lot of files. Now every time you want to do some file manipulation, you obviously wouldn't want to enter the whole path again and again.So we can create an alias and put it in .profile.
alias myd= cd /home/mydir/mydir1/

Functions:
You can also create functions with arguments to simplify ur task. Lets write a function for displaying your file (using cat)
show ()
{
cat /home/mydir/mydir1/$1
}
Now if you write "show abc" from any folder, the file content will be viewed.

set -o vi
This is another command that I always put in my .profile. It enables us to use history.
You can do this by pressing Esc key and then using "k" and "j" to move backward and forward in history. Its useful, believe me...

set -o noclobber
This is again a useful command. It helps us from accidently over writing an existing file.
Lets say you have a file abc.
Now if you write ls -l > abc
You will get an error saying that abc cannot be overwritten.

export HISTSIZE=100
This enables 100 commands to be kept in history.

These are some of things that you can do.You can write if statements and write any kind of shell scripting that you wanna perform at login...

Saturday, March 6, 2010

Copying files in binary mode

Long time guys.... Yes, m really writing after a long time..i guess after 2 months...
There hasn't been learning on my side on the technical front, but a lot on the domain side..
Copying files :
Many of us would be using tools like winscp, which uses SSH for transferring files between Linux and Windows..even I use it... SSH basically does encryption and decryption before sending and receiving data respectively.It does so for secure transmission.

Now when you copy files between Windows and Linux, you should preferably use bin or binary mode.
Now comes a big "WHY" ???
I prefer it because in "text" mode, WINSCP does some conversion between end of line characters (Windows uses CR+LF(\r\n) as EOL whereas Linux uses LF(\n))
CR and LF represents bytes used to denote EOL.
Enter key generates LF.
CR is denoted by \r.

So to avoid this conversion, its better to use bin mode when you copy dumps or some other type of files which dont deal with just characters.

Ill now come up wid details on these in my next post... Thanks...

Saturday, January 9, 2010

SMTP and MIME

Hi,
Im writing after a long time.Y? Its just because i didn't learn anything new or found anything interesting to write. So , today while browsing I can across an interesting topic..

People studying engineering would know what is SMTP. But, few people know about MIME.As a student, I only knew MIME had something related to email header. So here we go.

SMTP or Simple Mail Transfer Protocol is used to send emails.These emails contain plain text and nothing else( It is because when SMTP was formulated in 1982, it had support only for US-ASCII characters).Now, when we send an email, we know that MIME adds a header to email, divides email into parts and does other technical stuff. But what if your email contains a binary file attachment? How will SMTP send the email since it contains binary information????

Now this is resolved by MIME. MIME( Multipurpose Internet Mail Extension) uses an algorithm "Base64" which does this encoding. This algorithm encodes the information, whether image,media or whatever into a form which can be understood by decoding at the recipient's end.