Search in sources :

Example 6 with ScaleIOVolume

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.

the class ScaleIORestClient method addVolume.

/**
 * Create a volume
 *
 * @param protectionDomainId The protection domain ID
 * @param storagePoolId The storage pool ID
 * @param volumeName The volume name
 * @param volumeSize The volume Size
 * @return The detail of the created volume
 * @throws Exception
 */
public ScaleIOVolume addVolume(String protectionDomainId, String storagePoolId, String volumeName, String volumeSize) throws Exception {
    ScaleIOCreateVolume volume = new ScaleIOCreateVolume();
    Long sizeInKb = Long.parseLong(volumeSize) / 1024L;
    volume.setVolumeSizeInKb(sizeInKb.toString());
    volume.setStoragePoolId(storagePoolId);
    volume.setName(volumeName);
    volume.setProtectionDomainId(protectionDomainId);
    ClientResponse response = post(URI.create(ScaleIOConstants.VOLUMES_URI), getJsonForEntity(volume));
    ScaleIOVolume createdVol = getResponseObject(ScaleIOVolume.class, response);
    return queryVolume(createdVol.getId());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume) ScaleIOCreateVolume(com.emc.storageos.scaleio.api.restapi.request.ScaleIOCreateVolume)

Example 7 with ScaleIOVolume

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.

the class ScaleIORestClientTest method testExpandVolume.

// @Test
public void testExpandVolume() {
    try {
        String volId = "537b69d70000003c";
        restClient.modifyVolumeCapacity(volId, "16");
        ScaleIOVolume vol = restClient.queryVolume(volId);
        String size = vol.getSizeInKb();
        Long sizeInGB = Long.parseLong(size) / 1024L / 1024L;
        System.out.println("size is :" + sizeInGB.toString());
    } catch (Exception e) {
        log.error("Exception: ", e);
    }
}
Also used : ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume)

Example 8 with ScaleIOVolume

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.

the class ScaleIORestClientTest method testAddVolume.

// @Test
public void testAddVolume() {
    try {
        ScaleIOVolume result = restClient.addVolume("a", "d924dfbf00000002", "volTest3", "1073741824", true);
        System.out.printf("created volume id: %s", result.getId());
    } catch (Exception e) {
        log.error("Exception: ", e);
        Assert.fail();
    }
}
Also used : ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume)

Example 9 with ScaleIOVolume

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.

the class ScaleIOCloneOperations method updateCloneFromQueryVolume.

private void updateCloneFromQueryVolume(ScaleIORestClient scaleIOHandle, Volume cloneObj) throws Exception {
    try {
        ScaleIOVolume vol = scaleIOHandle.queryVolume(cloneObj.getNativeId());
        long size = Long.parseLong(vol.getSizeInKb()) * 1024L;
        cloneObj.setAllocatedCapacity(size);
        cloneObj.setProvisionedCapacity(size);
    } catch (Exception e) {
        log.warn("Failed to update full copy {} with size information: {}", cloneObj.getId(), e.getMessage());
        throw e;
    }
}
Also used : ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume)

Example 10 with ScaleIOVolume

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.

the class ScaleIOStorageDevice method doExpandVolume.

@Override
public void doExpandVolume(StorageSystem storage, StoragePool pool, Volume volume, Long size, TaskCompleter taskCompleter) throws DeviceControllerException {
    Long volumeSize = size / ScaleIOHelper.BYTES_IN_GB;
    Long expandSize = volumeSize;
    // ScaleIO volume size has to be granularity of 8
    long remainder = volumeSize % 8;
    if (remainder != 0) {
        expandSize += (8 - remainder);
        log.info("The requested size is {} GB, increase it to {} GB, so that it is granularity of 8", volumeSize, expandSize);
    }
    try {
        ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
        ScaleIOVolume result = scaleIOHandle.modifyVolumeCapacity(volume.getNativeId(), expandSize.toString());
        long newSize = Long.parseLong(result.getSizeInKb()) * 1024L;
        volume.setProvisionedCapacity(newSize);
        volume.setAllocatedCapacity(newSize);
        volume.setCapacity(size);
        dbClient.persistObject(volume);
        ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
        pool.removeReservedCapacityForVolumes(Arrays.asList(volume.getId().toString()));
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        log.error("Encountered an exception", e);
        ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("expandVolume", e.getMessage());
        taskCompleter.error(dbClient, code);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) ScaleIOVolume(com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException)

Aggregations

ScaleIOVolume (com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume)11 ScaleIORestClient (com.emc.storageos.scaleio.api.restapi.ScaleIORestClient)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 ScaleIOException (com.emc.storageos.scaleio.ScaleIOException)3 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)3 URI (java.net.URI)3 HashMap (java.util.HashMap)3 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 Volume (com.emc.storageos.db.client.model.Volume)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ScaleIOCreateVolume (com.emc.storageos.scaleio.api.restapi.request.ScaleIOCreateVolume)2 ScaleIOVolumeList (com.emc.storageos.scaleio.api.restapi.request.ScaleIOVolumeList)2 HashSet (java.util.HashSet)2 ScaleIODataMapper (com.emc.storageos.api.mapper.ScaleIODataMapper)1 ScaleIOCollectDataParam (com.emc.storageos.model.collectdata.ScaleIOCollectDataParam)1 ScaleIODeviceDataRestRep (com.emc.storageos.model.collectdata.ScaleIODeviceDataRestRep)1 ScaleIOSDCDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSDCDataRestRep)1 ScaleIOSDSDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSDSDataRestRep)1 ScaleIOSystemDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSystemDataRestRep)1