use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class CephStorageDevice method doDeleteVolumes.
@Override
public void doDeleteVolumes(StorageSystem storage, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
HashMap<URI, String> pools = new HashMap<URI, String>();
try (CephClient cephClient = getClient(storage)) {
for (Volume volume : volumes) {
if (volume.getNativeId() != null && !volume.getNativeId().isEmpty()) {
URI poolUri = volume.getPool();
String poolName = pools.get(poolUri);
if (poolName == null) {
StoragePool pool = _dbClient.queryObject(StoragePool.class, poolUri);
poolName = pool.getPoolName();
pools.put(poolUri, poolName);
}
cephClient.deleteImage(poolName, volume.getNativeId());
} else {
_log.info("Volume {} was not created completely, so skipping deletion from ceph array and just deleting from the controller's inventory", volume.getLabel());
}
volume.setInactive(true);
_dbClient.updateObject(volume);
}
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Error while deleting volumes", e);
ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("deleteVolume", e.getMessage());
taskCompleter.error(_dbClient, code);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class HDSProtectionOperations method deleteSecondaryVolumeSnapshot.
public void deleteSecondaryVolumeSnapshot(StorageSystem storageSystem, BlockSnapshot snapshotObj, TaskCompleter taskCompleter) throws Exception {
log.info("Snapshot deletion operation started");
String asyncTaskMessageId = null;
HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
String logicalUnitObjId = HDSUtils.getLogicalUnitObjectId(snapshotObj.getNativeId(), storageSystem);
asyncTaskMessageId = hdsApiClient.deleteSnapshotVolume(systemObjectID, logicalUnitObjId, storageSystem.getModel());
if (null != asyncTaskMessageId) {
HDSJob deleteSnapshotJob = new HDSDeleteSnapshotJob(asyncTaskMessageId, snapshotObj.getStorageController(), taskCompleter);
hdsCommandHelper.waitForAsyncHDSJob(deleteSnapshotJob);
log.info("Snapshot deletion operation completed successfully");
} else {
// This path should never be taken as the HDS client should always return
// the asynchronous task id. If it does not, this will be treated as an
// error.
log.error("Unexpected null asynchronous task id from HDS client call to delete volume snapshot.");
ServiceCoded sc = DeviceControllerExceptions.hds.nullAsyncTaskIdForDeleteSnapshot(snapshotObj.forDisplay());
taskCompleter.error(dbClient, sc);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class SRDFMirrorRollbackCompleter method logRollbackStatus.
/**
* Write a log message to help the user understand the potential state of a given
* source & target volume pair.
*
* @param source Source volume
* @param target Target volume
*/
private void logRollbackStatus(Volume source, Volume target) {
StringBuilder msg = new StringBuilder();
msg.append(String.format("Rollback of Source:%s, Target:%s for Task:%s ", source.getNativeGuid(), target.getNativeGuid(), getOpId()));
String key = rollbackStatusKey(source, target);
if (rollbackFailures.containsKey(key)) {
ServiceCoded coded = rollbackFailures.get(rollbackStatusKey(source, target));
msg.append(String.format("failed: %s\n%s.", coded, UNKNOWN_STATUS_MSG));
} else if (rollbackSuccesses.contains(key)) {
msg.append("complete.");
} else {
msg.append(String.format("did not occur. %s", UNKNOWN_STATUS_MSG));
}
log.info(msg.toString());
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class ScaleIOSnapshotOperations method deleteSingleVolumeSnapshot.
@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
BlockSnapshot blockSnapshot = dbClient.queryObject(BlockSnapshot.class, snapshot);
if (blockSnapshot != null && !blockSnapshot.getInactive() && // state against the BlockSnapshot object can be set.
!Strings.isNullOrEmpty(blockSnapshot.getNativeId())) {
scaleIOHandle.removeVolume(blockSnapshot.getNativeId());
}
if (blockSnapshot != null) {
blockSnapshot.setInactive(true);
dbClient.updateObject(blockSnapshot);
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, blockSnapshot);
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("deleteSingleVolumeSnapshot", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class ScaleIOStorageDevice method unmapVolumes.
/**
* Given a mapping of volumes and initiators, make the ScaleIO API calls to un-map the volume
* to the specified ScaleIO initiators
*
* @param storage
* [in] - StorageSystem object (ScaleIO array abstraction)
* @param volumeURIs
* [in] - Collection of Volume URIs
* @param initiators
* [in] - Collection of Initiator objects
* @param completer
* [in] - TaskCompleter
*/
private void unmapVolumes(StorageSystem storage, Collection<URI> volumeURIs, Collection<Initiator> initiators, TaskCompleter completer) {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
for (URI volumeURI : volumeURIs) {
BlockObject blockObject = BlockObject.fetch(dbClient, volumeURI);
if (blockObject == null || blockObject.getInactive()) {
log.warn(String.format("Attempted to unmap BlockObject %s, which was either not found in the DB or was inactive", volumeURI.toString()));
continue;
}
String nativeId = blockObject.getNativeId();
for (Initiator initiator : initiators) {
String port = initiator.getInitiatorPort();
boolean wasUnMapped = false;
if (initiator.getProtocol().equals(HostInterface.Protocol.ScaleIO.name())) {
wasUnMapped = unmapFromSDC(scaleIOHandle, nativeId, port, completer);
} else if (initiator.getProtocol().equals(HostInterface.Protocol.iSCSI.name())) {
wasUnMapped = unmapFromSCSI(scaleIOHandle, nativeId, port, initiator.getLabel(), completer);
} else {
ServiceCoded code = DeviceControllerErrors.scaleio.unmapVolumeToClientFailed(nativeId, port, String.format("Unexpected initiator type %s", initiator.getProtocol()));
completer.error(dbClient, code);
}
if (!wasUnMapped) {
// Failed to map the volume
return;
}
}
}
completer.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("unmapVolume", e.getMessage());
completer.error(dbClient, code);
}
}
Aggregations