Friday, February 26, 2016

Nova Docker Installation

After going through a lot of links (some good, some confusing), I finally figured out the installation of nova-docker. So whats the whole idea ?
When we create an OpenStack compute node with kvm as the underlying hypervisor, the VMs on that node get created using kvm hypervisor. Simple..
In the same way, there's a nova-docker driver. When we use nova-docker driver on a compute node, we can create docker containers using the "nova boot" command. That's what I did on my OpenStack kilo setup.

I created an All-in-one OpenStack kilo setup and used qemu as the hypervisor. Then, I thought of adding another compute node to the setup - but this one with nova-docker driver. Without any delay, I'll tell you how I did it (Though you would find a lot of links on it, but I prefer writing it my way :) ).

Step 1: Install docker on your VM - http://docs.docker.io/en/latest/installation/
Step 2: usermod -aG docker nova
Step 3: pip install docker-py
Step 4: git clone https://github.com/stackforge/nova-docker
[Steps 1-4 copied shamelessly from here]
Step 5: git checkout stable/kilo
Step 6: cd nova-docker
    Step 6.1: Edit the file driver.py - vi novadocker/virt/docker/driver.py as explained below
                   In def spawn(...), args{} needs to be edited as given below:

                    args = {
                   'hostname': instance['name'],
                   'mem_limit': self._get_memory_limit_bytes(instance),
                   'cpu_shares': self._get_cpu_shares(instance),
                   'network_disabled': True,
                   'tty': True,   # This line needs to be added.
        }
[Now again, step 6.1 is copied from here.]
Step 7: Follow the steps to configure and install a compute node from Openstack Kilo guide. - http://docs.openstack.org/kilo/install-guide/install/apt/content/neutron-compute-node.html
Step 8:python setup.py install - Install the nova-docker driver.
Step 9: Now we need to make some modifications to the nova configuration files that we edited in step 7. In "/etc/nova/nova.conf" under DEFAULT section, set 
compute_driver = novadocker.virt.docker.DockerDriver 
In /etc/nova/nova-compute.conf, we will set the compute driver as novadocker [that we installed in step 8].
cat /etc/nova/nova-compute.conf 
[DEFAULT]
#compute_driver=libvirt.LibvirtDriver
compute_driver=novadocker.virt.docker.DockerDriver
[libvirt]
virt_type=qemu
Step 10: Create the directory /etc/nova/rootwrap.d, if it does not already exist, and inside that directory create a file "docker.filters" with the following content:

# nova-rootwrap command filters for setting up network in the docker driver
# This file should be owned by (and only-writeable by) the root user

[Filters]
# nova/virt/docker/driver.py: 'ln', '-sf', '/var/run/netns/.*'
ln: CommandFilter, /bin/ln, root

Step 11: In "/etc/glance/glance-api.conf", set 
container_formats=ami,ari,aki,bare,ovf,ova,docker

Step 12: Follow "Uploading Images to Glance" onwards from this. If you get any error, follow this link. I got some of the same errors as described in this wonderful link. Many thanks to the author.

Once you are done with this, I would suggest you to create a new availability zone for this compute host. This way, while creating the docker instance, you can choose the docker availability zone. Here's what I did,

Step 1: nova aggregate-create docker-aggregate docker-availability-zone 
Step 2: nova aggregate-add-host

Now you can create an instance using the docker image. Check your instance using docker ps command on the compute node that we just created.

Thats all folks, I have consolidated everything in this blog post along with the helpful links. 

Putting all the links that I used for reference:

Sunday, June 14, 2015

Orchestration with Heat

This time, I tried to get my hands dirty by writing a heat script - my first yaml file.
Oops!!!
I think I need to start off with a small intro.
OK, so what is openstack heat ?
Heat is one of the several services in Openstack. It is used for orchestration. This simply means that creating networks, instances, routers, security groups etc using a script(or rather a template in YAML format - called HOT - Heat Orchestration Template) instead of browsing the horizon or using nova/neutron etc commands to setup a tenant. It also means that if the same needs to be replicated, you just need to provide some parameters and its done. And if you want to delete the same, just do it by hitting the enter key with heat stack's delete command.
Ok, I used another jargon here... Heat stack. Heat stack can be simply defined as the collection of resources that are orchestrated with heat. So if you have spawned 5 networks, 100 VMs, 10 routers, a few security group rules through a heat yaml, then all of these form a heat stack.


In this post, I would describe a HOW-TO for writing a heat template. I have created a simple YAML file to spawn 2 VMs, a security group and a network to which these VMs are attached. Once a VM is spawned, it executes a script defined in the user_data section. This script prints "Scripts loaded on startup" in syslog. The purpose of this script is to illustrate that users can create VMs and spawn a configuration script or a start-up script once the VM boots up.

Sections:
A heat template has the below sections:
1. Heat template version
2. Parameters
3. Resources
4. Outputs - (Not describing in this post.)

Heat template version is simply a header that describes the template version that you

The parameters section is used to define the parameters. These parameters are like input variables with some default values.
For example, if you want to create two stacks for two different tenants using the below yaml file, then you can use the parameters to specify the values like vm name, subnet address etc for the tenant.

The resources section describes the resources of your stack - In this section, you define the VMs, networks, security groups, ports etc.

heat_template_version: 2013-05-23
description: Create a network and attach a VM. Run a script in the VM

parameters:
  p_my_vm_flavor:
    type: string
    label: Flavor
    description:
    default:ubuntu

  p_my_private_network:
    type: string
    description:
    default: tenantA_net

  p_my_private_subnet:
    type: string
    description:
    default: tenantA_subnet

  p_my_network_cidr:
    type: string
    description:
    default: 11.0.0.0/24

  p_my_network_gateway:
    type: string
    description:
    default: 11.0.0.1

resources:
  r_my_network:
    type: OS::Neutron::Net
    properties:
      name: { get_param: p_my_private_network }
  r_my_network_subnet:
    type: OS::Neutron::Subnet
    properties:
      name: {get_param: p_my_private_subnet }
      network_id: {get_resource: r_my_network}
      gateway_ip: {get_param: p_my_network_gateway}
      cidr: { get_param: p_my_network_cidr }
  r_my_port:
    type: OS::Neutron::Port
    properties:
      network_id: {get_resource: r_my_network}
  r_security_group:
    type: OS::Neutron::SecurityGroup
    properties:
      description:
      name:
      rules: [ { "direction": ingress, "protocol": ICMP }, { "direction": ingress, "protocol": TCP,"port_range_min": 1, "port_range_max": 65535 }, { "direction": ingress, "protocol": UDP,  "port_range_min": 1, "port_range_max": 65535 } ]

  r_my_vm:
    type: OS::Nova::Server
    properties:
      image: firewall
      flavor: m1.medium
      networks:
        - port: {get_resource: r_my_port}
      user_data: |
        #!/bin/sh -ex
        logger "Script loaded on startup"
  r_my_vm_port:
    type: OS::Neutron::Port
    properties:
      network_id: {get_resource: r_my_network}
      security_groups: [{get_resource: r_security_group}]


Parameters section: I have used 5 configurable parameters and specified  a default value (default: tag) for each of this. So if a user doesn't provides a parameter, its default value would be used.
  p_my_vm_flavor - To indicate the flavor of VM.
  p_my_private_network - Specify name of tenant's network.
  p_my_private_subnet - Specify the private subnet of the tenant.
  p_my_network_cidr - CIDR of tenant's network.
  p_my_network_gateway - Gateway of the tenant's network.

Resources Section: I have used 6 type of resources
r_my_network: It is defined as OS::Neutron::Net. This is an OpenStack resource type (see this).
Similarly  I have defined r_my_network_subnet, r_my_port, r_security_group, r_my_vm and r_my_vm_port. All these are self explanatory and define the subnet, port, security group, VM and VM's port.

The user_data in r_my_vm properties defines a script that would be loaded on start when the VM is instantiated.

You can run this YAML file(test.aml) with "heat stack-create" command and provide the below file as parameters.

parameters:
  p_my_private_network: TenantCNetwork
  p_my_private_subnet: TenantCSubnet
  p_my_network_cidr: 80.0.0.1/24
  p_my_network_gateway: 80.0.0.1


Friday, May 8, 2015

NORMAL mode in OVS - MAC learning

OpenVSwitch or OVS can run in two modes
1. NORMAL mode
2. Flow mode

In NORMAL mode, OVS works like any other L2 layer switch operating on MAC-Port mapping.
To use an OVS in NORMAL mode, simple create an OVS bridge and add the below flow entry
ovs-vsctl add-br br0
ovs-vsctl add-port eth0
ovs-ofctl add-flow br0 action=NORMAL
For flows hitting this entry, the MAC table maintained by OVS would be referred for forwarding decision.

In Flow mode, the regular OpenFlow pipeline is hit and OVS works on the basis of flows installed.

In my experiment, I would explain how the NORMAL mode works standalone and also how it works in conjunction with flow mode.
I have only used mininet and OVS for this experiment on Ubuntu 14.04 LTS.

Step 1: Create a simple topology with one switch and three hosts.

$ sudo mn --topo=single,3 --controller=none --mac
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1) (h3, s1)
*** Configuring hosts
h1 h2 h3
*** Starting controller
*** Starting 1 switches
s1
*** Starting CLI:

Step 2: Execute ovs-appctl command. This command displays the MAC table created by OVS. Since we have not done any ping, the table doesn't has the MAC entries for h1,h2 and h3.
mininet> sh ovs-appctl fdb/show s1
 port  VLAN  MAC                Age
LOCAL     0  b2:c9:fc:3c:1a:41    8
mininet>

Step 3: We do not have any flows installed on OVS. If you try to ping between hosts, nothing would happen.
mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
mininet>

Step 4: Now, lets add a NORMAL action flow entry on OVS and see what happens.
mininet> sh ovs-ofctl add-flow s1 action=normal
mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=12.023s, table=0, n_packets=0, n_bytes=0, idle_age=12, actions=NORMAL
mininet>

The MAC table is still blank as in step 2.
mininet> sh ovs-appctl fdb/show s1
 port  VLAN  MAC                Age
LOCAL     0  b2:c9:fc:3c:1a:41   56
mininet>

Step 5: Lets ping
mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.587 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.085 ms
^C
--- 10.0.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.085/0.336/0.587/0.251 ms

The ping is successful because of NORMAL flow entry. The MAC addresses of the hosts h1 and h2 are learnt. h3 is still not learnt as there has been no ping to/from h3.

mininet> sh ovs-appctl fdb/show s1
 port  VLAN  MAC                Age
LOCAL     0  b2:c9:fc:3c:1a:41   63
    2     0  00:00:00:00:00:02    1
    1     0  00:00:00:00:00:01    1
mininet>

The above steps show the OVS operation in NORMAL mode.
Step 6 onwards, I would explain how NORMAL and FLOW mode work in conjunction,

Step 6: Now, lets add a flow for MAC address and port of h3 with a higher priority.
mininet> sh ovs-ofctl add-flow s1 priority=60000,dl_dst=00:00:00:00:00:03,actions=output:3
mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=4.242s, table=0, n_packets=0, n_bytes=0, idle_age=4, priority=60000,dl_dst=00:00:00:00:00:03 actions=output:3
 cookie=0x0, duration=71.223s, table=0, n_packets=8, n_bytes=560, idle_age=43, actions=NORMAL
mininet>

Step 7: Lets ping and notice n_packets/n_bytes of flow entries.

mininet> h1 ping h3
PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data.
64 bytes from 10.0.0.3: icmp_seq=1 ttl=64 time=0.558 ms
64 bytes from 10.0.0.3: icmp_seq=2 ttl=64 time=0.090 ms
^C
--- 10.0.0.3 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.090/0.324/0.558/0.234 ms
mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=13.124s, table=0, n_packets=2, n_bytes=196, idle_age=2, priority=60000,dl_dst=00:00:00:00:00:03 actions=output:3  --> Flow1
 cookie=0x0, duration=80.105s, table=0, n_packets=12, n_bytes=840, idle_age=2, actions=NORMAL ---> Flow2
mininet>

Notice that the packets/bytes increase for both the entries. This is because when h1 ping is sent to h3, Flow 1 is hit and for the ping reply, Flow 2 gets hit.

Journey of a packet when a VM accesses internet in Openstack

I am putting down my understanding in the post to explain the journey of a packet from a VM to an external network. As you read on, I would explain this figure in detail at interface and bridge level with the help of some slides.

Step 1: VM to br-int - Packet filtering by Security Group


Each VM that is created, is attached to a TAP interface (vnetX). This tap interface is connected to a Linux bridge qbrXXX and then a veth pair qbrXXXX - qvoXXXX connects the Linux bridge with br-int.
The security groups are implemented on TAP devices using iptables rules. If an instance has multiple ports, the same security groups are applied on all ports of the instances.

Step 2: br-int to br-tun (Inside the Compute node)


br-int and br-tun are connected via patch ports. The external packets (VLAN tagged) reach br-tun via the patch ports. On br-tun, the VLAN tag is stripped and a tunnel id is added to send the packet to the tunnel between the compute node and the network node.

Step 3: Packet travels to Network Node through GRE Tunnel
At this point, the packet reaches the physical interface - eth1 of the network node via a GRE tunnel.


Step 4: Packet reaches br-int from br-tun

eth1 of the network node belongs to br-tun. The packet is thus received by br-tun. br-tun removes the GRE header and sends the packet to br-int via patch ports(qr veth pair,i.e the receiving interface on br-int is qrXXXX). This is done via GRE-VLAN mapping maintained as flow rules on br-tun.

Step 5: Firewall rules on network node

The packet exits br-int via qrXXXX interface which exists in the qROUTER namespace that belongs to the tenant. Both qrXXXX and qgXXXX interfaces exist in the qROUTER namespace. You can check the interface and route and iptables details using the below commands.
#ip netns exec ifconfig -a
#ip netns exec route -n
#ip netns exec iptables -L
#ip netns exec iptables -L -t nat
qrXXXX is the interface that serves as the internal gateway for a tenant.
qgXXXX is the interface towards the external network on br-ex.
Rules of the tenant's firewall then get executed which determines whether the packet going to external network should be dropped or allowed.
NATing is also done at this point, so the packet leaving the network node has the source IP as that of the qROUTER's external gateway.
Once allowed, the packet reaches qgXXXX interfaces on br-ex and is set to external network or the internet.


The response takes the same path in reverse direction.

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.



Saturday, September 19, 2009

Drupal - Pathauto Module

Hmm.. so u ppl are back... thank god u are :) , now I have some visits...
Without wasting any time, lets start..This time, vll learn pathauto module..So as always, lets begin by asking "WHY"....

Why are we learning this module?
You might have noticed, when you create a page or a story, it is allocated a URL automatically which by default is node/1 or node/2 and so on.. When your website is live, u obvioulsy wouldn't want to have such un-meaningful URLs. It looks more meaningful, if the URLs contain the type of information that the page displays.
So it time to add some meaning to our URLs..

Here we go now ...

1. So as described in my previous posts, u need to download this DHTML module( just goto drupal.org, click on modules do a search with DHTML menu), unzip it and save it in C:\wamp\www\drupal\sites\all\modules.
2. Make sure that you download the correct version.
3. Once you have downloaded it, start the WAMP server and go to http://localhost/drupal .
4. Now login into your account.
5. Goto Administer- Site Building - Module.
6. Click on URL aliases under Path heading.
7. Click on Add Alias.
8. On Existing Alias path, give the automatically generated path( node/1 ..)
9. On Path Alias, give a meaningful name to be associated with a particular page.
10. Click on Create new Alias and BINGO... there u go..

Thats it for now, keep giving some meaningful names to your pages or polls or wtever... I'll be back with some other important modules...

Happy naming :)....


Wednesday, September 16, 2009

Drupal - DHTML Menu Module

This is the simplest module that ive come across during my course fo learning Drupal.

Why are we learning this module?
Thats the first question I believe you shud ask yourself...In case uve not asked yourselves :) , lemme answer it since I raised it at the first place.. :)
Oh k.. If youve explored or played with drupal, you would have noticed that when you click on the parent menu, a new page opens.This increases the number of pages t be opened and makes the user wait. By using DHTML Menu, the sub menu opens up below the parent item and without opening or refreshing the current page.

Here we go, as always :)

1. So as described in my previous posts, u need to download this DHTML module( just goto drupal.org, click on modules do a search with DHTML menu), unzip it and save it in C:\wamp\www\drupal\sites\all\modules.
2. Make sure that you download the correct version.
3. Once you have downloaded it, start the WAMP server and go to http://localhost/drupal .
4. Now login into your account.
5. Goto Administer- Site Building - Module.
6. Check DHTML Menu and click on save configuration
7. Now again goto Administer- Site Configuration(Click on By Module on the top) - DHTML Menu.
8. Now you can check animate sliding effect and decide which menu you want to have DHTML effect.
9. Now keep playing with the options that you see and try to get the effect which suits your needs.

Ill come up with more modules in my next post...


Tuesday, September 15, 2009

Drupal Themes - Configuration

Oh k.. So now we know hot to install and enable themes and modules..
Lets start with the configuration of themes... Before I move ahead, let me tell you that drupal is more like a game.. By this I dont mean that its a child's play, its a kinda thing that the more you explore and play with it, the more you learn....
Let me explain some of the things realted to theme settings.
So lets hit it...
1.Goto Administer-Site Building-Themes.
2.Click on the configure link on the theme that is checked.

Ill discuss now some common things that everybody wants on their page.

Page Elements:These are the elements like logo, site names, slogon... basically self explanatory.
If you dont want to use the default logo, you can upload any other image from your computer.

Breadcrumbs: You would have often seen in websites the hierarchy of the page ie you move from home to careers to contact us etc.
So you can enable breadcrumbs to display your traversal like Home-Careers-Contact Us.
Woah.. m already feeling sleepy... explaining this stuff is boring.. it doesn't deserves and explanation.. I don't know why I wrote this post :) .. You can certainly skip it...

In my next post,Ill explain more about modules.. Yes the commonly used modules which you would be asked in interviews i guess... So pay attention.. No sleeping next time.... Good nite... :)

Monday, September 14, 2009

Installing Themes in Drupal

When we install drupal, there are a lot of themes that come with it. But there are a lot of themes freely available on drupal website. Download any of them in case you sont like the themes that come bundled with drupal.
So, lets get started...

1.Goto drupal.org and download the theme of your choice which comes as a tar.gz file.
2. Unzip the file.
3. Create a folder called themes in C:\wamp\www\drupal\sites\all\
4. Thats it.
5. Now on your drupal menu, goto Administer- Site Buliding.
6. Scroll down the page to see whether your theme name appears or not.
7. Check the box to use the theme.

In my next pos, Ill discuss about the configuration of themes according to your style...

Installing Modules in Drupal

In my previous posts, Ive explained about the installation and configuration of Drupal and WAMP.
Now, lets hit it...
When we install drupal, there are a lot of modules that come with it. But to use the complete power of drupal, we must use the freely available modules on drupal.org.
Here we go...

1.Goto drupal.org and download the module of your choice which comes as a tar.gz file.
2.Unzip the file.
3. Create a folder called modules in C:\wamp\www\drupal\sites\all\
4. Thats it.
5. Now on your drupal menu, goto Administer- Site Buliding.
6. Scroll down the page to see whether your module name appears or not.
7. Check the box to enable the module.

In my next post Ill write about the installation of themes.

Monday, September 7, 2009

Starting WAMP

In this post, Im gonna discuss about the WAMP issue which I faced when I got my hands on it. In the previous posts, Ive described the WAMP and drupal installation, configuration etc.
But after doing all this, when i restarted my computer and double clicked on WAMP, I wasn't able to open the http://localhost/drupal. I checked out services.msc, and I was amazed that inspite of double clicking on WAMP, there was no entry for wampmysqld and wampapache. WTF ...

So I re-installed everything and faced the same problem again on restarting my computer.
I decided to google it and found that WAMP has come issues with Skype , but I had no skype on my computer.
So, I disabled all the firewalls and anti virus on my system, started computer in safe mode with networking, checked ports and what not... Huff... I got tired of searching so I thot of trying it my way...And I did it finally......
So here it goes:

Starting WAMP

1. Double click on wamp. You'll see and icon for WAMP where the time appears on Win XP.
2.Click on the WAMP icon.Goto APACHE- Services- Install Service. A command window opens up, hit enter and it'll be gone.
3.Click on the WAMP icon.Goto MySQL-Service-Install Service.
4. Now goto APACHE- Services-Start/Resume Service.
5. Now goto MySQL- Services-Start/Resume Service.

BINGO !!! Its done now.. Now everythings gonna work. You can check services.msc and ull see wampmysqld and wampapache...

The steps look damn easy but they blow the mind of someone jus starting wid it...

WAMP and Drupal - Installation

Now lets start with the WAMP installation.

Installing WAMP is a child's play. Just do a couple of nexts in the installation wizard and ure on.

Setting up drupal

1. After you download drupal form drupal.org, unzip the file and rename the folder as drupal. After this, paste this folder in C:\wamp\www. ( Assuming your WAMP resides in C:\)
2.Now go to C:\wamp\www\drupal\sites\default and rename the file default.settings.php as settings.php.
3. Now start your wamp by double clicking. The WAMP icon appears at the place where you see the time on Windows XP.
4. Click on WAMP and click on phpMyAdmin.
5. Now on http://localhost/phpmyadmin/ page in your browser, give a database name and click on create.
6. Now type http://localhost/ on the address bar of your browser and just so a couple of next. After performing all the steps, you have drupal installed on your computer.

Ill write more about using drupal in my next post.

Introduction to Drupal

Ok guyz... Its been long since Ive written ( or shud I say its been long since Ive learnt somthing) on my blog. So, as they say, Im back with a bang and this time...Its DRUPAL...I recently got a chance to learn it (thanks to my friends) so thot i shud share it...

What is Drupal ?
Well, drupal is an open source CMS ( Content Management System). This means that using Drupal, we can build and manage websites in no time. Just download Drupal and use the freely available modules available on drupal.org. No need to learn HTML,DHTML and to scratch your head on css.

How to start?
Ok, to start with, we need to download WAMP (Windows, Apache, MySQL and PHP).All these four things come bundled in WAMP. So visit http://www.brothersoft.com/wampserver-70590.html and download WAMP 2.0 h.

Next, you need to download Drupal ver 6.x from http://www.drupal.org .

In my next post, Ill teach u how to install these.

Saturday, July 4, 2009

SELECT COUNT(*) v/s SELECT COUNT(1) - FASTER??

I was writing a PL/SQL code one day using select count(*) from Table_name when somebody told me that select count(1) is better and faster. Although, he couldn't tell me the reason but he gave me a fact. So i jumped upon to search the reason.

Select count(*) uses a TABLE SCAN ie all the rows are looked upon one by one based on your WHERE CLAUSE whereas select count(1) uses an INDEX SCAN which has better performance as the scan is based on indexes.

TABLE scan is faster if the table is small.