use of org.apache.cloudstack.storage.datastore.util.NexentaStorAppliance in project cloudstack by apache.
the class NexentaPrimaryDataStoreDriver method getNexentaStorAppliance.
private NexentaStorAppliance getNexentaStorAppliance(long storagePoolId) {
NexentaPluginParameters parameters = new NexentaPluginParameters();
parameters.setNmsUrl(_storagePoolDetailsDao.findDetail(storagePoolId, NexentaUtil.NMS_URL).getValue());
parameters.setVolume(_storagePoolDetailsDao.findDetail(storagePoolId, NexentaUtil.VOLUME).getValue());
parameters.setStorageType(_storagePoolDetailsDao.findDetail(storagePoolId, NexentaUtil.STORAGE_TYPE).getValue());
parameters.setStorageHost(_storagePoolDetailsDao.findDetail(storagePoolId, NexentaUtil.STORAGE_HOST).getValue());
parameters.setStoragePort(_storagePoolDetailsDao.findDetail(storagePoolId, NexentaUtil.STORAGE_PORT).getValue());
parameters.setStoragePath(_storagePoolDetailsDao.findDetail(storagePoolId, NexentaUtil.STORAGE_PATH).getValue());
parameters.setSparseVolumes(_storagePoolDetailsDao.findDetail(storagePoolId, NexentaUtil.SPARSE_VOLUMES).getValue());
parameters.setVolumeBlockSize(_storagePoolDetailsDao.findDetail(storagePoolId, NexentaUtil.VOLUME_BLOCK_SIZE).getValue());
return new NexentaStorAppliance(parameters);
}
use of org.apache.cloudstack.storage.datastore.util.NexentaStorAppliance in project cloudstack by apache.
the class NexentaPrimaryDataStoreDriver method createAsync.
@Override
public void createAsync(DataStore dataStore, DataObject dataObject, AsyncCompletionCallback<CreateCmdResult> callback) {
String iqn = null;
String errorMessage = null;
if (dataObject.getType() != DataObjectType.VOLUME) {
errorMessage = "Invalid DataObjectType (" + dataObject.getType() + ") passed to createAsync";
} else {
VolumeInfo volumeInfo = (VolumeInfo) dataObject;
long storagePoolId = dataStore.getId();
NexentaStorAppliance appliance = getNexentaStorAppliance(storagePoolId);
// TODO: maybe we should use md5(volume name) as volume name
NexentaStorZvol zvol = (NexentaStorZvol) appliance.createVolume(volumeInfo.getName(), volumeInfo.getSize());
iqn = zvol.getIqn();
VolumeVO volume = this._volumeDao.findById(volumeInfo.getId());
volume.set_iScsiName(iqn);
volume.setFolder(zvol.getName());
volume.setPoolType(Storage.StoragePoolType.IscsiLUN);
volume.setPoolId(storagePoolId);
_volumeDao.update(volume.getId(), volume);
StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId);
long capacityBytes = storagePool.getCapacityBytes();
long usedBytes = storagePool.getUsedBytes();
usedBytes += volumeInfo.getSize();
storagePool.setUsedBytes(usedBytes > capacityBytes ? capacityBytes : usedBytes);
_storagePoolDao.update(storagePoolId, storagePool);
}
CreateCmdResult result = new CreateCmdResult(iqn, new Answer(null, errorMessage == null, errorMessage));
result.setResult(errorMessage);
callback.complete(result);
}
use of org.apache.cloudstack.storage.datastore.util.NexentaStorAppliance in project cloudstack by apache.
the class NexentaPrimaryDataStoreDriver method deleteAsync.
@Override
public void deleteAsync(DataStore store, DataObject data, AsyncCompletionCallback<CommandResult> callback) {
String errorMessage = null;
if (data.getType() == DataObjectType.VOLUME) {
VolumeInfo volumeInfo = (VolumeInfo) data;
long storagePoolId = store.getId();
NexentaStorAppliance appliance = getNexentaStorAppliance(storagePoolId);
StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId);
// _storagePoolDao.update(stoagePoolId);
} else {
errorMessage = String.format("Invalid DataObjectType(%s) passed to deleteAsync", data.getType());
}
CommandResult result = new CommandResult();
result.setResult(errorMessage);
callback.complete(result);
}
Aggregations