使用jclouds列出SAIO中的容器Openstack swift服务器不成功

时间:2014-03-13 20:08:14

标签: blobstore openstack openstack-swift jclouds

我根据Openstack Swift的网站设置了一个SAIO服务器:http://docs.openstack.org/developer/swift/development_saio.html#loopback-section

我使用的是默认测试帐户。我可以使用这些命令使用其他机器来卷曲它:

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

这为我提供了令牌和存储网址,然后我将其用于GET / POST / etc。 ' X.X.X.X'是机器的IP。

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

我希望能够使用jclouds使用此服务器。但是,我无法执行列出容器等基本功能。我使用此处提供的示例:http://jclouds.apache.org/guides/openstack/

我的init方法如下:

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();
   }

这是控制台输出的一部分:

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

当我尝试列出容器时,这是proxy.log中的日志:

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

我已经尝试了几天寻找解决方案,但我没有找到任何东西。非常感谢你!

1 个答案:

答案 0 :(得分:1)

您可以尝试将auth和版本后缀附加到端点,例如:

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