【问题标题】:Use JClouds to talk to non AWS cloud with S3 API使用 JClouds 通过 S3 API 与非 AWS 云通信
【发布时间】:2012-02-22 06:02:02
【问题描述】:

我正在尝试使用 JClouds 与仅公开 S3 API(它不支持 swift / rackspace API)的 OpenStack / swift 存储云安装对话。

我试过了:

Properties overrides = new Properties();
overrides.setProperty(Constants.PROPERTY_ENDPOINT, CLOUD_SERVIE_ENDPOINT);

// get a context with nova that offers the portable ComputeService api
BlobStoreContext context = new BlobStoreContextFactory().createContext("aws-s3", ident,
    password, ImmutableSet.<Module> of(), overrides);

服务器回复身份验证错误 403。使用标准 AWS sdk 或 python boto 可以正常工作,因此这不是服务器问题,但很可能是 jclouds 使用不正确。

【问题讨论】:

  • 请关闭,原来我用的密码不对。使用正确的密码。

标签: amazon-s3 jclouds


【解决方案1】:

jclouds 实际上支持 swift,所以你不需要做任何特别的事情。我推荐使用jclouds 1.3.1,并配置依赖org.jclouds.api/swift

然后,您只需要输入您的端点、身份、凭证

Properties overrides = new Properties();
overrides.setProperty("swift.endpoint", "http://1.1.1.1:8080/auth");

BlobStoreContext context = new BlobStoreContextFactory().createContext("swift", "XXXXXX:YYYYY", "password", ImmutableSet.<Module> of(), overrides);

【讨论】:

  • JClouds 可以,但我尝试使用的快速安装没有。
【解决方案2】:

以下内容应该适合您。例如,它可以在 vBlob 上工作。

import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS;
...

     Properties overrides = new Properties();
     overrides.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");

     BlobStore blobstore = ContextBuilder.newBuilder(new S3ApiMetadata()) // or "s3"
                                         .endpoint("http://host:port")
                                         .credentials(accessKey, secretKey)
                                         .overrides(overrides)
                                         .buildView(BlobStoreContext.class).getBlobStore();

如果您的克隆不接受根 url 的 s3 请求,您需要相应地设置另一个参数。

import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH;
...

     overrides.setProperty(PROPERTY_S3_SERVICE_PATH, "/services/Walrus");
...
                                         .endpoint("http://host:port/services/Walrus")

【讨论】:

  • 感谢您的回答。原来是用户错误(见我的评论)。很遗憾我无法删除问题,而且版主似乎太忙了。
猜你喜欢
  • 2014-06-24
  • 2016-03-16
  • 2016-08-14
  • 1970-01-01
  • 1970-01-01
  • 2015-12-14
  • 1970-01-01
  • 1970-01-01
  • 2018-04-04
相关资源
最近更新 更多