Search in sources :

Example 1 with Hypervisor

use of com.att.cdp.zones.model.Hypervisor 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 2 with Hypervisor

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

the class TestComputeService method testListHypervisors.

/**
 * This test case is designed to simply list the existing hypervisors.
 *
 * @throws ZoneException
 *             If something goes horribly wrong
 */
@SuppressWarnings("nls")
@Ignore
@Test
public void testListHypervisors() throws ZoneException {
    Context context = connect();
    ComputeService computeService = context.getComputeService();
    List<Hypervisor> hypervisors = computeService.getHypervisors();
    for (Hypervisor hypervisor : hypervisors) {
        System.out.println(hypervisor.toString());
    }
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) Hypervisor(com.att.cdp.zones.model.Hypervisor) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with Hypervisor

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

Example 4 with Hypervisor

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

the class TestComputeService method testGetHypervisor.

/**
 * This test case is designed to simply list the details for a hypervisor.
 *
 * @throws ZoneException
 *             If something goes horribly wrong
 */
@SuppressWarnings("nls")
@Ignore
@Test
public void testGetHypervisor() throws ZoneException {
    Context context = connect();
    ComputeService computeService = context.getComputeService();
    Hypervisor hypervisor = computeService.getHypervisor("1");
    System.out.println(hypervisor.toString());
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) Hypervisor(com.att.cdp.zones.model.Hypervisor) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with Hypervisor

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

the class OpenStackServer method loadHypervisorAttachment.

/**
 * This method is called to load the hypervisor attachment, if it has not already been loaded. If it has been
 * loaded, then the call is ignored.
 *
 * @param context
 *            The context that represents the connection we are servicing
 * @throws ZoneException
 *             If the attachments cannot be obtained, or if a hypervisor cannot be listed, or a hypervisor does not
 *             exist
 */
private void loadHypervisorAttachment(Context context) throws ZoneException {
    if (hypervisorAttachmentProcessed.compareAndSet(false, true)) {
        ComputeService computeService = context.getComputeService();
        List<Hypervisor> hypervisors = computeService.getHypervisors();
        if (this.novaModel.getHypervisorHostname() != null && !this.novaModel.getHypervisorHostname().isEmpty()) {
            String hypervisorName = this.novaModel.getHypervisorHostname();
            for (Hypervisor h : hypervisors) {
                if (h.getHostName().equals(hypervisorName)) {
                    this.setHypervisor(h);
                    return;
                }
            }
        }
    }
}
Also used : Hypervisor(com.att.cdp.zones.model.Hypervisor) ComputeService(com.att.cdp.zones.ComputeService)

Aggregations

Hypervisor (com.att.cdp.zones.model.Hypervisor)6 Context (com.att.cdp.zones.Context)5 OpenStackContext (com.att.cdp.openstack.OpenStackContext)4 ComputeService (com.att.cdp.zones.ComputeService)3 OpenStackHypervisor (com.att.cdp.openstack.model.OpenStackHypervisor)2 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)2 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2