Search code examples
blobstoreopenstackopenstack-swiftjclouds

Using jclouds to list containers in SAIO Openstack swift server not successful


I have set up a SAIO server according to Openstack Swift's site: http://docs.openstack.org/developer/swift/development_saio.html#loopback-section

I'm using the default test account. I can curl to it using other machines using these commands:

curl -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' http://x.x.x.x:8080/auth/v1.0

This gives me the token and storage url which I then use to GET/POST/etc. 'x.x.x.x' is the ip of the machine.

curl -X GET -i -H 'X-Auth-Token: {token}' http://x.x.x.x:8080/v1/AUTH_test/container-bdf7f288-31f9-4cc1-9ab4-f0705dda763f

I want to be able to work with this server using jclouds. However, I'm unable to do basic functions such as listing containers. I'm using the example provided here: http://jclouds.apache.org/guides/openstack/

I have my init method as this:

private void init() {
      Iterable<Module> modules = ImmutableSet.<Module> of(
            new SLF4JLoggingModule());

      String api = "swift";
      String identity = "test:tester"; // tenantName:userName
      String password = "testing"; // demo account uses ADMIN_PASSWORD too


      BlobStoreContext context = ContextBuilder.newBuilder(api)
            .endpoint("http://x.x.x.x:8080/")
            .credentials(identity, password)
            .modules(modules)
            .buildView(BlobStoreContext.class);
      storage = context.getBlobStore();
      swift = context.unwrap();
   }

This is part of the console output:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
List Containers
org.jclouds.http.HttpResponseException: command: GET http://x.x.x.x:8080/v1.0 HTTP/1.1 failed with response: HTTP/1.1 412 Precondition Failed; content: [Bad URL]
    at org.jclouds.openstack.swift.handlers.ParseSwiftErrorFromHttpResponse.handleError(ParseSwiftErrorFromHttpResponse.java:55)
    at org.jclouds.http.handlers.DelegatingErrorHandler.handleError(DelegatingErrorHandler.java:67)
    at org.jclouds.http.internal.BaseHttpCommandExecutorService.shouldContinue(BaseHttpCommandExecutorService.java:180) ...

And this is the log in the proxy.log when I try to list containers:

Mar 13 11:40:42 minint-klnhv9g proxy-server: {requesting ip} {requesting ip} 13/Mar/2014/18/40/42 GET /v1.0 HTTP/1.0 412 - jclouds/1.7.1%20java/1.7.0_05 - - 7 - tx670f536e9c634dc0a69d3-005321fbaa - 0.0002 - - 1394736042.856692076 1394736042.856895924

I've tried searching for a solution for a few days now, but I have not found anything. Thank you very much!


Solution

  • Can you try appending the auth and version suffix to the endpoint, e.g.:

    BlobStoreContext context = ContextBuilder.newBuilder(api)
          .endpoint("http://x.x.x.x:8080/auth/v1.0")