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());
}
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);
}
}
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();
}
}
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;
}
}
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);
}
}
Aggregations