Search in sources :

Example 1 with OpenStackHypervisor

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

the class OpenStackComputeService method getHypervisor.

/**
 * @see com.att.cdp.zones.ComputeService#getHypervisor(java.lang.String)
 */
@Override
public Hypervisor getHypervisor(String id) throws ZoneException {
    checkArg(id, "id");
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.HYPERVISOR, id);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    try {
        com.woorea.openstack.nova.model.Hypervisor hypervisor = nova.getClient().hypervisors().show(id).execute();
        return new OpenStackHypervisor(context, hypervisor);
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return null;
}
Also used : Context(com.att.cdp.zones.Context) OpenStackContext(com.att.cdp.openstack.OpenStackContext) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) OpenStackHypervisor(com.att.cdp.openstack.model.OpenStackHypervisor)

Example 2 with OpenStackHypervisor

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

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

the class OpenStackComputeService method getHypervisors.

/**
 * @see com.att.cdp.zones.ComputeService#getHypervisors(java.lang.String)
 */
@Override
public List<Hypervisor> getHypervisors(String id) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    RequestState.put(RequestState.HYPERVISOR, id);
    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()) {
            if (id != null) {
                if (h.getId().matches(id)) {
                    list.add(new OpenStackHypervisor(context, h));
                }
            } else {
                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)

Aggregations

OpenStackContext (com.att.cdp.openstack.OpenStackContext)3 OpenStackHypervisor (com.att.cdp.openstack.model.OpenStackHypervisor)3 Context (com.att.cdp.zones.Context)3 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)3 Hypervisor (com.att.cdp.zones.model.Hypervisor)2 ArrayList (java.util.ArrayList)2