1

How can I find information about a Rackspace Cloud server from within the server itself?

Amazon AWS has it, and its documented here: http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html?r=7479

Jon Schneider
  • 25,758
  • 23
  • 142
  • 170
Kunal P.Bharati
  • 949
  • 4
  • 11
  • 19

2 Answers2

0

From your application code, you can find the local server's own external IP address using a technique like the one described here (for C#): https://stackoverflow.com/a/1069113/12484

Then, once you have the IP address, you can use the Rackspace Cloud API to query the list of all active servers, and get the information for the server with the matching IP address. Sample code (C#, using the OpenStack.net SDK):

CloudIdentity cloudIdentity = new CloudIdentity { APIKey = API_KEY, Username = USERNAME };
CloudServersProvider provider = new CloudServersProvider(cloudIdentity);

IEnumerable<Server> servers = provider.ListServersWithDetails(region: REGION);
foreach (Server server in servers)
{
    if (server.AccessIPv4 == ipAddress)
    {
        Console.Out.WriteLine("Server ID:" + server.Id);
        Console.Out.WriteLine("  Flavor: " + server.Flavor.Name);
        Console.Out.WriteLine("  Image: " + server.Image.Name);
        Console.Out.WriteLine("  PowerState: " + server.PowerState.Name);
        Console.Out.WriteLine("  Status: " + server.Status.Name);
        Console.Out.WriteLine("  UserId: " + server.UserId); 
        break;       
    }
}

USERNAME, API_KEY, and REGION in the above code should be replaced by the actual values for your own Rackspace Cloud account.

Community
  • 1
  • 1
Jon Schneider
  • 25,758
  • 23
  • 142
  • 170
0

You could use the Rackspace Cloud Server API: http://www.rackspace.com/cloud/cloud_hosting_products/servers/api/

There's a python implementation here: http://packages.python.org/python-cloudservers/

or the command line tool is really useful too: http://jsquaredconsulting.com/blog/2010/11/rscurl-a-rackspace-cloud-server-command-line-tool/

That's the most practical link /\

matiu
  • 7,469
  • 4
  • 44
  • 48