Cinder API using jclouds

2019-08-21 07:02发布

问题:

I have been reading about the support jclouds added to the Cinder Openstack API, and i was looking at this example usage on Rackspace Cloud.

https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudblockstorage/CreateVolumeAndAttach.java

does anybody know is this is supported for HP Cloud as well? if not, how can i use HP Cloud Block Storage with jclouds?

thanks a lot!

回答1:

You should be able to use the Cinder API with HP but I tried it out and it wasn't working. Here's what I did.

Iterable<Module> modules = ImmutableSet.<Module> of(new SLF4JLoggingModule());

RestContext<CinderApi, CinderAsyncApi> cinder = ContextBuilder.newBuilder("openstack-cinder")
  .endpoint("https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/")
  .apiVersion("1.1")
  .credentials(myHpTenantName + ":" + myHpUsername, myHpPassword)
  .modules(modules)
  .build(CinderApiMetadata.CONTEXT_TOKEN);
VolumeApi volumeApi = cinder.getApi().getVolumeApiForZone("az-1.region-a.geo-1");
System.out.println(volumeApi.list());

The call to list() returns an empty list but with logging turned on I can see that it's actually a 404 causing the empty list to be returned. The URL that's created to list the volumes is

https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/myHpTenantId/volumes

Which I think should be valid according to the HP service catalog but it's returning a 404.

I'll ping someone I know from HP and see if we can get to the bottom of this.



回答2:

HP Cloud's support for the OpenStack Block Storage (Cinder) API is coming soon. Please refer to our API documentation for reference to the currently supported Block Storage APIs: https://docs.hpcloud.com/api/block-storage/