use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class ControllerUtils method checkIfVolumeHasSnapshot.
public static boolean checkIfVolumeHasSnapshot(Volume volume, DbClient dbClient) {
URIQueryResultList list = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volume.getId()), list);
Iterator<URI> it = list.iterator();
while (it.hasNext()) {
URI snapshotID = it.next();
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotID);
if (snapshot != null & !snapshot.getInactive()) {
s_logger.debug("Volume {} has snapshot", volume.getId());
return true;
}
}
return false;
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class ControllerUtils method getMirrorsPartOfReplicationGroup.
/**
* Gets the mirrors part of a given replication group.
*/
public static List<BlockMirror> getMirrorsPartOfReplicationGroup(String replicationGroupInstance, DbClient dbClient) {
List<BlockMirror> mirrors = new ArrayList<BlockMirror>();
URIQueryResultList uriQueryResultList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getMirrorReplicationGroupInstanceConstraint(replicationGroupInstance), uriQueryResultList);
Iterator<BlockMirror> mirrorIterator = dbClient.queryIterativeObjects(BlockMirror.class, uriQueryResultList);
while (mirrorIterator.hasNext()) {
BlockMirror mirror = mirrorIterator.next();
if (mirror != null && !mirror.getInactive()) {
mirrors.add(mirror);
}
}
return mirrors;
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class ControllerWorkflowCleanupHandler method completeWorkflow.
private void completeWorkflow(URI workflowId) {
URIQueryResultList stepURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getWorkflowWorkflowStepConstraint(workflowId), stepURIs);
for (URI stepURI : stepURIs) {
WorkflowStep step = dbClient.queryObject(WorkflowStep.class, stepURI);
String state = step.getState();
List<String> activeStepStates = Arrays.asList(StepState.CREATED.toString(), StepState.BLOCKED.toString(), StepState.QUEUED.toString(), StepState.EXECUTING.toString());
if (activeStepStates.contains(state)) {
WorkflowException ex = WorkflowException.exceptions.workflowTerminatedForFailover(workflowId.toString());
log.info("Terminate workflow step {}", step.getId());
WorkflowService.completerStepErrorWithoutRollback(step.getStepId(), ex);
}
}
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class FileDeviceController method doDeleteSnapshotsFromDB.
private void doDeleteSnapshotsFromDB(FileShare fs, boolean allDirs, String subDir, FileDeviceInputOutput args) throws Exception {
_log.info(" Setting Snapshots to InActive with Force Delete ");
URIQueryResultList snapIDList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getFileshareSnapshotConstraint(fs.getId()), snapIDList);
_log.info("getSnapshots: FS {}: {} ", fs.getId().toString(), snapIDList.toString());
List<Snapshot> snapList = _dbClient.queryObject(Snapshot.class, snapIDList);
// Set this as snapshot operation to delete only snapshots.
args.setFileOperation(false);
if (snapList != null && !snapList.isEmpty()) {
for (Snapshot snapshot : snapList) {
_log.info("Marking Snapshot as InActive Snapshot Id {} Fs Id : {}", snapshot.getId(), snapshot.getParent());
snapshot.setInactive(true);
args.addSnapshot(snapshot);
doDeleteExportRulesFromDB(true, null, args);
deleteShareACLsFromDB(args);
_dbClient.updateObject(snapshot);
}
}
// restoring back
args.setFileOperation(true);
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class FileDeviceController method getExistingShareAclFromDB.
private CifsShareACL getExistingShareAclFromDB(CifsShareACL dbShareAcl, FileDeviceInputOutput args) {
CifsShareACL acl = null;
String index = null;
URIQueryResultList result = new URIQueryResultList();
if (args.getFileOperation()) {
index = dbShareAcl.getFileSystemShareACLIndex();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemShareACLConstraint(index), result);
} else {
index = dbShareAcl.getSnapshotShareACLIndex();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotShareACLConstraint(index), result);
}
Iterator<URI> it = result.iterator();
while (it.hasNext()) {
if (result.iterator().hasNext()) {
acl = _dbClient.queryObject(CifsShareACL.class, it.next());
if (acl != null && !acl.getInactive()) {
_log.info("Existing ACE found in DB: {}", acl);
return acl;
}
}
}
return null;
}
Aggregations