use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class CephSnapshotOperations method deleteSingleVolumeSnapshot.
@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try (CephClient cephClient = getClient(storage)) {
BlockSnapshot blockSnapshot = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume volume = _dbClient.queryObject(Volume.class, blockSnapshot.getParent().getURI());
StoragePool pool = _dbClient.queryObject(StoragePool.class, volume.getPool());
cephClient.deleteSnap(pool.getPoolName(), volume.getNativeId(), blockSnapshot.getNativeId());
blockSnapshot.setInactive(true);
_dbClient.updateObject(blockSnapshot);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Snapshot deletion failed", e);
ServiceError error = DeviceControllerErrors.ceph.operationFailed("deleteSingleVolumeSnapshot", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class CephStorageDevice method doCreateVolumes.
@Override
public void doCreateVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
try (CephClient cephClient = getClient(storage)) {
for (Volume volume : volumes) {
String id = CephUtils.createNativeId(volume);
cephClient.createImage(storagePool.getPoolName(), id, volume.getCapacity());
volume.setNativeId(id);
volume.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, volume));
volume.setDeviceLabel(volume.getLabel());
volume.setProvisionedCapacity(volume.getCapacity());
volume.setAllocatedCapacity(volume.getCapacity());
}
_dbClient.updateObject(volumes);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Error while creating volumes", e);
_dbClient.updateObject(volumes);
ServiceError error = DeviceControllerErrors.ceph.operationFailed("doCreateVolumes", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class CinderExportOperations method removeVolumes.
@Override
public void removeVolumes(StorageSystem storage, URI exportMaskId, List<URI> volumeURIs, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("{} removeVolumes START...", storage.getSerialNumber());
try {
log.info("removeVolumes: Export mask id: {}", exportMaskId);
log.info("removeVolumes: volumes: {}", Joiner.on(',').join(volumeURIs));
if (initiatorList != null) {
log.info("removeVolumes: impacted initiators: {}", Joiner.on(",").join(initiatorList));
}
ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskId);
List<Volume> volumes = new ArrayList<Volume>();
List<Initiator> userAddedInitiatorList = new ArrayList<Initiator>();
StringMap initiators = exportMask.getUserAddedInitiators();
for (URI volumeURI : volumeURIs) {
Volume volume = dbClient.queryObject(Volume.class, volumeURI);
volumes.add(volume);
}
for (String ini : initiators.values()) {
Initiator initiator = dbClient.queryObject(Initiator.class, URI.create(ini));
userAddedInitiatorList.add(initiator);
}
detachVolumesFromInitiators(storage, volumes, userAddedInitiatorList);
taskCompleter.ready(dbClient);
} catch (final Exception ex) {
log.error("Problem in RemoveVolumes: ", ex);
ServiceError serviceError = DeviceControllerErrors.cinder.operationFailed("doRemoveVolumes", ex.getMessage());
taskCompleter.error(dbClient, serviceError);
}
log.info("{} removeVolumes END...", storage.getSerialNumber());
}
use of com.emc.storageos.exceptions.DeviceControllerException 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.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method doRemoveFromConsistencyGroup.
@Override
public void doRemoveFromConsistencyGroup(StorageSystem storageSystem, URI consistencyGroupId, List<URI> blockObjects, TaskCompleter taskCompleter) throws DeviceControllerException {
BlockConsistencyGroup consistencyGroup = null;
try {
_log.info("{} doRemoveVolumesFromConsistencyGroup START ...", storageSystem.getSerialNumber());
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
List<Volume> volumes = dbClient.queryObject(Volume.class, blockObjects);
List<StorageVolume> driverVolumes = new ArrayList<>();
consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
for (Volume volume : volumes) {
StorageVolume driverVolume = new StorageVolume();
driverVolume.setStorageSystemId(storageSystem.getNativeId());
driverVolume.setNativeId(volume.getNativeId());
driverVolume.setRequestedCapacity(volume.getCapacity());
driverVolume.setThinlyProvisioned(volume.getThinlyProvisioned());
driverVolume.setConsistencyGroup(consistencyGroup.getNativeId());
driverVolume.setDisplayName(volume.getLabel());
// add them to StorageVolumes list
driverVolumes.add(driverVolume);
}
DriverTask task = driver.removeVolumesFromConsistencyGroup(driverVolumes, null);
_log.info("doRemoveVolumesFromConsistencyGroup -- removing volumes {} from consistency Group: {}", volumes.toString(), consistencyGroupId);
if (task.getStatus() == DriverTask.TaskStatus.READY) {
for (Volume volume : volumes) {
volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
}
dbClient.updateObject(volumes);
taskCompleter.ready(dbClient);
} else {
_log.error(String.format("Remove volumes from Consistency Group operation failed %s", task.getMessage()));
taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), task.getMessage()));
}
_log.info("{} doRemoveVolumesFromConsistencyGroup END ...", storageSystem.getSerialNumber());
} catch (Exception e) {
_log.error(String.format("Remove volumes from Consistency Group operation failed %s", e.getMessage()));
taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), e.getMessage()));
}
}
Aggregations