use of com.linbit.linstor.api.model.VolumeDefinitionModify in project cloudstack by apache.
the class LinstorPrimaryDataStoreDriverImpl method resize.
@Override
public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
final VolumeObject vol = (VolumeObject) data;
final StoragePool pool = (StoragePool) data.getDataStore();
final DevelopersApi api = LinstorUtil.getLinstorAPI(pool.getHostAddress());
final ResizeVolumePayload resizeParameter = (ResizeVolumePayload) vol.getpayload();
final String rscName = LinstorUtil.RSC_PREFIX + vol.getPath();
final long oldSize = vol.getSize();
String errMsg = null;
VolumeDefinitionModify dfm = new VolumeDefinitionModify();
dfm.setSizeKib(resizeParameter.newSize / 1024);
try {
ApiCallRcList answers = api.volumeDefinitionModify(rscName, 0, dfm);
if (answers.hasError()) {
s_logger.error("Resize error: " + answers.get(0).getMessage());
errMsg = answers.get(0).getMessage();
} else {
s_logger.info(String.format("Successfully resized %s to %d kib", rscName, dfm.getSizeKib()));
vol.setSize(resizeParameter.newSize);
vol.update();
}
} catch (ApiException apiExc) {
s_logger.error(apiExc);
errMsg = apiExc.getBestMessage();
}
CreateCmdResult result;
if (errMsg != null) {
result = new CreateCmdResult(null, new Answer(null, false, errMsg));
result.setResult(errMsg);
} else {
// notify guests
result = notifyResize(data, oldSize, resizeParameter);
}
callback.complete(result);
}
Aggregations