Search in sources :

Example 11 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException 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 12 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method processResize.

/**
 * @see com.att.cdp.zones.ComputeService#processResize(com.att.cdp.zones.model.Server)
 */
@SuppressWarnings("nls")
@Override
public void processResize(Server server) throws ZoneException {
    checkArg(server, "server");
    checkArg(server.getId(), "server id");
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        OpenStackResponse request = nova.getClient().servers().confirmResize(server.getId()).request();
        if (request != null && request.getStatus() != Status.NO_CONTENT.getStatusCode()) {
            throw new ZoneException(request.getEntity(String.class));
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : OpenStackResponse(com.woorea.openstack.base.client.OpenStackResponse) ZoneException(com.att.cdp.exceptions.ZoneException) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException)

Example 13 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method getHypervisors.

/**
 * @see com.att.cdp.zones.ComputeService#getHypervisors()
 */
@Override
public List<Hypervisor> getHypervisors() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<Hypervisor> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Hypervisors hypervisors = nova.getClient().hypervisors().list(true).execute();
        for (com.woorea.openstack.nova.model.Hypervisor h : hypervisors.getList()) {
            list.add(new OpenStackHypervisor(context, h));
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackHypervisor(com.att.cdp.openstack.model.OpenStackHypervisor) Hypervisor(com.att.cdp.zones.model.Hypervisor) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) OpenStackHypervisor(com.att.cdp.openstack.model.OpenStackHypervisor)

Example 14 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method getServers.

/**
 * Returns the list of servers that match the name pattern supplied.
 *
 * @param name
 *            A regular expression that can be used to filter server names. A string that is suitable to use in the
 *            Java <code>String.matches()</code> method.
 * @return The server
 * @throws ZoneException
 *             If the host cannot be found
 * @see java.lang.String#matches(String)
 * @see com.att.cdp.zones.ComputeService#getServers(java.lang.String)
 */
@Override
public List<Server> getServers(String name) throws ZoneException {
    // checkArg(name, "name");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    RequestState.put(RequestState.SERVER, name);
    ArrayList<Server> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Servers servers = nova.getClient().servers().list(true).execute();
        for (com.woorea.openstack.nova.model.Server s : servers.getList()) {
            if (name != null) {
                if (s.getName().matches(name)) {
                    list.add(new OpenStackServer(context, s));
                }
            } else {
                list.add(new OpenStackServer(context, s));
            }
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return list;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) Server(com.att.cdp.zones.model.Server) ConnectedServer(com.att.cdp.zones.spi.model.ConnectedServer) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer) ArrayList(java.util.ArrayList) Servers(com.woorea.openstack.nova.model.Servers)

Example 15 with OpenStackBaseException

use of com.woorea.openstack.base.client.OpenStackBaseException in project AJSC by att.

the class OpenStackComputeService method findAllServersUsingKey.

/**
 * @see com.att.cdp.zones.ComputeService#findAllServersUsingKey(java.lang.String)
 */
@SuppressWarnings("nls")
@Override
public List<String> findAllServersUsingKey(String keyPair) throws ZoneException {
    checkArg(keyPair, "keyPair");
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    RequestState.put(RequestState.KEYPAIR, keyPair);
    List<String> users = new ArrayList<String>();
    try {
        Servers servers = nova.getClient().servers().list(false).execute();
        for (com.woorea.openstack.nova.model.Server server : servers.getList()) {
            if (keyPair.equals(server.getKeyName())) {
                users.add(server.getId());
            }
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return users;
}
Also used : OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList) Servers(com.woorea.openstack.nova.model.Servers)

Aggregations

OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)151 OpenStackContext (com.att.cdp.openstack.OpenStackContext)140 Context (com.att.cdp.zones.Context)140 ArrayList (java.util.ArrayList)54 Quantum (com.woorea.openstack.quantum.Quantum)36 OpenStackSnapshot (com.att.cdp.openstack.model.OpenStackSnapshot)18 ZoneException (com.att.cdp.exceptions.ZoneException)15 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)14 Server (com.att.cdp.zones.model.Server)11 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)11 HashMap (java.util.HashMap)11 ResourceNotFoundException (com.att.cdp.exceptions.ResourceNotFoundException)10 Snapshot (com.att.cdp.zones.model.Snapshot)10 OpenStackACL (com.att.cdp.openstack.model.OpenStackACL)8 OpenStackImage (com.att.cdp.openstack.model.OpenStackImage)8 OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)8 OpenStackVolume (com.att.cdp.openstack.model.OpenStackVolume)8 OpenStackNetwork (com.att.cdp.openstack.model.OpenStackNetwork)7 Network (com.att.cdp.zones.model.Network)7 Port (com.att.cdp.zones.model.Port)7