Tuesday, 20 March 2012

Unable to run Instance, Ends with status Error in OpenStack

Hello all
I came across this problem when I started testing the OpenStack Diablo release.Let me explain what happens usually when you begin working with OpenStack .
I use to re-compile the OpenStack Installation for development and testing purpose. (i.e re-running /.stack.sh when you use devstack). Every thing will go smoothly and the installation will show "Successfully Installation " , And when you open the Dashboard (http://cloud server),  there will be nothing wrong but when you launch an instance it will end with "error" status or sometime "build" status will never change.

Reason:

This happens only when you launched instances during last installation and closed/restarted/shutdown your cloud server without terminating the  running instances.
When you launch an instance (in case of KVM) , a new instance will be created by  defining a XML file which has the instance configuration ( hw config like cpu,ram,Disk,etc) and launched.
If you /restarted/shutdownthe cloud server or reinstall the OpenStack without terminating the instances, then the created running instance's status will change to "shut off" and it remains in the hypervisor (i.e xml file will not be destroyed). So when you tries to launch an new instances from the re installed OpenStack ,  every thing will go well by instances cannot be launched , this is because when a new installation sends a request to create an instances it will send request with name "instance-00000001" (i.e always begins in 1 and increments it for successive attempts). This request will fail because there exist an instance with same name in the hypervisor (KVM). If you check the log of "n-cpu" you will find
-----------------------------------------------------------------------------------------------
Error: operation failed: domain 'instance-00000001' already exists with uuid xxxxxxxx-xxxx-yyyy-cccc-xxxxxxxxxxx
-------------------------------------------------------------------------------------------

Solutions
There are two solutions for this

1. Simplest one is attempting to launch instance more number of times so that it  exceed the total number of instances launched during last installation. This is not complete solution. I figured out this solution during my initial experience with openstack and then I started to explore more to find the solution which comes next.

2. Run this commend

----------------------
$virsh list --all
---------------------


you will get something like below
------------------------------------------------------------------
Id Name State
----------------------------------
  - instance-00000001 shut off
  - instance-00000002 shut off 
  - instance-00000003 shut off 

-------------------------------------------------------------------------------

These are the definitions exist in hypervisors for the previously launched instances so you have to un-define it by using this command
-------------------------------------------------------------

$virsh undefine  instance-00000004

Domain instance-00000001 has been undefined
-------------------------------------------------------------

This has to be done for each instances in the list.

Now you are good to go.. The problem is solved. 





Note: since instance is not running, you cannot destroy these instance using
----------------------------------------------
$virsh destroy  instance-00000004

----------------------------------------------

You can find more details about"virsh"  command in following links

Ref:

Wednesday, 23 November 2011

Using ec2ools(eucalyptus) with keystone in openstack

Eucalyptus ec2ools is a comment line API tools used for managing instances in Amazon Elastic Cloud.
OpenStack uses this as a comment line API tools in the same way as AEC2 to manage openstack compute (NOVA).

Once you install openstack nova with out installing keystone and dashboard  you can use ec2ools to run,reboot,terminate the  instances,uploading and remove images,allocating and un allocate  floatting public ip address,associate ip with instances,etc..(for more details refer http://wiki.magellancloud.org/index.php/List_of_Eucalyptus_Commands )


If you want to use dashboard for managing openstack cloud , you  have to use keystone for identification and authentication , there is no other option. Even it is simple to make ec2ools work with keystone  people (including me) initially have some difficulty .This post will explain how I fixed this problem.

In Cloud Controller (server) side

1.Make sure you have created the user (either by using dashboard or keystone-manage http://docs.openstack.org/diablo/openstack-identity/admin/content/creating-tenants-users-roles-tokens-and-endpoints.html )

2.Adding Credentials in keystone for using ec2ools by using
keystone-manage credentials add admin EC2 'user name' 'secretpassword'

done now go to client machine .

In Client Side(ubuntu)

1. Install ec2ools  use " sudo apt-get intal euca2ools".
2.Setting environmental variables by create a small rc file (examplerc)with


# Set the ec2 url so euca2ools works
export EC2_URL=${EC2_URL:-http://$HOST_IP:8773/services/Cloud}

# Access key is set in the initial keystone data to be the same as username
export EC2_ACCESS_KEY=${USERNAME:-username}

# Secret key is set in the initial keystone data to the admin password
export EC2_SECRET_KEY=${ADMIN_PASSWORD:-secretepassword}

3. check  echo $EC2_ACCESS_KEY and echo $EC2_SECRET_KEY give the proper values

If yes go to next step otherwise set environmental  variable directly by giving these commands

export EC2_ACCESS_KEY=xyz
export EC2_SECRET_KEY=PASSWORD

then verify again.

4.Now you are ready to work with ec2ools tools. you can check it by giving below comment


euca-describe-availability-zones verbose

you will get output like
-
AVAILABILITYZONE nova available
AVAILABILITYZONE |- cloud
AVAILABILITYZONE | |- nova-scheduler enabled :-) 2011-11-24 07:58:17
AVAILABILITYZONE | |- nova-volume enabled :-) 2011-11-24 07:58:17
AVAILABILITYZONE | |- nova-network enabled :-) 2011-11-24 07:58:17
AVAILABILITYZONE | |- nova-compute enabled :-) 2011-11-24 07:58:12

Thank you



Wednesday, 16 November 2011

How to add vmware and VirtualBox image in openstack

VMware

Vmware will create vm with disk image *.vmdk , first locate the file (you can do this by selecting the setting of corresponding vm and select "Hard Disk(scsi) or usualy it will be in "Virtual Machine" folder created during vmware installation)
Then copy the file in to your openstack cloud system (you can use scp for this).

glance add -A <admin_password> name="<image name>" is_public=true container_format=bare disk_format=vmdk < myvm.vmdk

NOTE : change
<admin_password> = your glance admin password
<image name>         =  name of image , this name will be shown  in your dashboard after you upload
 myvm.vmdk            = your virtual machine name .vmdk(the file which you coppied)



Another method you may think of is using ova and ovf which you can create by using vmware export option . But you can not add .ova file in your openstack cloud since it is not support by glance. And you can not add *.ovf which is created by vmware because current vmwareapi driver of nova supports only thick flat vmdk disk so you can only add *.vmdk file

(I conformed by asking it in openstack group at launchpad.net  https://answers.launchpad.net/glance/+question/178944 )

VirtualBox

  In case of VirtualBox it create vm with disk image *.vdi as default. Locate it and copy to your openstack cloud system

glance add -A <admin_password> name="<image name>" is_public=true container_format=bare disk_formate=vdi < myvm.vdi

NOTE : change
<admin_password> - your glance admin password
<image name>         -  name of image , this name will be shown  your dashboard after you apploaded
myvm.vdi                 -  your virtual machine name .vmdk(the file which you coppied)



Thank you all..