Skip to content

Instantly share code, notes, and snippets.

@jasdeep-hundal
Last active August 29, 2015 13:57
Show Gist options
  • Save jasdeep-hundal/852739ae465398587144 to your computer and use it in GitHub Desktop.
Save jasdeep-hundal/852739ae465398587144 to your computer and use it in GitHub Desktop.
Glance API Example - JClouds + Devstack
ADMIN_PASSWORD=secrete
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
SERVICE_TOKEN=a682f596-76f3-11e3-b3b2-e716f9080d50
HOST_IP=192.168.56.20
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS;
import org.jclouds.ContextBuilder;
import org.jclouds.openstack.glance.v1_0.GlanceApi;
import org.jclouds.openstack.glance.v1_0.features.ImageApi;
import org.junit.Test;
/**
*
* @author Jasdeep Hundal
*/
public class GlanceApiTest {
private static final Log LOG = LogFactory.getLog(GlanceApiTest.class);
@Test
public void testListImages() throws Exception {
String provider = "openstack-glance";
Properties properties = new Properties();
properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true");
properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true");
properties.setProperty(provider + ".identity", "admin:admin");
properties.setProperty(provider + ".credential", "secrete");
properties.setProperty(provider + ".endpoint", "http://192.168.56.20:5000/v2.0/");
ContextBuilder builder = ContextBuilder.newBuilder(provider);
GlanceApi glanceApi = builder.overrides(properties).buildApi(GlanceApi.class);
ImageApi imageApi = glanceApi.getImageApiForZone("RegionOne");
imageApi.list();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment