简体   繁体   中英

Connect to OpenStack Swift ONLY install using Rackspace OpenStack.net

I've been able to install and get OpenStack Swift up and running. My installation is strictly Swift, does not include Keystone or other OpenStack components.

When I use the curl command I am able to create users and do my Swift tests making sure all is working just fine. Where I am running into problems is when I use the OpenStack.NET API maintained by Rackspace on github .

Using the following commands I was able to create a swift user.

$ curl -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' http://192.168.0.3:8080/auth/v1.0
$ curl -v -H 'X-Auth-Token: <token-from-x-auth-token-above>' <url-from-x-storage-url-above>
$ swift -A http://192.168.0.3:8080/auth/v1.0 -U test:tester -K testing stat

All works as expected, and the user / account is created. On my Windows Development Machine I then downloaded the OpenStack.NET API from Rackspace GitHub and created an application running the following code;

    var authUri = new Uri("http://192.168.0.3:8080/auth/v1.0");
    var userName = "test";
    var password = "tester";
    var tenantId = "testing";


    var credential = new OpenStackCredential(authUri, userName, password, tenantId);

    var client = OpenStackClientFactory.CreateClient(credential);
    client.Connect();

    var storageServiceClient = client.CreateServiceClient<IStorageServiceClient>();
    var storageAccount = storageServiceClient.GetStorageAccount();

When this runs I am getting the following error.

"A client that supports the requested service for the given instance of OpenStack could not be found."

What am I doing wrong here?

I faced the exact same problem and after doing some debugging I got to the conclusion that the Openstack .NET SDK checks for the version in the url and "v1.0" isn't valid.

I'm by no means an expert on this matter so try to double check my findings before relying on them.

Edit: After further reading I think that the v1.0 url is for TempAuth authentication and looks like the SDK tries a Keystone authentication instead. I can't find a way to use the SDK with TempAuth authentication.

I am really appreciative of people's responses to my questions!

I wasn't able to connect using the Rackspace API, and suspect you may be right. It's a little sad just because while there is a lot of documentation surrounding connecting within a fully implemented OpenStack ecosystem (Swift, Glance, Keystone, Newton etc), there really isn't enough documentation for those trying to make the daunting first steps into OpenStack, with Swift being most people's likely first step.

For those that started were I was, Swift is the object storage engine. It's great for storing lots of uploaded files that you may have traditionally stored on the web server itself, FTP or on a network file share. Basically you throw a "object" (eg image, word document, pdf, excel document) into a "container" (eg a folder), and Swift stores it on the server and gives you a GUID to reference the file. Getting to that file is via HTTP. For example;

http://YOUR.swift.SERVER.ipaddress/THEcontainerNAME/THEguidRETURNED

and viola! Your file is served to you!

There are a lot of libraries out there that claim to give you access to OpenStack Swift and all of the other OpenStack goodies (Newton, Glance etc), but they generally assume you are running OpenStack's full multi-tenant ecosystem, with its home grown tenant management software (aka keystone) installed and configured which, if you're like me, you don't.

If you want a quick access via C#, use the HttpWebRequest and HttpResponse classes while referencing the OpenStack Swift API ( click here ). You're going to have to get right down to the gritty details of adding and reading HTTP Headers. Once you get the hang of it, it is all easy stuff.

There are plenty of examples on the web of people using the HttpWebRequest class, you just need to use your "Google"-Foo and search for it. Don't waste your time looking up how to connect to OpenStack Swift using C# and HttpWebRequest class. You're trying to be inundated with bad examples, and forms with unanswered questions. Start by searching for an easy example of using the HttpWebRequest class, searching for something like "download file using httpwebrequest class c#", then once you see how the class is used, then adopting it to call Swift, while referencing the API linked above should be quite easy. Don't do that I did, spend hours looking for the code you can just copy and paste into your application. Unfortunately you're going to have to read... which sucks - I know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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