use of com.emc.storageos.cinder.errorhandling.CinderException in project coprhd-controller by CoprHD.
the class CinderStorageDevice method doDeleteVolumes.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteVolumes
* (com.emc.storageos.db.client.model.StorageSystem,
* java.lang.String,
* java.util.List,
* com.emc.storageos.volumecontroller.TaskCompleter)
*/
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
List<String> volumeNativeIdsToDelete = new ArrayList<String>(volumes.size());
List<String> volumeLabels = new ArrayList<String>(volumes.size());
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getSerialNumber()));
log.info(logMsgBuilder.toString());
MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
log.info("Getting the cinder APi for the provider with id " + storageSystem.getActiveProviderURI());
CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
try {
// Check if the volume is present on the back-end device
cinderApi.showVolume(volume.getNativeId());
} catch (CinderException ce) {
// This means, the volume is not present on the back-end device
log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
volume.setInactive(true);
dbClient.persistObject(volume);
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
deleteTaskCompleter.ready(dbClient);
continue;
}
volumeNativeIdsToDelete.add(volume.getNativeId());
volumeLabels.add(volume.getLabel());
// cleanup if there are any snapshots created for a volume
cleanupAnyBackupSnapshots(volume, cinderApi);
}
// Now - trigger the delete
if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
cinderApi.deleteVolumes(volumeNativeIdsToDelete.toArray(new String[] {}));
ControllerServiceImpl.enqueueJob(new QueueJob(new CinderDeleteVolumeJob(volumeNativeIdsToDelete.get(0), volumeLabels.get(0), volumes.get(0).getStorageController(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter)));
} else {
// If we are here, there are no volumes to delete, we have
// invoked ready() for the VolumeDeleteCompleter, and told
// the multiVolumeTaskCompleter to skip these completers.
// In this case, the multiVolumeTaskCompleter complete()
// method will not be invoked and the result is that the
// workflow that initiated this delete request will never
// be updated. So, here we just call complete() on the
// multiVolumeTaskCompleter to ensure the workflow status is
// updated.
multiVolumeTaskCompleter.ready(dbClient);
}
} catch (Exception e) {
log.error("Problem in doDeleteVolume: ", e);
ServiceError error = DeviceControllerErrors.cinder.operationFailed("doDeleteVolume", e.getMessage());
taskCompleter.error(dbClient, error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getSerialNumber()));
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
}
log.info(logMsgBuilder.toString());
}
use of com.emc.storageos.cinder.errorhandling.CinderException in project coprhd-controller by CoprHD.
the class CinderStorageDevice method doDeleteSnapshot.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteSnapshot
* (com.emc.storageos.db.client.model.StorageSystem,
* java.net.URI, com.emc.storageos.volumecontroller.TaskCompleter)
*/
@Override
public void doDeleteSnapshot(StorageSystem storageSystem, URI snapshotURI, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Snapshot Start - Array:%s", storageSystem.getSerialNumber()));
log.info(logMsgBuilder.toString());
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotURI);
CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
log.info("Getting the cinder APi for the provider with id " + storageSystem.getActiveProviderURI());
CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
try {
cinderApi.showSnapshot(snapshot.getId().toString());
} catch (CinderException ce) {
// This means, the snapshot is not present on the back-end device
log.info(String.format("Snapshot %s already deleted: ", snapshot.getNativeId()));
snapshot.setInactive(true);
dbClient.updateObject(snapshot);
taskCompleter.ready(dbClient);
}
// Now - trigger the delete
cinderApi.deleteSnapshot(snapshot.getNativeId().toString());
ControllerServiceImpl.enqueueJob(new QueueJob(new CinderSnapshotDeleteJob(snapshot.getNativeId(), snapshot.getLabel(), storageSystem.getId(), CinderConstants.ComponentType.snapshot.name(), ep, taskCompleter)));
} catch (Exception e) {
log.error("Problem in doDeleteVolume: ", e);
ServiceError error = DeviceControllerErrors.cinder.operationFailed("doDeleteSnapshot", e.getMessage());
taskCompleter.error(dbClient, error);
}
}
use of com.emc.storageos.cinder.errorhandling.CinderException in project coprhd-controller by CoprHD.
the class CinderStorageDevice method doExpandVolume.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.BlockStorageDevice#doExpandVolume
* (com.emc.storageos.db.client.model.StorageSystem,
* com.emc.storageos.db.client.model.StoragePool,
* com.emc.storageos.db.client.model.Volume,
* java.lang.Long,
* com.emc.storageos.volumecontroller.TaskCompleter)
*/
@Override
public void doExpandVolume(StorageSystem storageSystem, StoragePool storagePool, Volume volume, Long size, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
log.info(String.format("Expand Volume Start - Array:%s, Pool:%s, Volume:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid(), volume.getId()));
CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
log.info("Getting the cinder APi for the provider with id " + storageSystem.getActiveProviderURI());
CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
String volumeId = volume.getNativeId();
if (null != volumeId) {
log.info("Expanding volume with the id " + volumeId + " on Openstack cinder node");
cinderApi.expandVolume(volumeId, CinderUtils.convertToGB(size));
CinderJob expandVolumeJob = new CinderVolumeExpandJob(volumeId, volume.getLabel(), volume.getStorageController(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter, storagePool.getId());
ControllerServiceImpl.enqueueJob(new QueueJob(expandVolumeJob));
}
log.info(String.format("Expand Volume End - Array:%s, Pool:%s, Volume:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid(), volume.getId()));
} catch (CinderException ce) {
String message = String.format("Exception when trying to expand volume on Array %s, Pool:%s, Volume:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid(), volume.getId());
log.error(message, ce);
ServiceError error = DeviceControllerErrors.cinder.operationFailed("doExpandVolume", ce.getMessage());
taskCompleter.error(dbClient, error);
} catch (final Exception e) {
log.error("Problem in doExpandVolume: ", e);
ServiceError serviceError = DeviceControllerErrors.cinder.operationFailed("doExpandVolume", e.getMessage());
taskCompleter.error(dbClient, serviceError);
}
}
Aggregations