Search in sources :

Example 1 with Template

use of com.att.cdp.zones.model.Template in project AJSC by att.

the class OpenStackComputeService method getTemplates.

/**
 * This method returns a list of templates that are available.
 * <p>
 * A template represents a definition of a hardware environment that is used to create an image. This includes
 * number of cpu's, amount of memory, etc.
 * </p>
 *
 * @return A list of available templates
 * @throws ZoneException
 *             If the templates cannot be listed
 * @see com.att.cdp.zones.ComputeService#getTemplates()
 */
@Override
public List<Template> getTemplates() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<Template> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Flavors flavors = nova.getClient().flavors().list(true).execute();
        for (com.woorea.openstack.nova.model.Flavor f : flavors.getList()) {
            Template template = new OpenStackTemplate(context, f);
            list.add(template);
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) OpenStackTemplate(com.att.cdp.openstack.model.OpenStackTemplate) OpenStackTemplate(com.att.cdp.openstack.model.OpenStackTemplate) Template(com.att.cdp.zones.model.Template)

Example 2 with Template

use of com.att.cdp.zones.model.Template in project AJSC by att.

the class TestTemplates method listTemplates.

/**
 * Verifies that we can list the existing templates on a provider. This test requires that the provider actually has
 * templates installed.
 *
 * @throws ZoneException
 */
@Test
@Ignore
public void listTemplates() throws ZoneException {
    Context context = connect();
    ComputeService service = context.getComputeService();
    List<Template> templates = service.getTemplates();
    assertNotNull(templates);
    assertFalse(templates.isEmpty());
    for (Template template : templates) {
        System.out.println(template.toString());
    }
}
Also used : Context(com.att.cdp.zones.Context) ComputeService(com.att.cdp.zones.ComputeService) Template(com.att.cdp.zones.model.Template) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with Template

use of com.att.cdp.zones.model.Template in project AJSC by att.

the class OpenStackComputeService method getTemplates.

/**
 * This method returns a list of templates that are available.
 * <p>
 * A template represents a definition of a hardware environment that is used
 * to create an image. This includes number of cpu's, amount of memory, etc.
 * </p>
 *
 * @return A list of available templates
 * @throws ZoneException
 *             If the templates cannot be listed
 * @see com.att.cdp.zones.ComputeService#getTemplates()
 */
@Override
public List<Template> getTemplates() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<Template> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Flavors flavors = nova.getClient().flavors().list(true).execute();
        for (com.woorea.openstack.nova.model.Flavor f : flavors.getList()) {
            Template template = new OpenStackTemplate(context, f);
            list.add(template);
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) OpenStackTemplate(com.att.cdp.openstack.model.OpenStackTemplate) OpenStackTemplate(com.att.cdp.openstack.model.OpenStackTemplate) Template(com.att.cdp.zones.model.Template)

Example 4 with Template

use of com.att.cdp.zones.model.Template in project AJSC by att.

the class TestComputeService method testComputeService.

/**
 * @throws ZoneException
 *             If something goes horribly wrong
 */
@Ignore
@Test
public void testComputeService() throws ZoneException {
    Context context = connect();
    ComputeService computeService = context.getComputeService();
    List<Server> servers = computeService.getServers();
    for (Server server : servers) {
        computeService.getServers(server.getName());
        computeService.getServer(server.getId());
        computeService.getAttachments(server);
        computeService.getAttachments(server.getId());
        computeService.getConsoleOutput(server);
    }
    List<Template> templates = computeService.getTemplates();
    for (Template template : templates) {
        computeService.getTemplate(template.getId());
    }
    List<ACL> accessControlLists = computeService.getAccessControlLists();
    for (ACL acl : accessControlLists) {
        computeService.getAccessControlList(acl.getId());
    }
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer) Server(com.att.cdp.zones.model.Server) ACL(com.att.cdp.zones.model.ACL) ComputeService(com.att.cdp.zones.ComputeService) Template(com.att.cdp.zones.model.Template) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Context (com.att.cdp.zones.Context)4 Template (com.att.cdp.zones.model.Template)4 OpenStackContext (com.att.cdp.openstack.OpenStackContext)3 OpenStackTemplate (com.att.cdp.openstack.model.OpenStackTemplate)2 ComputeService (com.att.cdp.zones.ComputeService)2 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)2 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)1 ACL (com.att.cdp.zones.model.ACL)1 Server (com.att.cdp.zones.model.Server)1