Search in sources :

Example 6 with Volume

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

the class TestVolumeService method CreateVolume.

@Test
@Ignore
public void CreateVolume() throws ZoneException {
    Context context = connect();
    Volume template = new Volume();
    template.setSize(Integer.valueOf(2));
    template.setName("Volume");
    VolumeService service = context.getVolumeService();
    Volume vol = service.createVolume(template);
    assertNotNull(vol);
}
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)

Example 7 with Volume

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

the class OpenStackServer method loadVolumeAttachments.

/**
 * This method is called to load the volume attachments, if they have not already been loaded. If they have 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 volume cannot be listed, or a volume does not exist
 */
private void loadVolumeAttachments(Context context) throws ZoneException {
    if (volumeAttachmentsProcessed.compareAndSet(false, true)) {
        VolumeService volumeService = context.getVolumeService();
        ComputeService computeService = context.getComputeService();
        Map<String, String> attachments = computeService.getAttachments(getId());
        for (Entry<String, String> entry : attachments.entrySet()) {
            Volume volume = volumeService.getVolume(entry.getValue());
            getVolumes().put(entry.getKey(), volume);
        }
    }
}
Also used : Volume(com.att.cdp.zones.model.Volume) VolumeService(com.att.cdp.zones.VolumeService) ComputeService(com.att.cdp.zones.ComputeService)

Example 8 with Volume

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

the class OpenStackServer method getAttachments.

/**
 * @see com.att.cdp.zones.spi.model.ConnectedServer#getAttachments()
 */
@Override
public Map<String, String> getAttachments() throws ZoneException {
    loadVolumeAttachments(getContext());
    Map<String, String> map = new HashMap<>();
    for (String device : getVolumes().keySet()) {
        Volume volume = getVolumes().get(device);
        map.put(device, volume.getId());
    }
    // return super.getAttachments();
    return map;
}
Also used : HashMap(java.util.HashMap) Volume(com.att.cdp.zones.model.Volume)

Example 9 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, "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) {
            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 10 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