Pages

Wednesday, January 13, 2016

find OpenStack Instance from KVM

Locate OpenStack Instance from KVM (or) find Open Stack Instance from KVM 

  • While creation of VM in OpenStack with KVM Hypervisor, if there are many VMs running then its difficult to pointout the VM created by OpenStack at KVM Level.
  • Because While creation of VM in Open Stack, User assigns a name to the Instance. Say WebServer. But the same VM while provisioned by KVM, has a different name such as instance-00000099. 
  • How to find the VM created by Open Stack at KVM Level ?
  • So there exists two level of naming of VM. One at KVM Level and other from Open Stack Level. How to associate and have a resolution of the VM at KVM Level. This post is for this purpose .

1. Find the List of VMs and their UUID running under KVM Level

virsh list | grep running -> Show VMs running in VIRSH.

#!/bin/bash
#This Script will print the Domain Name & UUID of the
#Running VM's

#Get Domain ID

for i in `virsh list |grep running |awk {'print $1'}`; 

do 

 a=`virsh domname $i`   # Domain Name

 b=`virsh domuuid $i`;  # Domain UUID

echo "$a,$b";

done


2. Find the List of VMs and their UUID under Open Stack Level


For this, you are required to get the details from NOVA Database (MySQL)

Connect to Nova Database through MySQL or query browser and run the following query to show the list of running vms

select display_name,uuid from instances where deleted_at is NULL and terminated_at is NULL;

Now we have the dom uuid from which we shall associate and resolve OpenStack VM to KVM VM.

No comments:

Post a Comment