Trying Citycloud’s OpenStack API with openstack4j

Trying Citycloud’s OpenStack API with openstack4j

Yesterday, we blogged about Citycloud’s new OpenStack offering, and how openstack4j now supports all authentication schemes in Keystone v3. We are excited about these developments, and want to show how easy it is to develop new solutions for Citycloud in openstack4j.

Citycloud credentials

Of course, the first thing you need is to head over to Citycloud and sign up. Once your new account is ready, log in over at your control panel. Once there, expand the API section, select the Native OpenStack API item, ensure that the API is active and create a new user. You assign it a password, keep a note of it. Also note your user’s ID.

Next, head over to the Settings section in your navigational sidebar. There, you will find “Manage projects”. Click on it, and note your project ID. Citycloud uses project-scoped authentication, so we will need all three: Openstack API user and password, plus the project ID the resources will belong to.

Obtaining openstack4j

At the time of writing, the stable version of openstack4j is 2.0.1, and the version that will include the required Keystone support is 2.0.2. Follow the instructions given at openstack4j’s github page and activate the 2.0.2-SNAPSHOT version. Make sure to add the Sonatype snapshot repo to your pom.xml, too!

Trying it out

The following dead-simple code shows not only how nice openstack4j’s fluent API is, but also what parameters to pass to make authentication work against Citycloud. Ignoring imports and package declarations for conciseness, the code is as follows:

public class Main {
	private static final String PASSWORD = "OpenStack API user password goes here";
	private static final String USER_ID = "OpenStack API user ID goes here";
	private final static String PROJECT_ID = "Project ID goes here";

	public static void main(String[] args) {
		OSClient client = OSFactory
				.credentials(USER_ID, PASSWORD)

		List serverList = (List) client.compute().servers()


And that’s it! That is all you need to list your servers running in Citycloud using openstack4j.

Stay tuned for an elastisys cloud pool implementation for Citycloud’s new and exciting OpenStack offering.

This Post Has One Comment

Comments are closed.