Search code examples
openstack-swiftjcloudscephradosgw

List container metadata from non-Keystone Swift


This code makes GET request to RadosGW (I don't use Keystone)

String srcEndpoint = "http://myhost/auth/v1.0";
SwiftApi api = ContextBuilder.newBuilder(PROVIDER).endpoint(srcEndpoint)
                .credentials(srcIdentity, srcCredential).buildApi(SwiftApi.class);

If PROVIDER is openstack-swift my code throws

org.jclouds.http.HttpResponseException: command: POST http://myhost/auth/v1.0/tokens HTTP/1.1 failed with response: HTTP/1.1 405 Method Not Allowed; content: [{"Code":"MethodNotAllowed"}]

If PROVIDER is swift my code throws

Exception in thread "main" com.google.inject.ConfigurationException: Guice configuration errors:

1) No implementation for org.jclouds.openstack.swift.v1.SwiftApi was bound.
  while locating org.jclouds.openstack.swift.v1.SwiftApi

My dependencies are

<dependency>
    <groupId>org.apache.jclouds.api</groupId>
    <artifactId>swift</artifactId>
    <version>1.9.2</version>
</dependency>
<dependency>
    <groupId>org.apache.jclouds.api</groupId>
    <artifactId>openstack-swift</artifactId>
    <version>1.9.2</version>
</dependency>

How can I list all containers with all their metadata, without downloading the list of blobs it contains?

What's the difference between swift and openstack-swift?


Solution

  • The primary difference is that swift supports v1 auth and openstack-swift supports v2 auth. Unfortunately, swift is also deprecated and no longer maintained.

    The reason you are getting that error is because SwiftApi is specific to the openstack-swift API implementation. Despite the heroic efforts that jclouds makes to abstract away all the implementation details, it's not perfect. The swift API implementation returns SwiftClient, which extends CommonSwiftClient (where all the interesting methods are defined).

    Also, as you may have guessed, SwiftClient is in a different package. So be sure to include package org.jclouds.openstack.swift; (no ".v1")

    You can list all containers with their metadata by calling listContainers(ListContainerOptions... options) on your SwiftClient instance. This will return Set<ContainerMetadata>.