简体   繁体   English

通过openstacknetsdk找不到我的Rackspace云服务器

[英]Can't find my Rackspace cloud server via openstacknetsdk

I'm attempting to write a simple proof-of-concept for manipulating cloud servers in my Rackspace Cloud account via the C# openstacknetsdk library, v1.3.0.0. 我正在尝试编写一个简单的概念验证,以通过C# openstacknetsdk库v1.3.0.0在Rackspace Cloud帐户中操作云服务器。

The problem I'm having is although I appear to be able to authenticate successfully using my Rackspace username and API key, the API is behaving as though I don't have any servers. 我遇到的问题是,尽管我似乎能够使用我的Rackspace用户名和API密钥成功进行身份验证,但该API的运行方式似乎没有任何服务器。 My code: 我的代码:

using net.openstack.Providers.Rackspace;
using net.openstack.Core.Providers;
using net.openstack.Core.Exceptions.Response;
using net.openstack.Providers.Rackspace.Objects;
using net.openstack.Core.Domain;

...

const string USERNAME = "[my rackspace username]";
const string API_KEY = "[my rackspace API key]";

static void Main(string[] args)
{
    CloudIdentity cloudIdentity = new CloudIdentity() { APIKey = API_KEY, Username = USERNAME };
    CloudServersProvider provider = new CloudServersProvider(cloudIdentity);

    IEnumerable<SimpleServer> servers = provider.ListServers();
    foreach (SimpleServer server in servers)
    {
        Console.Out.WriteLine(server.Id);
    }
}

When I step through this code in the debugger, I can see that servers ends up having size 0, and nothing ends up getting written out. 当我在调试器中逐步执行此代码时,我可以看到servers最终的大小为0,而最终没有任何内容被写出。

This is unexpected, because I do have one server created, which I can see on the Rackspace cloud control panel website. 这是意外的,因为我确实创建了一个服务器,可以在Rackspace云控制面板网站上看到它。 The server is in Active status. 服务器处于活动状态。

If I try to get information on my specific server, using the server ID from the Cloud Servers > Server Details page on the Rackspace cloud control panel site: 如果尝试获取有关特定服务器的信息,请使用Rackspace云控制面板站点上“云服务器>服务器详细信息”页面上的服务器ID:

Server server = provider.GetDetails("[my cloud server ID]");
Console.Out.WriteLine(server.Image.Name);

I get a net.openstack.Core.Exceptions.Response.ItemNotFoundException. 我得到了net.openstack.Core.Exceptions.Response.ItemNotFoundException。

The authentication seems to be working because if I intentionally change my API_KEY value to something incorrect (like "test" ), I get a UserNotAuthorizedException instead. 身份验证似乎有效,因为如果我有意将API_KEY值更改为不正确的值(例如"test" ),则会得到UserNotAuthorizedException。

What am I missing here? 我在这里想念什么? Why is the openstacknetsdk acting like I don't have any servers? 为什么openstacknetsdk的行为就像我没有任何服务器?

Is the server you have created in your default region? 您创建的服务器是否在默认区域中?

To be safe, try specifying the region in the .ListServers() method call. 为了安全起见,请尝试在.ListServers()方法调用中指定区域。

Also; 也; you can download sample data via NuGet; 您可以通过NuGet下载样本数据; search for "openstack sample". 搜索“ openstack示例”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM