Release 1.0-RC3 is compatible with Essex and Folsom.
Maven
| groupId | artifactId | version |
| org.openstack | openstack-java-sdk | 1.0-RC3 |
https://raw.github.com/woorea/maven/master/releases/
Configuration
You can configure the client in a properties file
openstack.properties
verbose=true #for HPCloud #auth.credentials=apiAccessKeyCredentials #auth.accessKey=<your accessKey> #auth.secretKey=<your secretKey> #auth.tenantId=<your tenantId> auth.credentials=passwordCredentials auth.username=demo auth.password=secret0 #auth.tenantId=123456789 auth.tenantName=demo identity.endpoint.publicURL=http://192.168.1.43:5000/v2.0 identity.endpoint.internalURL=http://192.168.1.43:5000/v2.0 identity.endpoint.adminURL=http://192.168.1.43:35357/v2.0 identity.admin.token=secret0 test.glance=false test.swift=false
Example
Identity API (keystone)
Access
// X-Auth-Token OpenStackClient openstack = OpenStackClient.authenticate(properties); IdentityAdministrationEndpoint identity = openstack.getIdentityAdministationEndpoint();
Tenants
//GET tenants available
TenantList tenants = identity.tenants().get();
//POST tenant
KeystoneTenant kst = new KeystoneTenant();
kst.setName("test");
kst.setDescription("desc");
kst.setEnabled(true);
Tenant tenant = identity.tenants().post(kst);
//GET tenant
tenant = identity.tenants().tenant(tenant.getId()).get();
//DELETE tenant
identity.tenants().tenant(tenant.getId()).delete();
Users
UserList users = identity.users().get();
KeystoneUser ksu = new KeystoneUser();
ksu.setName("test");
ksu.setPassword("secret0");
ksu.setEmail("test@test.com");
ksu.setEnabled(true);
User user = identity.users().post(ksu);
user = identity.users().user(user.getId()).get();
identity.users().user(user.getId()).delete();
Roles
RoleList roles = identity.roles().get();
KeystoneRole ksr = new KeystoneRole();
ksr.setName("test");
Role role = identity.roles().post(ksr);
role = identity.roles().role(role.getId()).get();
identity.roles().role(role.getId()).delete();
Services
ServiceList services = identity.services().get();
KeystoneService kss = new KeystoneService();
kss.setName("test");
kss.setType("compute");
kss.setDescription("Nova 3.0");
Service service = identity.services().post(kss);
service = identity.services().service(service.getId()).get();
identity.services().service(service.getId()).delete();
Endpoints (Not implemented yet)
501 HTTP Error from Keystone Server API
Compute API (nova)
Select a Tenant
// Authenticate on admin tenant
openstack = openstack.reauthenticateOnTenant("admin");
TenantResource compute = openstack.getComputeEndpoint();
Servers
ServerList servers = compute.servers().get();
Server Actions
TODO
Images
ImageList images = compute.images().get();
Flavors
FlavorList flavors = compute.flavors().get();
Key Pairs
KeyPairList keypairs = compute.keyPairs().get();
Security Groups
SecurityGroupList securityGroups = compute.securityGroups().get();
Volumes
VolumeList volumes = compute.volumes().get();
Image Store (glance)
org.openstack.model.images.ImageList gImages = openstack.getImagesEndpoint().get();
Object Store (swift)
List<StorageContainer> sAccount = openstack.getStorageEndpoint().get();
Maven
We use maven to build the project. Some helpful maven commands:
mvn eclipse:eclipse Create the eclipse projects
mvn install Builds everything, runs unit & integration tests, installs into your maven repo
mvn install -Dmaven.test.skip=true As above, but without running tests
License
This software is licensed under the Apache 2 license, quoted below.
Copyright 2012 Luis Gervaso and OpenStack Java SDK
Copyright 2012 Justin Santa Barbara
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.