Search in sources :

Example 6 with OpenStackServer

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

the class OpenStackComputeService method refreshServerStatus.

@SuppressWarnings("nls")
@Override
public void refreshServerStatus(Server server) throws ZoneException {
    checkArg(server, "server");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVER, server);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        ((OpenStackServer) server).mapServerStatus(nova.getClient().servers().show(server.getId()).execute());
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer)

Example 7 with OpenStackServer

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

the class OpenStackComputeService method getServers.

/**
 * Obtain a list of servers from the compute service.
 *
 * @return The list of servers that are defined.
 * @throws ZoneException
 *             - If any of the following conditions are true:
 *             <ul>
 *             <li>the user has not successfully logged in to the provider</li>
 *             <li>the context has been closed and this service is requested
 *             </li>
 *             <li>the current user does not have the rights to perform this
 *             operation</li>
 *             <li>the user and/or credentials are not valid</li>
 *             </ul>
 * @see com.att.cdp.zones.ComputeService#getServers()
 */
@Override
public List<Server> getServers() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<Server> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Servers servers = nova.getClient().servers().list(true).execute();
        if (servers != null && servers.getList() != null) {
            for (com.woorea.openstack.nova.model.Server s : servers.getList()) {
                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)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)7 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)7 Context (com.att.cdp.zones.Context)7 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)7 Server (com.att.cdp.zones.model.Server)4 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)4 Servers (com.woorea.openstack.nova.model.Servers)4 ArrayList (java.util.ArrayList)4