Showing posts with label openstack. Show all posts
Showing posts with label openstack. Show all posts

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