Search in sources :

Example 31 with StringSet

use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.

the class VPlexUtil method getSharedExportMaskInDb.

/**
 * Returns the shared export mask in the export group i:e single ExportMask in database for multiple hosts
 * corresponding to the single storage view on VPLEX with multiple hosts.
 *
 * At-least there should be two host in the exportMask to be called as sharedExportMask. Also there shouldn't be more than one
 * exportMask for the exportGroup for a VPLEX cluster.
 *
 * Note : This is applicable from Darth release onwards.
 *
 * @param exportGroup ExportGroup object
 * @param vplexURI URI of the VPLEX system
 * @param dbClient database client instance
 * @param varrayUri Varray we want the Export Mask in
 * @param vplexCluster Vplex Cluster we want ExportMask for
 * @param hostInitiatorMap Map of host to initiators that are not yet added to the storage view on VPLEX
 * @return shared ExportMask for a exportGroup
 * @throws Exception
 */
public static ExportMask getSharedExportMaskInDb(ExportGroup exportGroup, URI vplexURI, DbClient dbClient, URI varrayUri, String vplexCluster, Map<URI, List<Initiator>> hostInitiatorMap) throws Exception {
    ExportMask sharedExportMask = null;
    if (exportGroup.getExportMasks() == null) {
        return null;
    }
    StringSet exportGrouphosts = exportGroup.getHosts();
    // Get all the exportMasks for the VPLEX from the export group
    List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(dbClient, exportGroup, vplexURI);
    // exportMasks list could have mask for both the VPLEX cluster for the same initiators for the cross-connect case
    // for the cross-connect case hence get the ExportMask for the specific VPLEX cluster.
    List<ExportMask> exportMasksForVplexCluster = getExportMasksForVplexCluster(vplexURI, dbClient, varrayUri, vplexCluster, exportMasks);
    // and we found only one exportMask in database for the VPLEX cluster
    if (exportGrouphosts != null && exportGrouphosts.size() > 1 && exportMasksForVplexCluster.size() == 1) {
        ExportMask exportMask = exportMasksForVplexCluster.get(0);
        ArrayList<String> exportMaskInitiators = new ArrayList<>(exportMask.getInitiators());
        Map<URI, List<Initiator>> exportMaskHostInitiatorsMap = makeHostInitiatorsMap(URIUtil.toURIList(exportMaskInitiators), dbClient);
        // Remove the host which is not yet added by CorpHD
        if (hostInitiatorMap != null) {
            for (Entry<URI, List<Initiator>> entry : hostInitiatorMap.entrySet()) {
                exportMaskHostInitiatorsMap.remove(entry.getKey());
            }
        }
        // If we found more than one host in the exportMask then its a sharedExportMask
        if (exportMaskHostInitiatorsMap.size() > 1) {
            sharedExportMask = exportMask;
        }
    }
    return sharedExportMask;
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URI(java.net.URI)

Example 32 with StringSet

use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method doFailBackMirrorSessionWF.

/**
 * Child Workflow for failback
 *
 * @param systemURI
 * @param fsURI source FS URI
 * @param taskId
 */
public void doFailBackMirrorSessionWF(URI systemURI, URI fsURI, String taskId) {
    TaskCompleter taskCompleter = null;
    String stepDescription;
    String stepId;
    Object[] args;
    try {
        FileShare sourceFS = s_dbClient.queryObject(FileShare.class, fsURI);
        StorageSystem primarysystem = s_dbClient.queryObject(StorageSystem.class, systemURI);
        StringSet targets = sourceFS.getMirrorfsTargets();
        List<URI> targetFSURI = new ArrayList<>();
        for (String target : targets) {
            targetFSURI.add(URI.create(target));
        }
        FileShare targetFS = s_dbClient.queryObject(FileShare.class, targetFSURI.get(0));
        StorageSystem secondarySystem = s_dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
        taskCompleter = new MirrorFileFailbackTaskCompleter(FileShare.class, sourceFS.getId(), taskId);
        Workflow workflow = _workflowService.getNewWorkflow(this, FAILBACK_FILE_SYSTEM_METHOD, false, taskId, taskCompleter);
        s_logger.info("Generating steps for failback to source file share: {} from target file share: {}", fsURI, targetFS.getId());
        /*
             * Step 1. Creates a mirror replication policy for the secondary cluster i.e Resync-prep on primary cluster , this will disable
             * primary cluster replication policy.
             */
        stepDescription = String.format("source resync-prep : creating mirror policy on target system: %s", secondarySystem.getId());
        stepId = workflow.createStepId();
        args = new Object[] { primarysystem.getId(), sourceFS.getId(), "resync" };
        String waitFor = _fileDeviceController.createMethod(workflow, null, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, primarysystem.getId(), args);
        /*
             * Step 2. Start the mirror replication policy manually, this will replicate new data (written during failover) from secondary
             * cluster to primary cluster.
             */
        stepDescription = String.format("start mirror policy: replicate target file share: %s, data to source file share:%s", targetFS.getId(), sourceFS.getId());
        stepId = workflow.createStepId();
        args = new Object[] { secondarySystem.getId(), targetFS.getId(), "start" };
        waitFor = _fileDeviceController.createMethod(workflow, waitFor, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, secondarySystem.getId(), args);
        /*
             * Step 3. Allow Write on Primary Cluster local target after replication from step 2
             * i.e Fail over to Primary Cluster
             */
        stepDescription = String.format("failover on source file system : allow write on source file share: %s", sourceFS.getId());
        stepId = workflow.createStepId();
        List<URI> combined = Arrays.asList(sourceFS.getId(), targetFS.getId());
        MirrorFileFailoverTaskCompleter failoverCompleter = new MirrorFileFailoverTaskCompleter(FileShare.class, combined, stepId);
        args = new Object[] { primarysystem.getId(), sourceFS.getId(), failoverCompleter };
        waitFor = _fileDeviceController.createMethod(workflow, waitFor, FAILOVER_FILE_SYSTEM_METHOD, stepId, stepDescription, primarysystem.getId(), args);
        /*
             * Step 4. Resync-Prep on secondary cluster , same as step 1 but will be executed on secondary cluster instead of primary
             * cluster.
             */
        stepDescription = String.format(" target resync-prep : disabling mirror policy on target system: %s", secondarySystem.getId());
        stepId = workflow.createStepId();
        args = new Object[] { secondarySystem.getId(), targetFS.getId(), "resync" };
        _fileDeviceController.createMethod(workflow, waitFor, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, secondarySystem.getId(), args);
        String successMsg = String.format("Failback of %s to %s successful", sourceFS.getId(), targetFS.getId());
        workflow.executePlan(taskCompleter, successMsg);
    } catch (Exception ex) {
        s_logger.error("Could not replicate source filesystem CIFS shares: " + fsURI, ex);
        String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILBACK.getName();
        ServiceError serviceError = DeviceControllerException.errors.createFileSharesFailed(fsURI.toString(), opName, ex);
        taskCompleter.error(s_dbClient, this._locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) ArrayList(java.util.ArrayList) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) StringSet(com.emc.storageos.db.client.model.StringSet) FileObject(com.emc.storageos.db.client.model.FileObject) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 33 with StringSet

use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method getProjectLevelPolices.

/**
 * Get the valid policy templates which are applied at project level
 *
 * @param vpool
 * @param project
 * @return list of project level policies on the given vpool
 */
private static List<FilePolicy> getProjectLevelPolices(VirtualPool vpool, Project project) {
    StringSet projectPolicies = project.getFilePolicies();
    List<FilePolicy> filePoliciesToCreate = new ArrayList<FilePolicy>();
    if (!CollectionUtils.isEmpty(projectPolicies)) {
        for (String projectFilePolicy : projectPolicies) {
            FilePolicy filePolicy = s_dbClient.queryObject(FilePolicy.class, URIUtil.uri(projectFilePolicy));
            if (filePolicy != null && !filePolicy.getInactive()) {
                // The policy should be of for the given vpool as well.
                if (NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool()) || !filePolicy.getFilePolicyVpool().toString().equals(vpool.getId().toString())) {
                    continue;
                }
                filePoliciesToCreate.add(filePolicy);
            }
        }
    }
    return filePoliciesToCreate;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList)

Example 34 with StringSet

use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.

the class FileOrchestrationUtils method getReplicationPolices.

/**
 * Gives list of replication policies assigned at vpool/project/fs levels
 *
 * @param dbClient
 * @param vpool
 * @param project
 * @param fs
 * @return
 */
public static List<FilePolicy> getReplicationPolices(DbClient dbClient, VirtualPool vpool, Project project, FileShare fs) {
    List<FilePolicy> replicationPolicies = new ArrayList<FilePolicy>();
    StringSet filePolicies = new StringSet();
    // vPool policies
    if (vpool.getFilePolicies() != null && !vpool.getFilePolicies().isEmpty()) {
        filePolicies.addAll(vpool.getFilePolicies());
    }
    // Project policies
    if (project.getFilePolicies() != null && !project.getFilePolicies().isEmpty()) {
        for (String strPolicy : project.getFilePolicies()) {
            FilePolicy policy = dbClient.queryObject(FilePolicy.class, URI.create(strPolicy));
            if (!NullColumnValueGetter.isNullURI(policy.getFilePolicyVpool()) && policy.getFilePolicyVpool().toString().equalsIgnoreCase(vpool.getId().toString())) {
                filePolicies.add(policy.getId().toString());
            }
        }
    }
    // fs policies
    if (fs != null && fs.getFilePolicies() != null && !fs.getFilePolicies().isEmpty()) {
        for (String strPolicy : fs.getFilePolicies()) {
            FilePolicy policy = dbClient.queryObject(FilePolicy.class, URI.create(strPolicy));
            if (!NullColumnValueGetter.isNullURI(policy.getFilePolicyVpool()) && policy.getFilePolicyVpool().toString().equalsIgnoreCase(vpool.getId().toString())) {
                filePolicies.add(policy.getId().toString());
            }
        }
    }
    if (filePolicies != null && !filePolicies.isEmpty()) {
        for (String strPolicy : filePolicies) {
            FilePolicy filePolicy = dbClient.queryObject(FilePolicy.class, URIUtil.uri(strPolicy));
            if (FilePolicyType.file_replication.name().equalsIgnoreCase(filePolicy.getFilePolicyType())) {
                replicationPolicies.add(filePolicy);
            }
        }
    } else {
        if (fs != null) {
            _log.info("No replication policy assigned to vpool {} , project {} and fs {}", vpool.getLabel(), project.getLabel(), fs.getLabel());
        } else {
            _log.info("No replication policy assigned to vpool {} and project {} ", vpool.getLabel(), project.getLabel());
        }
    }
    return replicationPolicies;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 35 with StringSet

use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.

the class FileOrchestrationUtils method getAllProjectLevelPolices.

/**
 * Return list of policies to be applied at project
 *
 * @param dbClient
 * @param project
 * @param storageSystem
 * @return
 */
public static List<FilePolicy> getAllProjectLevelPolices(DbClient dbClient, Project project, VirtualPool vpool, URI storageSystem, URI nasServer) {
    List<FilePolicy> filePoliciesToCreate = new ArrayList<FilePolicy>();
    StringSet fileProjectPolicies = project.getFilePolicies();
    if (fileProjectPolicies != null && !fileProjectPolicies.isEmpty()) {
        for (String fileProjectPolicy : fileProjectPolicies) {
            FilePolicy filePolicy = dbClient.queryObject(FilePolicy.class, URIUtil.uri(fileProjectPolicy));
            if (NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool()) || !filePolicy.getFilePolicyVpool().toString().equals(vpool.getId().toString())) {
                continue;
            }
            filePoliciesToCreate.add(filePolicy);
            StringSet policyStrRes = filePolicy.getPolicyStorageResources();
            if (policyStrRes != null && !policyStrRes.isEmpty()) {
                for (String policyStrRe : policyStrRes) {
                    PolicyStorageResource strRes = dbClient.queryObject(PolicyStorageResource.class, URIUtil.uri(policyStrRe));
                    if (strRes != null && strRes.getAppliedAt().toString().equals(project.getId().toString()) && strRes.getStorageSystem().toString().equals(storageSystem.toString()) && strRes.getNasServer().toString().equalsIgnoreCase(nasServer.toString())) {
                        _log.info("File Policy {} is already exists for project {} , storage system {} and nas server {}", filePolicy.getFilePolicyName(), project.getLabel(), storageSystem.toString(), strRes);
                        filePoliciesToCreate.remove(filePolicy);
                        break;
                    }
                }
            }
        }
    }
    return filePoliciesToCreate;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource)

Aggregations

StringSet (com.emc.storageos.db.client.model.StringSet)753 URI (java.net.URI)366 ArrayList (java.util.ArrayList)274 Volume (com.emc.storageos.db.client.model.Volume)189 NamedURI (com.emc.storageos.db.client.model.NamedURI)173 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)135 HashMap (java.util.HashMap)129 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)119 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)111 HashSet (java.util.HashSet)105 List (java.util.List)105 StoragePort (com.emc.storageos.db.client.model.StoragePort)86 StoragePool (com.emc.storageos.db.client.model.StoragePool)75 StringMap (com.emc.storageos.db.client.model.StringMap)72 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)71 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)70 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)55 Initiator (com.emc.storageos.db.client.model.Initiator)54 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)48 Map (java.util.Map)47