Monday, July 21, 2014

Compile Libvirt for xen (libxl toolstack)

Hi all,

Libvirt is the tools which is used for interacting with hypervisor like XEN, KVM. By using the libvirt, we can pass our configuration in the form of XML format.

And this will be very useful when you are interacting the hypervisor with Web services.

Libvirt is the redhat product and it is giving support for XEN hypervisor also.

Then, How i can compile libvirt for xen.?

 ./configure with --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib64 --with-xen=yes --with-libvirt=yes

make 

make install 

and its finished.

If you want to check the libvirt in your system; it have the tool as "virsh".

In your command prompt; type virsh -c xen:///

then it will enter into the special terminal. then type: version

virsh # version
Compiled against library: libvirt 1.2.0
Using library: libvirt 1.2.0
Using API: Xen 1.2.0
Running hypervisor: Xen 4.4.0

You will get like this. It means it successfully installed and also able to communicate with your hypervisor also. In my case, hte hypervisor is XEN. And, finally you did it.

Enjoy and Be CooL... :)


regards,
cooldharma06.. :)


Sunday, July 20, 2014

Convert ogv to mkv using ffmpeg

Hi all,

Most of the peoples know about these things just for reminding i am writing this blog. If you are taking video of your Desktop using recordmydesktop ( Screencasting tool) then the output will comes in out.ogv format. If you want to change that one to mkv means kindly follow the following command.

In case if you haven't installed ffmpeg means kindly install from your repository.

ffmpeg -i sample.ogv -vcodec libx264 -vpre medium -crf 24 -threads 0 -acodec copy sample.mkv

Enjoy.. and Be cool..:)

Wednesday, April 30, 2014

Run VLC as a root user.

Hi all,
   
i think you people got bored by trying to "run VLC as a root user". Yeah me too.

After some days i found the solution to run VLC as a root user from some forums.

Solution:

in the following file -> vi /usr/bin/vlc

just change the "geteuid" to "getppid".

Sure it will works. Because its worked for me...:)


Enjoy the world with exploring Things..:)


Regards,
cooldharma06..:)


Friday, March 14, 2014

Passing Parameters in From C to Pyhton.

Hi all,

Once again i come with some C and Python. Dont think its very new things. It just an upgraded post of the last post "Embedding Python in C".

In the last post you learned "how to Embed the Python code in C". Now i am going to explain how we can send some parameters from Python to C.

Example:

mypython.py

import sys

ca_one = str(sys.argv[1])
ca_two = str(sys.argv[2])
print "My command line args are " + ca_one + " and " + ca_two

call.c
#include <Python.h>
#include <stdio.h>

int main(int argc,char *argv[])
{
    FILE* file;

    Py_SetProgramName(argv[0]);
    Py_Initialize();
    PySys_SetArgv(argc, argv);
    file = fopen("mypython.py","r");
    PyRun_SimpleFile(file, "mypython.py");
    Py_Finalize();

    return 0;
}
  
Now compile your c program and pass some paramters *for mypython.py ( above sample code) you have to send two parameters.

Input:
./call cool dharma


Output:
My command line args are cool and dharma


Yeah..! You did this, like this you can pass your parameters from your C program to python code. :)


Regards,
cooldharma06..:)



Monday, March 10, 2014

Embedding python in C.

Hi all,

Python is developing now a days. So as a developer we have to change based on the technology.

Now i am going to explain about how we can compile the python programs with(in) c.

Example python program:

addition.py

def add(a,b):
    c=a+b
    print "You did it and Added result is ..",c


And my C program:

samlepython.c

#include <Python.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
  Py_SetProgramName(argv[0]);  /* optional but recommended */
  Py_Initialize();
  PyRun_SimpleString("import addition\naddition.add(4, 2)\n");  /* here we are calling the python                                                                                                                                                 things */
  Py_Finalize();
  return 0;
}


Now you have to compile your c program:

gcc samlepython.c -o sample_python

it will show the following error:
"mainpgm.c:1:20: fatal error: Python.h: No such file or directory"

For this you have add your python installed location to your gcc.

gcc -I/usr/include/python2.7 -lpython2.7 samplepython.c -o sample_python

now it compiled and if you are running the ./sample_python means; you will get the foollowing error.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named addition


It means the program is not able to find the imported "addition" location. for this you have to add the path folder to PYTHONPATH variable.

Suppose i stored my program under the /home/cool/docs/

export PYTHONPATH="/home/cool/docs/"

then again compile and once again run your program,
Output:
You did it and Added result is .. 6


Yeah you compiled your python program with c. Congratz...:)



Regards,
cooldharma06..:)



Thursday, March 6, 2014

Xml file in XEN-4.3.1

hi all,

As it of opensource, i just want to share some things which i knows:

Most of the beginners are not aware of xml file creation in XEN.

Please refer the following things if you have the above questions in your mind..

XML file is created by some programs which is under the xen source tree as Node.

it will create the XML file and it will passed into libvirt for VM creation.


Flow of Xml file creation is:

instance.xml is produced by the node. And it will get under the xsl translation with libvirt.xsl file to produce the instance-libvirt.xml.

That is passed for the VM creation in XEN...:)


That's all i think..:)

If you have any suggestions kindly google or ask the XEN community or ask here..:)

Regards,
cooldharma06.. :)

Raw image creation by dd command

hi all,

If you want to create the raw file image using the dd command just simply run the following command:

   dd if=/dev/zero of=windows.img bs=1 count=0 seek=10G

It will create the raw image in current directory. Before running this command check the memory is available in the folder or not.

If you want to change the size means just change the seek value to 1M or 1024K.

then do

   ls -l --block-size=G

You did it, Congratz...!!! Enjoy with your image.

regards,
cooldharma06..:)

Saturday, January 25, 2014

Warning : gnome-keyring pkcs11 : No such file.??

Hi,

In Gnome sometime in your terminal you are able to see the some errors like:

WARNING: gnome-keyring:: couldn't connect to: /xxxx/yyyy/.cache/keyring-DWS6bg/pkcs11: No such file or directory

I also stucked with this one. I also googled so many times but I have not understood why this raised.??

Then from one blog I found the solution and also somewhat I understood why this one showed??

Reason:
In Gnome if you changed the Desktop environment means it will raises the above warning.
For this you have to tell “I am using the XXXX-desktop environment” and dont irritate me by throwing this waring..:). This can be done by adding the Desktop environment type in gnome.keyring-pkcs11.desktop file.

Solution:

       vi /etc/xdg/autostart/gnome-keyring-pkcs11.desktop
       Go to this line and append your desktop environment type:
       Exec=/usr/bin/gnome-keyring-daemon --start --components=pkcs11
       OnlyShowIn=GNOME;Unity;XFCE;
       In my case I am using the XFCE desktop environment incase if you are using other things means just add the name like LXDE or XFCE.

Then restart it.

Then just check it..:)

Congratz and you done it.

Regards,
cooldharma06.





Installation of EUCALYPTUS-3.4.1 in DEBIAN Flavor.

Hi all,

i am writing this blog for the installation of EUCALYPTUS-3.4.1 from source.

WHY i am writing this.?
You can ask me this question.??? :) because i wasted my three golden days with this installation alone. you may get(find) lot of installation guides.

INSTALLTION GUIDE which for single machine

Before this you have installed XEN and LIBVIRT. And they have to work.

Build Your OWN cloud:

ARCHITECTURE (Design flow):

Eucalyptus --> Libvirt --> Hypervisor

Eucalyptus main dependency packages:
  • axis2-1.4
  • axis2c-1.6.0
  • rampart-1.3.0
Basic Prerequisites
apt-get install cdbs debhelper default-jdk libfuse-dev libfuse2 libcurl4-openssl-dev libssl-dev ant-optional zlib1g-dev pkg-config swig python python-setuptools rsync wget open-iscsi libxslt1-dev gengetopt ant groovy postgresql-server-dev-9.1 python-boto sudo (groovy – not recommenede)

These are all other dependency which you have to install in your system:
libc6, adduser, openssh-server, openssh-client, postgresql-client-9.1, python2.7, python, python-psutil, python-pygresql, lvm2, libgetargs-long-perl, postgresql-9.1, vblade, dmsetup, velocity, libpostgresql-jdbc-java, libjboss-common-java, libhibernate-commons-annotations-java, python-pygresql, drbd8-utils, open-iscsi, libcrypt-openssl-random-perl, libcrypt-openssl-rsa-perl, libcrypt-x509-perl, lvm2, vblade, libcurl3, libssl1.0.0, apache2, libapache2-mod-axis2c (not in repository, installed from wheezy or squeeze ), bridge-utils, vlan, dhcp3-server, iptables, vtun, libpam-modules, libapr1-dev libaprutil1-dev, apache2-threaded-dev , ivy, openntpd , tgt, parted

Eucalytpus is recommending to have java-7-openjdk
In debian i am recommending to install the tgt from the source because i faced many problems and write your own service using the chkconfig.

Also i recommend to check the dependencies from the eucalyptus INSTAll guide.

You can install LIBVIRT-xxx either from the repository or from the source.

Download axis2-1.4 from


Unzip it in /opt, so /opt/axis2-1.4 exists

Download the axis2c-1.6.0 from the source which is available in the following link:


export EUCALYPTUS="/opt/eucalyptus"
export AXIS2C_HOME=/usr/lib/axis2/
export APACHE_INCLUDES=/usr/include/apache2
export APR_INCLUDES=/usr/include/apr-1.0
export AXIS2C_HOME=$EUCALYPTUS/packages/axis2c-1.6.0
CFLAGS="-w" ./configure --prefix=${AXIS2C_HOME} --with- apache2=$APACHE_INCLUDES --with-apr=$APR_INCLUDES --enable-multithread=no
make

If you face any error as axiom* means
Add this one in neethi/test/Makefile.am and Makefile also
../../axiom/src/parser/guththila/libaxis2_parser.la \

make install

Download the rampart-1.3.0

Untar the rampart source.(tar -zxvf rampart-XXXXX)
cd rampartc-src-1.3.0
./configure --prefix=${AXIS2C_HOME} --enable-static=no --with-axis2=${AXIS2C_HOME}/include/axis2-1.6.0
make
make install

Eucalyptus Installation:

Untar the Eucalyptus Source in the required locatuion.
cd /opt/eucalyptus-version-src

export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64/"
export JAVA="$JAVA_HOME/jre/bin/java"

./configure --with-axis2c=/usr/lib/axis2 --with-axis2c-services=/usr/lib/axis2/services --prefix=$EUCALYPTUS --with-apache2-module-dir=/usr/lib/apache2/modules --with-axis2=/opt/axis2-1.4 –with-db-home=/usr/lib/postgresql/9.1 –with-libvirt=/opt/libvirt-1.2.0(if installed from the source)

If libvirt you have installed from the repository just leave it.( Don't add the tag)
make clean
make
make install
ln -s /lib/udev/scsi_id /usr/bin/scsi_id
cp -r /etc/eucalyptus/faults/en_US/* /opt/eucalyptus_new_3.4.1/eucalyptus/etc/eucalyptus/faults/en_US/ 

chmod +s /usr/lib/eucalyptus/euca_rootwrap -v

adduser eucalyptus

sudo adduser `id -un` libvirtd
sudo adduser eucalyptus libvirtd
 mkdir -p /var/lock/subsys
 mkdir -p /var/lock/eucalyptus
 chown -R eucalyptus:eucalyptus /var/lock/subsys /var/run/eucalyptus

Open the eucalyptus configuration file:
vi /opt/eucalyptus/etc/eucalyptus/eucalyptus.conf
Type :6 press Enter
Get into INSERT mode
 Edit the value of Eucalyptus = "/opt/eucalyptus/"
save the file.

 service postgresql restart

Then :
 cd /opt/eucalyptus/

 usr/sbin/euca_conf -d $EUCALYPTUS  --hypervisor xen  --instances  /usr/local/eucalyptus --user eucalyptus --setup

 ln  -sf  $EUCALYPTUS/etc/init.d/eucalyptus-cloud  /etc/init.d/eucalyptus-cloud
 ln  -sf  $EUCALYPTUS/etc/init.d/eucalyptus-cc  /etc/init.d/eucalyptus-cc
 ln  -sf  $EUCALYPTUS/etc/init.d/eucalyptus-nc  /etc/init.d/eucalyptus-nc

 usr/sbin/euca_conf --initialize
 service openntpd restart
 chmod 0777 /tmp

 service eucalyptus-cloud start
 service eucalyptus-cc start
 service eucalyptus-nc start

Congratz successfully you installed the EUCALYPTUS cloud in your system.

Now open your browser then hit the following link:
 https://localhost:8443/

You will see the portal:
       Intially the password is "admin"
After successfull login you will ask for mail and new password. If you wish you can change it. :)
Now you have to get the credentials.For that:
 usr/sbin/euca_conf --get-credentials admin.zip.
 unzip admin.zip
 source eucarc
Now we are able to access your portal using the euca2ools.
  euca-describe-services -- to see all the services.
 euca-describe-components -- to see the all components.

Now register your machine as Walrus, Cluster, SC, NC.
In my case i am having the single machine. so I am going to using same ip for all. 
Registering Walrus
/usr/sbin/euca_conf --register-walrus --partition walrus --host ip --component walrusname
Register Cluster
usr/sbin/euca_conf --register-cluster --partition clustername --host ip --component ccname 
Registering Sc                                                        
usr/sbin/euca_conf --register-sc --partition clustername --host ip --component scname
walrusname,ccname, scname - to avoid confusion if you have multiple machine means
eucalyptus recommends to put the name with ip. for example: sc-ip
Registering Nodes
usr/sbin/euca_conf --register-nodes "nodes-ip-address"

During the registration it will show some error BlockStorage. (BROKEN).
For this you have run the follwoign command:

euca-modify-property -p [clustername].storage.blockstoragemanager=overlay

Then you can check with this one:
euca-describe-properties | grep blockstorage

Now you can check all the components with the following commands:
  • euca-describe-services -- to see all the services.
  • euca-describe-components -- to see the all components.
  • euca-describe-clouds
  • euca-describe-clusters
  • euca-describe-storage-controllers
  • euca-describe-nodes
Now you have all the components in your machine. You can create the VM by uploading image to eucalyptus.

Upload some image to/from eucalyptus and launch the virtual machine.

Create the Virtual machine and enjoy with your CLOUD..

These steps are clubbed from following installation guides:

i referred following links for my installation.

and also i added my suggestions.

If you have any queries means put it in comments.

Regards,
cooldharma06.. :)