Search in sources :

Example 1 with OpenStackTemplate

use of com.att.cdp.openstack.model.OpenStackTemplate in project AJSC by att.

the class OpenStackComputeService method getTemplate.

/**
 * Obtains the template specified by the provided id
 *
 * @see com.att.cdp.zones.ComputeService#getTemplate(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Template getTemplate(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    RequestState.put(RequestState.TEMPLATE, id);
    try {
        return new OpenStackTemplate(context, nova.getClient().flavors().show(id).execute());
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    } catch (Exception e) {
        throw new ResourceNotFoundException(e);
    }
    // for the compiler
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackTemplate(com.att.cdp.openstack.model.OpenStackTemplate) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException) InvalidRequestException(com.att.cdp.exceptions.InvalidRequestException) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ZoneException(com.att.cdp.exceptions.ZoneException) OpenStackConnectException(com.woorea.openstack.base.client.OpenStackConnectException) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) ContextClosedException(com.att.cdp.exceptions.ContextClosedException) NotLoggedInException(com.att.cdp.exceptions.NotLoggedInException)

Example 2 with OpenStackTemplate

use of com.att.cdp.openstack.model.OpenStackTemplate 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 3 with OpenStackTemplate

use of com.att.cdp.openstack.model.OpenStackTemplate in project AJSC by att.

the class OpenStackComputeService method getTemplate.

/**
 * Obtains the template specified by the provided id
 *
 * @see com.att.cdp.zones.ComputeService#getTemplate(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public Template getTemplate(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    RequestState.put(RequestState.TEMPLATE, id);
    try {
        return new OpenStackTemplate(context, nova.getClient().flavors().show(id).execute());
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    } catch (Exception e) {
        throw new ResourceNotFoundException(e);
    }
    // for the compiler
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackTemplate(com.att.cdp.openstack.model.OpenStackTemplate) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException) InvalidRequestException(com.att.cdp.exceptions.InvalidRequestException) ResourceNotFoundException(com.att.cdp.exceptions.ResourceNotFoundException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ZoneException(com.att.cdp.exceptions.ZoneException) OpenStackConnectException(com.woorea.openstack.base.client.OpenStackConnectException) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) ContextClosedException(com.att.cdp.exceptions.ContextClosedException) NotLoggedInException(com.att.cdp.exceptions.NotLoggedInException)

Example 4 with OpenStackTemplate

use of com.att.cdp.openstack.model.OpenStackTemplate 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)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)4 OpenStackTemplate (com.att.cdp.openstack.model.OpenStackTemplate)4 Context (com.att.cdp.zones.Context)4 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)4 ContextClosedException (com.att.cdp.exceptions.ContextClosedException)2 InvalidRequestException (com.att.cdp.exceptions.InvalidRequestException)2 NotLoggedInException (com.att.cdp.exceptions.NotLoggedInException)2 ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)2 ZoneException (com.att.cdp.exceptions.ZoneException)2 Template (com.att.cdp.zones.model.Template)2 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)2 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)2 ArrayList (java.util.ArrayList)2