Search in sources :

Example 1 with Volume

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

the class ConnectedVolume method refresh.

/**
 * @see com.att.cdp.zones.model.Volume#refresh()
 */
@Override
public void refresh() throws ZoneException {
    Context context = getContext();
    Volume copy = context.getVolumeService().getVolume(getId());
    ObjectMapper.map(copy, this);
}
Also used : Context(com.att.cdp.zones.Context) Volume(com.att.cdp.zones.model.Volume)

Example 2 with Volume

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

the class OpenStackVolumeService method getVolumes.

/**
 * Returns a list of volumes that match the supplied name
 *
 * @param name
 *            The name pattern of the volumes to be located. The name is a regular expression that is suitable for
 *            use in the Java String.matches() method.
 * @return A list (potentially empty) of all volumes that match the specified name pattern
 * @throws ZoneException
 *             - If the volume service cannot be accessed.
 * @see java.lang.String#matches(String)
 * @see com.att.cdp.zones.VolumeService#getVolumes(java.lang.String)
 */
@Override
public List<Volume> getVolumes(String name) throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.VOLUME, name);
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint());
    ArrayList<Volume> list = new ArrayList<>();
    try {
        com.woorea.openstack.nova.model.Volumes volumes = nova.getClient().volumes().list(true).execute();
        for (com.woorea.openstack.nova.model.Volume volume : volumes) {
            if (name != null) {
                if (volume.getName() != null && volume.getName().matches(name)) {
                    list.add(new OpenStackVolume(context, volume));
                }
            } else {
                list.add(new OpenStackVolume(context, volume));
            }
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return list;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) Volume(com.att.cdp.zones.model.Volume) OpenStackVolume(com.att.cdp.openstack.model.OpenStackVolume) AbstractVolume(com.att.cdp.zones.spi.AbstractVolume) OpenStackVolume(com.att.cdp.openstack.model.OpenStackVolume) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Example 3 with Volume

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

the class OpenStackVolumeService method getVolumes.

/**
 * Retrieves the list of volumes defined for this service.
 *
 * @return The list of volumes for this tenant, if any. The list may be empty if there are no volumes defined.
 * @see com.att.cdp.zones.VolumeService#getVolumes()
 */
@Override
public List<Volume> getVolumes() throws ZoneException {
    connect();
    Context context = getContext();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Volume");
    RequestState.put(RequestState.SERVICE_URL, cinder.getEndpoint());
    ArrayList<Volume> list = new ArrayList<>();
    try {
        com.woorea.openstack.cinder.model.Volumes volumes = cinder.getClient().volumes().list(true).execute();
        for (com.woorea.openstack.cinder.model.Volume volume : volumes) {
            list.add(new OpenStackVolume(context, volume));
        }
    } catch (OpenStackBaseException ex) {
        ExceptionMapper.mapException(ex);
    }
    return list;
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) Volume(com.att.cdp.zones.model.Volume) OpenStackVolume(com.att.cdp.openstack.model.OpenStackVolume) AbstractVolume(com.att.cdp.zones.spi.AbstractVolume) OpenStackVolume(com.att.cdp.openstack.model.OpenStackVolume) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) ArrayList(java.util.ArrayList)

Example 4 with Volume

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

the class TestComputeService method testListServers.

/**
 * This test case is designed to simply list the existing servers.
 *
 * @throws ZoneException
 *             If something goes horribly wrong
 */
@SuppressWarnings("nls")
@Ignore
@Test
public void testListServers() throws ZoneException {
    Context context = connect();
    ComputeService computeService = context.getComputeService();
    List<Server> servers = computeService.getServers();
    for (Server server : servers) {
        System.out.println(server.toString());
        if (server.getImage() == null) {
            // Map<String, String> attachments = server.getAttachments();
            Map<String, Volume> attachments = server.getVolumes();
            System.out.println("+++No image, volume attachments are: " + attachments.toString());
        }
    }
}
Also used : OpenStackContext(com.att.cdp.openstack.OpenStackContext) Context(com.att.cdp.zones.Context) OpenStackServer(com.att.cdp.openstack.model.OpenStackServer) Server(com.att.cdp.zones.model.Server) Volume(com.att.cdp.zones.model.Volume) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with Volume

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

the class TestVolumeService method listVolumes.

/**
 * @throws ZoneException
 */
@Test
@Ignore
public void listVolumes() throws ZoneException {
    Context context = connect();
    VolumeService service = context.getVolumeService();
    List<Volume> volumes = service.getVolumes();
    assertNotNull(volumes);
    for (Volume volume : volumes) {
        assertNotNull(service.getVolume(volume.getId()));
        assertNotNull(service.getVolumes(volume.getName()));
        if (volume.getStatus().equals(Volume.Status.ERROR)) {
            System.out.printf("%-12s: %s\n", volume.getName(), volume.getId());
        }
    }
}
Also used : Context(com.att.cdp.zones.Context) Volume(com.att.cdp.zones.model.Volume) VolumeService(com.att.cdp.zones.VolumeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Volume (com.att.cdp.zones.model.Volume)13 Context (com.att.cdp.zones.Context)11 OpenStackContext (com.att.cdp.openstack.OpenStackContext)6 Ignore (org.junit.Ignore)6 Test (org.junit.Test)6 VolumeService (com.att.cdp.zones.VolumeService)5 OpenStackVolume (com.att.cdp.openstack.model.OpenStackVolume)4 AbstractVolume (com.att.cdp.zones.spi.AbstractVolume)4 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)4 ArrayList (java.util.ArrayList)4 ComputeService (com.att.cdp.zones.ComputeService)3 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)2 Server (com.att.cdp.zones.model.Server)2 Network (com.att.cdp.zones.model.Network)1 ServerBootSource (com.att.cdp.zones.model.ServerBootSource)1 HashMap (java.util.HashMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1