[英]How to become an expert at Cloud technologies like AWS,Openstack and etc.?
[英]How to find out Rackspace Cloud server info (id, IP, etc.) from within itself?
如何從服務器本身內部找到有關Rackspace Cloud服務器的信息?
Amazon AWS擁有它,並在此處提供了記錄: http : //docs.amazonwebservices.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html?r=7479
從您的應用程序代碼中,您可以使用類似於此處描述的技術(針對C#)找到本地服務器自己的外部IP地址: https : //stackoverflow.com/a/1069113/12484
然后,一旦有了IP地址,就可以使用Rackspace Cloud API查詢所有活動服務器的列表,並獲取具有匹配IP地址的服務器的信息。 示例代碼(使用OpenStack.net SDK的 C#):
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
和REGION
應該替換為您自己的Rackspace Cloud帳戶的實際值。
您可以使用Rackspace Cloud Server API: http : //www.rackspace.com/cloud/cloud_hosting_products/servers/api/
這里有一個python實現: http : //packages.python.org/python-cloudservers/
或命令行工具也確實非常有用: http : //jsquaredconsulting.com/blog/2010/11/rscurl-a-rackspace-cloud-server-command-line-tool/
那是最實用的鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.