Fork me on GitHub

OpenStack4j

[ Fluent OpenStack client for Java ]

Learn JavaDoc Install

Take Control of Your Cloud
OpenStack4j is an open source OpenStack client which allows provisioning and control of an OpenStack system. This includes support for Identity, Compute, Image, Block Storage, Telemetry, Orchestration and Network using Java. The library and has been broken out into several major API abstractions:

Identity

The Identity (Keystone) service provides the central directory of users, tenants, service endpoints and authorization.

Identity Guide

Compute

The Compute (Nova) service provides management to Servers (running virtual machines), VM Management, Flavors and diagnostics. The API makes day to day management tasks breeze.

Compute Guide

Image

The Image (Glance) service provides discovery, registration and delivery services for disk and server images. Stored images can be used as a template for quickly booting new instances.

Image Guide

Network

The Network (Neutron) service provides "network connectivity as a service". The OpenStack4j implementation supports Routers, Ports, Subnets and Interface management.

Network Guide

Block Storage

Block Storage (Cinder) Service is a block-level storage solution that enables you to mount drives to scale storage. OpenStack4j implementation fully supports all major operations.

Block Storage Guide

Telemetry

Telemetry (Ceilometer) delivers metering and statistic measurements against OpenStack core components. This is ideal for customer billing, account and reporting of resources.

Block Storage Guide

Orchestration

Orchestration (Heat) is a service that you can use to orchestrate multiple composite cloud applications. Using OpenStack4j you can control Stacks, Templates, Resources and Events.

Orchestration Guide

Fluent API
Identity
// Authenticate
OSClient os = OSFactory.builder()
                  .endpoint("http://127.0.0.1:5000/v2.0")
                  .credentials("admin","sample")
                  .tenantName("admin")
                  .authenticate();

// Create a Tenant
Tenant t = os.identity().tenants()
                     .create(Builders.tenant()
                     .name("ABC Corporation")
                     .build());
			
Compute
// Create a Server Model Object
Server server = Builders.server()
                        .name("Ubuntu 2")
                        .flavor("large")
                        .image("imageId")
                        .build();

// Boot the Server
Server server = os.compute().servers().boot(server);

// Create a Snapshot
os.compute().servers().createSnapshot("id", "name");
			
Image
// Create an Image
Image image = os.images().create(Builders.image()
                .name("Cirros 0.3.0 x64")
                .isPublic(true)
                .containerFormat(ContainerFormat.BARE)
                .diskFormat(DiskFormat.QCOW2)
                .build()
                ), Payloads.create(new File("cirros.img")));
			
Network
	
// Create a Port
Port port = os.networking().port()
              .create(Builders.port()
              .name("port1")
              .networkId("networkId")
              .fixedIp("52.51.1.253", "subnetId")
              .build());