// X-Auth-Token (no tenant selected)
OpenStackClient openstack = OpenStackClientFactory.authenticate("http://192.168.1.52:5000/v2.0", "admin", "secret0");
//Here we use the admintoken (set on installation process. It may be different from admin password setted before)
openstack.getAccess().getToken().setId("secret0");
//Since Keystone does not give us information about services
//when we do not choose a tenant, we have to know the identity
//admin endpoint and create the administration endpoint from it.
IdentityAdministrationEndpoint identity = openstack.target("http://192.168.1.52:35357/v2.0", IdentityAdministrationEndpoint.class);
//GET tenants available
KeystoneTenantList tenants = identity.tenants().get();
//POST tenant
KeystoneTenant tenant = new KeystoneTenant();
tenant.setName("test");
tenant.setDescription("desc");
tenant.setEnabled(true);
tenant = identity.tenants().post(Entity.json(tenant));
//GET tenant
tenant = identity.tenants().tenant(tenant.getId()).get();
//DELETE tenant
identity.tenants().tenant(tenant.getId()).delete();
KeystoneUserList users = identity.users().get();
KeystoneUser user = new KeystoneUser();
user.setName("test");
user.setPassword("secret0");
user.setEmail("test@test.com");
user.setEnabled(true);
user = identity.users().post(Entity.json(user));
user = identity.users().user(user.getId()).get();
identity.users().user(user.getId()).delete();
KeystoneRoleList roles = identity.roles().get();
KeystoneRole role = new KeystoneRole();
role.setName("test");
role = identity.roles().post(Entity.json(role));
role = identity.roles().role(role.getId()).get();
identity.roles().role(role.getId()).delete();
KeystoneServiceList services = identity.services().get();
KeystoneService service = new KeystoneService();
service.setName("test");
service.setType("compute");
service.setDescription("Nova 3");
service = identity.services().post(Entity.json(service));
service = identity.services().service(service.getId()).get();
identity.services().service(service.getId()).delete();
501 HTTP Error from Keystone Server API
// Authenticate on admin tenant
openstack = OpenStackClientFactory.authenticate("http://192.168.1.52:5000/v2.0", "admin", "secret0", "admin");
TenantResource compute = openstack.compute().getPublicEndpoint();
NovaServerList servers = compute.servers().get();
TODO
NovaImageList images = compute.images().get();
NovaFlavorList flavors = compute.flavors().get();
NovaKeyPairList keypairs = compute.keyPairs().get();
NovaSecurityGroupList securityGroups = compute.securityGroups().get();
NovaVolumeList volumes = compute.volumes().get();
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
mvn test Runs unit tests
mvn verify Runs integration tests
The integration tests run against an OpenStack installation.
It takes its configuration from the system properties.
Useful properties:
| Property | Default | Explanation |
| openstack.debug | false | Set to true for lots of debug output |
| openstack.auth.url | http://127.0.0.1:5000/v2.0 | Location of Keystone service |
| openstack.auth.user | demo | Authentication info: username |
| openstack.auth.secret | secret0 | Authentication info: password |
| openstack.auth.tenant | demo | Authentication info: tenant |
The defaults should work with a local devstack installation. Otherwise do something like this:
mvn verify -Dopenstack.auth.url=http://192.168.2.10:5000/v2.0
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.