Search code examples
openstack-novajclouds

Getting Current Nova Instance ID


I'm using jclouds SDK 2.1.0 to handle OpenStack resources, assume i have a running nova server and code is running on it, is there any way to get the ID or details for that instance that is already running? meaning getting the instance details (not for all instances, only the instance that I'm using)

its something similar to a function exists in this AWS class

Thanks

EDIT

i found that there is a file called meta_data.json that contains the server id (UUID) when creating the server with configuration drive enabled, but how to implement that through the code? can i get that file using jclouds SKD?


Solution

  • according to metadata APIs its only a matter of a HTTP GET request sent to the URL to: http://169.254.169.254/openstack/2012-08-10/meta_data.json but the trick is to send this request from within the Nova Server itself, so i opened a the nova server's console and i ran the command: curl http://169.254.169.254/openstack/2012-08-10/meta_data.json

    this command will return a JSON object contains the server id (UUID), keep in mind that first thing is that, when creating a Nova instance you should check the configuration drive option enter image description here

    second, there is multiple meta_data.json files in the server, the file that exists in the folder 2012-08-10 contains the server id (UUID)