1

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.

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. 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.

This is unexpected, because I do have one server created, which I can see on the Rackspace cloud control panel website. 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:

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

I get a 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.

What am I missing here? Why is the openstacknetsdk acting like I don't have any servers?

Jon Schneider
  • 25,758
  • 23
  • 142
  • 170

1 Answers1

2

Is the server you have created in your default region?

To be safe, try specifying the region in the .ListServers() method call.

Also; you can download sample data via NuGet; search for "openstack sample".

Don Schenck
  • 161
  • 1
  • 6
  • Yes, that was it! My server is in Rackspace's "DFW" region, so changing my ListServers call to the following worked: IEnumerable servers = provider.ListServers(region: "DFW"); – Jon Schneider Apr 10 '14 at 17:29
  • I actually recommend specifying the region in the [constructor of `CloudServersProvider`](http://openstacknetsdk.org/docs/html/M_net_openstack_Providers_Rackspace_CloudServersProvider__ctor_6.htm). Newer services in the SDK, such as `CloudQueuesProvider` and `CloudDnsProvider`, *only* allow you to specify the region in this manner, simplifying the overall use of the API. When [issue #243](https://github.com/openstacknetsdk/openstack.net/issues/243) is closed, this will be true for Cloud Servers as well. – Sam Harwell Apr 10 '14 at 17:48