![](/img/trans.png)
[英]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.