使用 JClouds 通过 S3 API 与非 AWS 云对话

发布于 2025-01-08 02:19:01 字数 546 浏览 0 评论 0原文

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

我尝试过:

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的错误使用。

I'm trying to use JClouds to talk to an OpenStack / swift storage cloud installation that only exposes a S3 API (it does not support the swift / rackspace API).

I tried:

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

The server replies with an authentication error 403. Using the standard AWS sdk or python boto works fine, so it's not a server problem, but most likely incorrect use of jclouds.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

童话 2025-01-15 02:19:01

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 in fact supports swift, so you don't need to do anything special. I'd recommend using jclouds 1.3.1, and configure the dependency org.jclouds.api/swift

Then, you just need to enter you endpoint, identity, credential

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);
哆兒滾 2025-01-15 02:19:01

以下内容应该适合您。例如,已知它可以在 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")

The following should work for you. It is known to work on vBlob, for example.

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

If your clone doesn't accept s3 requests at the root url, you'll need to set another parameter accordingly.

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")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文