use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class SmisStorageDevice method markSnapSessionsInactiveForReplicationGroup.
/**
* After clearing the snap session SFS entries in the SMI-S Provider for the replication group,
* mark the associated snap sessions inactive in database.
*
* @param storage
* the storage
* @param cg
* the consistency group
* @param rgName
* the replication group name
*/
private void markSnapSessionsInactiveForReplicationGroup(URI storage, URI cg, String rgName) {
List<BlockSnapshotSession> sessionsList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, AlternateIdConstraint.Factory.getSnapshotSessionReplicationGroupInstanceConstraint(rgName));
for (BlockSnapshotSession session : sessionsList) {
if (storage.toString().equals(session.getStorageController().toString()) && (cg != null && cg.toString().equals(session.getConsistencyGroup().toString()))) {
_log.info("Marking snap session in-active: {}", session.getLabel());
session.setInactive(true);
_dbClient.updateObject(session);
}
}
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class ControllerUtils method convertToRecordableBourneEvent.
/**
* Create a new instance of RecordableBourneEvent with the given resource
* and properties.
*
* @param resource
* - Type of Resource - File or Volume
* @param type
* - Event Type Enum
* @param description
* - Description of event if available
* @param extensions
* - Extensions mapped with Event Model Extensions
* @param eventServiceSource
* - URI of the Project
* @param dbClient
* - DBClient reference
* @param evtServiceType
* - Service Type
* @param recordType
* - Type of Indication
* @return RecordableBourneEvent
*/
public static RecordableBourneEvent convertToRecordableBourneEvent(DataObject resource, String type, String description, String extensions, DbClient dbClient, String evtServiceType, String recordType, String eventServiceSource) {
URI cos = null;
URI id = null;
String nativeGuid = null;
URI projectURI = null;
URI tenantURI = null;
RecordableBourneEvent event = null;
if (resource != null) {
if (resource instanceof Volume) {
Volume volume = (Volume) resource;
cos = volume.getVirtualPool();
id = volume.getId();
nativeGuid = volume.getNativeGuid();
projectURI = volume.getProject().getURI();
tenantURI = volume.getTenant().getURI();
} else if (resource instanceof FileShare) {
FileShare fs = (FileShare) resource;
cos = fs.getVirtualPool();
id = fs.getId();
nativeGuid = fs.getNativeGuid();
projectURI = (fs.getProject() != null) ? fs.getProject().getURI() : null;
tenantURI = (fs.getTenant() != null) ? fs.getTenant().getURI() : null;
} else if (resource instanceof VplexMirror) {
VplexMirror vplexMirror = (VplexMirror) resource;
cos = vplexMirror.getVirtualPool();
id = vplexMirror.getId();
projectURI = vplexMirror.getProject().getURI();
tenantURI = vplexMirror.getTenant().getURI();
} else if (resource instanceof BlockSnapshot) {
BlockSnapshot snapshot = (BlockSnapshot) resource;
try {
if (!NullColumnValueGetter.isNullNamedURI(snapshot.getParent())) {
Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
cos = volume.getVirtualPool();
tenantURI = (volume.getTenant() != null) ? volume.getTenant().getURI() : null;
}
id = snapshot.getId();
nativeGuid = snapshot.getNativeGuid();
projectURI = snapshot.getProject().getURI();
} catch (DatabaseException e) {
s_logger.error("Exception caught", e);
}
} else if (resource instanceof BlockSnapshotSession) {
BlockSnapshotSession session = (BlockSnapshotSession) resource;
try {
id = session.getId();
projectURI = session.getProject().getURI();
} catch (DatabaseException e) {
s_logger.error("Exception caught", e);
}
} else if (resource instanceof ExportGroup) {
ExportGroup exportGroup = (ExportGroup) resource;
try {
id = exportGroup.getId();
projectURI = exportGroup.getProject().getURI();
tenantURI = (exportGroup.getTenant() != null) ? exportGroup.getTenant().getURI() : null;
} catch (Exception e) {
s_logger.error("Exception caught", e);
}
} else if (resource instanceof FCZoneReference) {
FCZoneReference zone = (FCZoneReference) resource;
try {
id = zone.getId();
} catch (Exception e) {
s_logger.error("Exception caught", e);
}
} else if (resource instanceof Network) {
Network tz = (Network) resource;
id = tz.getId();
nativeGuid = tz.getNativeGuid();
} else if (resource instanceof BlockConsistencyGroup) {
BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) resource;
try {
id = consistencyGroup.getId();
projectURI = consistencyGroup.getProject().getURI();
tenantURI = (consistencyGroup.getTenant() != null) ? consistencyGroup.getTenant().getURI() : null;
} catch (Exception e) {
s_logger.error("Exception caught", e);
}
} else if (resource instanceof StoragePool) {
StoragePool sp = (StoragePool) resource;
id = sp.getId();
nativeGuid = sp.getNativeGuid();
} else {
s_logger.info("Error getting vpool,id,NativeGuid for event. Unexpected resource type {}.", resource.getClass().getName());
}
// TODO fix the bogus tenant, user ID once we have AuthZ working
if (tenantURI == null && projectURI != null) {
tenantURI = ControllerUtils.getProjectTenantOrgURI(dbClient, projectURI);
}
event = new RecordableBourneEvent(type, tenantURI, // user ID TODO when AAA
URI.create("ViPR-User"), // fixed
projectURI, cos, evtServiceType, id, description, System.currentTimeMillis(), extensions, nativeGuid, recordType, eventServiceSource, "", "");
}
return event;
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class BlockSnapshotSessionLinkTargetsWorkflowCompleter method complete.
/**
* {@inheritDoc}
*/
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
URI snapSessionURI = getId();
try {
BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
List<BlockObject> allSources = getAllSources(snapSession, dbClient);
BlockObject sourceObj = allSources.get(0);
// Record the results.
recordBlockSnapshotSessionOperation(dbClient, OperationTypeEnum.LINK_SNAPSHOT_SESSION_TARGET, status, snapSession, sourceObj);
// Update the status map of the snapshot session.
switch(status) {
case error:
// represented by the BlockSnapshotSession instance, mark them inactive.
for (List<URI> snapshotURIs : _snapshotURILists) {
for (URI snapshotURI : snapshotURIs) {
// Successfully linked targets will be in the list of linked
// targets for the session.
StringSet linkedTargets = snapSession.getLinkedTargets();
if ((linkedTargets == null) || (!linkedTargets.contains(snapshotURI.toString()))) {
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotURI);
// marked inactive, so be sure to check for null.
if ((snapshot != null) && (!snapshot.getInactive())) {
snapshot.setInactive(true);
dbClient.updateObject(snapshot);
}
}
}
}
setErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
break;
case ready:
setReadyOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
break;
case suspended_error:
setSuspendedErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
break;
case suspended_no_error:
setSuspendedNoErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
break;
default:
String errMsg = String.format("Unexpected status %s for completer for task %s", status.name(), getOpId());
s_logger.info(errMsg);
throw DeviceControllerException.exceptions.unexpectedCondition(errMsg);
}
s_logger.info("Done create and link new target volumes task {} with status: {}", getOpId(), status.name());
} catch (Exception e) {
s_logger.error("Failed updating status for create and link new target volumes task {}", getOpId(), e);
} finally {
super.complete(dbClient, status, coded);
}
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class BlockSnapshotSessionRelinkTargetsWorkflowCompleter method complete.
/**
* {@inheritDoc}
*/
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
URI tgtSnapSessionURI = getId();
try {
if (_updateOpStatus) {
// Update the status map of the snapshot session.
BlockSnapshotSession tgtSnapSession = dbClient.queryObject(BlockSnapshotSession.class, tgtSnapSessionURI);
List<BlockObject> allSources = getAllSources(tgtSnapSession, dbClient);
BlockObject sourceObj = allSources.get(0);
// Record the results.
recordBlockSnapshotSessionOperation(dbClient, OperationTypeEnum.RELINK_SNAPSHOT_SESSION_TARGET, status, tgtSnapSession, sourceObj);
switch(status) {
case error:
setErrorOnDataObject(dbClient, BlockSnapshotSession.class, tgtSnapSessionURI, coded);
break;
case ready:
setReadyOnDataObject(dbClient, BlockSnapshotSession.class, tgtSnapSessionURI);
break;
case suspended_error:
setSuspendedErrorOnDataObject(dbClient, BlockSnapshotSession.class, tgtSnapSessionURI, coded);
break;
case suspended_no_error:
setSuspendedNoErrorOnDataObject(dbClient, BlockSnapshotSession.class, tgtSnapSessionURI);
break;
default:
String errMsg = String.format("Unexpected status %s for completer for task %s", status.name(), getOpId());
s_logger.info(errMsg);
throw DeviceControllerException.exceptions.unexpectedCondition(errMsg);
}
}
s_logger.info("Done re-link target volumes task {} with status: {}", getOpId(), status.name());
} catch (Exception e) {
s_logger.error("Failed updating status for re-link target volumes task {}", getOpId(), e);
} finally {
super.complete(dbClient, status, coded);
}
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class BlockSnapshotSessionCreateWorkflowCompleter method complete.
/**
* {@inheritDoc}
*/
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
try {
BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, getId());
List<BlockObject> allSources = getAllSources(snapSession, dbClient);
// Record the results.
recordBlockSnapshotSessionOperation(dbClient, OperationTypeEnum.CREATE_SNAPSHOT_SESSION, status, snapSession, allSources.get(0));
// Update the status map of the snapshot session.
switch(status) {
case error:
// represented by the BlockSnapshotSession instance, mark them inactive.
for (List<URI> snapshotURIs : _sessionSnapshotURIs) {
for (URI snapshotURI : snapshotURIs) {
// Successfully linked targets will be in the list of linked
// targets for the session.
StringSet linkedTargets = snapSession.getLinkedTargets();
if ((linkedTargets == null) || (!linkedTargets.contains(snapshotURI.toString()))) {
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotURI);
// marked inactive, so be sure to check for null.
if ((snapshot != null) && (!snapshot.getInactive())) {
snapshot.setInactive(true);
dbClient.updateObject(snapshot);
}
}
}
}
setErrorOnDataObject(dbClient, BlockSnapshotSession.class, getId(), coded);
for (BlockObject source : allSources) {
setErrorOnDataObject(dbClient, URIUtil.getModelClass(source.getId()), source.getId(), coded);
}
break;
case ready:
setReadyOnDataObject(dbClient, BlockSnapshotSession.class, getId());
for (BlockObject source : allSources) {
setReadyOnDataObject(dbClient, URIUtil.getModelClass(source.getId()), source);
}
break;
case suspended_error:
setSuspendedErrorOnDataObject(dbClient, BlockSnapshotSession.class, getId(), coded);
for (BlockObject source : allSources) {
setSuspendedErrorOnDataObject(dbClient, URIUtil.getModelClass(source.getId()), source, coded);
}
break;
case suspended_no_error:
setSuspendedNoErrorOnDataObject(dbClient, BlockSnapshotSession.class, getId());
for (BlockObject source : allSources) {
setSuspendedNoErrorOnDataObject(dbClient, URIUtil.getModelClass(source.getId()), source);
}
break;
default:
String errMsg = String.format("Unexpected status %s for completer for task %s", status.name(), getOpId());
s_logger.info(errMsg);
throw DeviceControllerException.exceptions.unexpectedCondition(errMsg);
}
s_logger.info("Done snapshot session create task {} with status: {}", getOpId(), status.name());
} catch (Exception e) {
s_logger.error("Failed updating status for snapshot session create task {}", getOpId(), e);
} finally {
super.complete(dbClient, status, coded);
}
}
Aggregations