Search in sources :

Example 31 with URIQueryResultList

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;
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 32 with URIQueryResultList

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;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 33 with URIQueryResultList

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);
        }
    }
}
Also used : WorkflowStep(com.emc.storageos.db.client.model.WorkflowStep) WorkflowException(com.emc.storageos.workflow.WorkflowException) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 34 with URIQueryResultList

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);
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 35 with URIQueryResultList

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;
}
Also used : URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)664 URI (java.net.URI)497 ArrayList (java.util.ArrayList)258 HashMap (java.util.HashMap)107 Volume (com.emc.storageos.db.client.model.Volume)97 NamedURI (com.emc.storageos.db.client.model.NamedURI)96 HashSet (java.util.HashSet)92 StoragePort (com.emc.storageos.db.client.model.StoragePort)91 StringSet (com.emc.storageos.db.client.model.StringSet)83 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)64 Produces (javax.ws.rs.Produces)55 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)54 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)54 Path (javax.ws.rs.Path)54 List (java.util.List)53 StoragePool (com.emc.storageos.db.client.model.StoragePool)49 Initiator (com.emc.storageos.db.client.model.Initiator)47 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)45 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)39 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)38