Search in sources :

Example 1 with NexentaStorAppliance

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);
}
Also used : NexentaStorAppliance(org.apache.cloudstack.storage.datastore.util.NexentaStorAppliance) NexentaPluginParameters(org.apache.cloudstack.storage.datastore.util.NexentaUtil.NexentaPluginParameters)

Example 2 with NexentaStorAppliance

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);
}
Also used : NexentaStorZvol(org.apache.cloudstack.storage.datastore.util.NexentaStorAppliance.NexentaStorZvol) Answer(com.cloud.agent.api.Answer) VolumeVO(com.cloud.storage.VolumeVO) NexentaStorAppliance(org.apache.cloudstack.storage.datastore.util.NexentaStorAppliance) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) CreateCmdResult(org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult)

Example 3 with NexentaStorAppliance

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);
}
Also used : NexentaStorAppliance(org.apache.cloudstack.storage.datastore.util.NexentaStorAppliance) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) CommandResult(org.apache.cloudstack.storage.command.CommandResult) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult)

Aggregations

NexentaStorAppliance (org.apache.cloudstack.storage.datastore.util.NexentaStorAppliance)3 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)2 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)2 Answer (com.cloud.agent.api.Answer)1 VolumeVO (com.cloud.storage.VolumeVO)1 CopyCommandResult (org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult)1 CreateCmdResult (org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult)1 CommandResult (org.apache.cloudstack.storage.command.CommandResult)1 NexentaStorZvol (org.apache.cloudstack.storage.datastore.util.NexentaStorAppliance.NexentaStorZvol)1 NexentaPluginParameters (org.apache.cloudstack.storage.datastore.util.NexentaUtil.NexentaPluginParameters)1