The Dasein Cloud API

By George Reese
August 15, 2009

Since the beginning of Java time, I have been releasing certain libraries under the Open Source name "Dasein". The first release was the first driver written against the JDBC specification, mSQL-JDBC. Other parts of Dasein include a Java utilities library, a CAPTCHA system accessible to users with disabilities, an object/relational mapping library, and more. This past week, enStratus contributed its cloud-abstraction layer to Dasein in the form of the Dasein Cloud API.

One of the key challenges with programming cloud management applications is that most providers tend to have wildly different programming APIs. If you want to support multiple clouds or if you simply want to support the possibility of switching cloud providers, you are faced with supporting different programming models.

Dasein Cloud provides a cloud-independent interface in Java for accessing cloud resources. If you are writing an application to manage your cloud infrastructure, you write the calls against the Dasein Cloud API without having to learn the specifics of the web services calls from different providers like Amazon Web Services and Rackspace. Cloud providers can then provide cloud-specific implementations of the API that simply plug in to your application without any need for changing your code. The model is very much like JDBC.

The following code shows how to list the servers currently running in the cloud:

import org.dasein.cloud.CloudProvider;
import org.dasein.cloud.ProviderContext;
import org.dasein.cloud.services.server.Server;

public class Lister {
public void main(String ... args) throws Exception {
CloudProvider provider = (CloudProvider)Class.forName(args[0]).newInstance();
ProviderContext ctx = new ProviderContext();

ctx.setAccountNumber(args[1]);
ctx.setRegion(args[2]);
ctx.setAccessKeys(args[3].getBytes("utf-8"), args[4].getBytes("utf-8"));
provider.connect(ctx);
try {
for( Server server : provider.getServerServices().list() ) {
System.out.println(server.getProviderServerId());
}
}
finally {
provider.close();
}
}
}

This code works no matter what cloud you are supporting, as long as there is an implementation for that provider. enStratus has made available its Amazon Web Services implementation both as a reference implementation and a working system for Dasein Cloud + AWS. enStratus will be releasing implementations for other providers, and hopefully providers will begin providing their own implementations.

You can download and/or become a contributor to the Dasein Cloud project at http://dasein-cloud.sourceforge.net. The software is available under the terms of the Open Source Artistic License 2.0.


You might also be interested in:

News Topics

Recommended for You

Got a Question?