stream
stream

Reputation: 11

How to run Openstack-Swift java api?

I try to run Openstack-Swift java sdk sample. I have swift and keystone project to use swift only. I found this project : https://github.com/woorea/openstack-java-sdk But, I don't know how to run this project in Window Eclipse. Should I build all project(nova, etc..) in maven? Do you know how to run this project or website that post run-way in regular sequence?

Upvotes: 1

Views: 3886

Answers (2)

arielp
arielp

Reputation: 1

looks like you can build SWIFT independently (part of woorea peoject) as it states in the readme file here:

(com.woorea swift-client 3.0.0-SNAPSHOT)

https://github.com/woorea/openstack-java-sdk

the Maven artifact ID should be: openstack-java-sdk

Here is a nice toturial that can be of hand:

https://github.com/woorea/openstack-java-sdk/wiki/Swift-Tutorial

it has the example for the java api for using SWIFT,

for example, this code snippet (more details in the link):

Properties properties = System.getProperties();
properties.put("verbose", "true");
properties.put("auth.credentials", "passwordCredentials");
properties.put("auth.username", "demo");
properties.put("auth.password", "secret0");
properties.put("auth.tenantName", "demo");
properties.put("identity.endpoint.publicURL","http://192.168.1.43:5000/v2.0");

OpenStackClient openstack = OpenStackClient.authenticate(properties);

AccountResource account = openstack.getStorageEndpoint();

account.container("hellocontainer").put();

account.container("hellocontainer").object("dir1").put();

account.container("hellocontainer").object("test1")
    .put(new File("pom.xml"), new SwiftStorageObjectProperties() {{
      setContentType("application/xml");
      getCustomProperties().putAll(new HashMap<String, String>() {{
        put("customkey.1", "customvalue.1");
              }});
    }});

List<SwiftStorageObject> objects = account.container("hellocontainer").get();
  • just keep in mind that when using openstack's API you will most likely need to authenticate (get tokens etc..) so that you will need the Keystone lib as well www.programcreek.com/java-api-examples/index.php?api=com.woorea.openstack.keystone.Keystone

hope this helps.

Upvotes: 0

koolhead17
koolhead17

Reputation: 1964

@stream

I have not tried Woorea but i know a lot many developers are using Jclouds, the link http://developer.rackspace.com/#home-sdks has well documented guide with example how to use the Java SDK.

Hope it helps.

Upvotes: 3

Related Questions