[Openstack] Developing with Scala/Java on OpenStack Swift
Luis Gervaso
luis at woorea.es
Thu Jan 3 16:43:17 UTC 2013
Gui,
In your own swift project you _only_ will need (take a look pom.xml in
openstack-examples project) 2 dependencies
<dependency>
<groupId>org.openstack</groupId>
<artifactId>keystone-client</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.openstack</groupId>
<artifactId>swift-client</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
On Thu, Jan 3, 2013 at 4:56 PM, Gui Maluf <guimalufb at gmail.com> wrote:
> Luis, thanks for your quick reply! Seems I'm missing something very
> important, because I can't use all this classes/types(Access, Authenticate,
> Tenants, KeystoneUtils, ObjectForUpload,etc).
> I've installed the os-java-sdk in this way:
>
> $ git clone
> $ mvn compile package
> $ find . -name '*.jar' -exec cp {} sbt_lib_dir/. \;
> $ sbt console
> > import org.openstack._
>
> What am I doing wrong? What am I missing?
> Is there a proper way to install the os-java-sdk?
>
> Thank you very much!
> With lots of regards.
>
>
>
>
> On Thu, Jan 3, 2013 at 4:00 AM, Luis Gervaso <luis at woorea.es> wrote:
>
>> Hi Gui!
>>
>> I just upgraded the code to work properly with latest Jersey release
>>
>> Below the swift example code (just tested and working with HPCloud)
>>
>> Hope it helps you :)
>>
>> private static final File TEST_FILE = new File("pom.xml");
>>
>> private static final String KEYSTONE_AUTH_URL = "
>> https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0";
>>
>> private static final String KEYSTONE_USERNAME = "";
>>
>> private static final String KEYSTONE_PASSWORD = "";
>>
>>
>> /**
>>
>> * @param args
>>
>> */
>>
>> public static void main(String[] args) throws Exception {
>>
>> KeystoneClient keystone = new KeystoneClient(KEYSTONE_AUTH_URL);
>>
>> //access with unscoped token
>>
>> Access access = keystone.execute(Authenticate.withPasswordCredentials(
>> KEYSTONE_USERNAME, KEYSTONE_PASSWORD));
>>
>> //use the token in the following requests
>>
>> keystone.setToken(access.getToken().getId());
>>
>> Tenants tenants = keystone.execute(new ListTenants());
>>
>> //try to exchange token using the first tenant
>>
>> if(tenants.getList().size() > 0) {
>>
>> access =
>> keystone.execute(Authenticate.withToken(access.getToken().getId()).withTenantId(tenants.getList().get(0).getId()));
>>
>> SwiftClient swiftClient = newSwiftClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(),
>> "object-store", null, "public"), access.getToken().getId());
>>
>> //swiftClient.execute(new DeleteContainer("navidad2"));
>>
>> swiftClient.execute(new CreateContainer("navidad2"));
>>
>> System.out.println(swiftClient.execute(new ListContainers()));
>>
>> ObjectForUpload upload = new ObjectForUpload();
>>
>> upload.setContainer("navidad2");
>>
>> upload.setName("example2");
>>
>> upload.setInputStream(new FileInputStream(TEST_FILE));
>>
>> swiftClient.execute(new UploadObject(upload));
>>
>> System.out.println(swiftClient.execute(new ListObjects("navidad2", new HashMap<String,
>> String>() {{
>>
>> put("path", "");
>>
>> }})).get(0).getContentType());
>>
>> }
>>
>>
>> }
>>
>> On Wed, Jan 2, 2013 at 8:01 PM, Gui Maluf <guimalufb at gmail.com> wrote:
>>
>>> Hey guys,
>>> I'm trying to extend a software project<https://github.com/VirtualCloudDrive/CloudDrive>to talk with Swift.
>>>
>>> This project was developed on Scala, and my issue is: how should I
>>> access Swift resource? Should I use openstack-java-sdk<https://github.com/woorea/openstack-java-sdk/>,
>>> jclouds <http://www.jclouds.org/documentation/quickstart/openstack/> or
>>> develop my own library to access the REST API?
>>> I've tried to use openstack-java-sdk but I wasn't able to import the
>>> libraries exposed at examples.
>>>
>>> I'm really confuse about that and I'll appreciate any help, hint, advice!
>>>
>>> Thanks in advance.!
>>>
>>> --
>>> *guilherme* \n
>>> \t *maluf*
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~openstack
>>> Post to : openstack at lists.launchpad.net
>>> Unsubscribe : https://launchpad.net/~openstack
>>> More help : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
>> --
>> -------------------------------------------
>> Luis Alberto Gervaso Martin
>> Woorea Solutions, S.L
>> CEO & CTO
>> mobile: (+34) 627983344
>> luis@ <luis.gervaso at gmail.com>woorea.es
>>
>
>
>
> --
> *guilherme* \n
> \t *maluf*
>
--
-------------------------------------------
Luis Alberto Gervaso Martin
Woorea Solutions, S.L
CEO & CTO
mobile: (+34) 627983344
luis@ <luis.gervaso at gmail.com>woorea.es
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20130103/1b90c14a/attachment.html>
More information about the Openstack
mailing list