Search in sources :

Example 26 with PolicyStorageResource

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

the class IsilonFileStorageDevice method getEquivalentPolicyStorageResource.

public static PolicyStorageResource getEquivalentPolicyStorageResource(FileShare fs, DbClient dbClient) {
    FilePolicy fp = getReplicationPolicyAppliedOnFS(fs, dbClient);
    if (fp != null) {
        StringSet policyStrResources = fp.getPolicyStorageResources();
        List<URI> policyStrURIs = new ArrayList<>();
        for (String policyStrResource : policyStrResources) {
            policyStrURIs.add(URI.create(policyStrResource));
        }
        Iterator<PolicyStorageResource> iterator = dbClient.queryIterativeObjects(PolicyStorageResource.class, policyStrURIs, true);
        while (iterator.hasNext()) {
            PolicyStorageResource policyRes = iterator.next();
            if (policyRes.getAppliedAt().equals(fs.getId()) && policyRes.getStorageSystem().equals(fs.getStorageDevice())) {
                _log.info("Found replication policy:{} corresponding storage resource: {}  applied to the file system: {}.", fp.getLabel(), policyRes.toString(), fs.getId());
                return policyRes;
            }
        }
    }
    return null;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource)

Example 27 with PolicyStorageResource

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

the class FileSystemReplicationUtils method getEquivalentPolicyStorageResource.

public static PolicyStorageResource getEquivalentPolicyStorageResource(FileShare fs, DbClient dbClient) {
    FilePolicy fp = getReplicationPolicyAppliedOnFS(fs, dbClient);
    if (fp != null) {
        StringSet policyStrResources = fp.getPolicyStorageResources();
        List<URI> policyStrURIs = new ArrayList<>();
        for (String policyStrResource : policyStrResources) {
            policyStrURIs.add(URI.create(policyStrResource));
        }
        Iterator<PolicyStorageResource> iterator = dbClient.queryIterativeObjects(PolicyStorageResource.class, policyStrURIs, true);
        while (iterator.hasNext()) {
            PolicyStorageResource policyRes = iterator.next();
            if (policyRes.getAppliedAt().equals(fs.getId()) && policyRes.getStorageSystem().equals(fs.getStorageDevice())) {
                return policyRes;
            }
        }
    }
    return null;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) URI(java.net.URI) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource)

Example 28 with PolicyStorageResource

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

the class FileMirrorScheduler method getRemoteMirrorRecommendationsForResources.

/* local mirror related functions */
/**
 * get list Recommendation for Local Mirror
 *
 * @param vArray
 * @param project
 * @param vPool
 * @param capabilities
 * @return
 */
public List getRemoteMirrorRecommendationsForResources(VirtualArray vArray, Project project, VirtualPool vPool, VirtualPoolCapabilityValuesWrapper capabilities) {
    List<FileRecommendation> targetFileRecommendations = null;
    List<FileMirrorRecommendation> fileMirrorRecommendations = new ArrayList<FileMirrorRecommendation>();
    // Get the source file system recommendations!!!
    capabilities.put(VirtualPoolCapabilityValuesWrapper.PERSONALITY, VirtualPoolCapabilityValuesWrapper.FILE_REPLICATION_SOURCE);
    // Verify the replication policy was applied!!
    // Get the policy storage resources for applied policy
    // Choose the right target for the source
    List<PolicyStorageResource> storageSystemResources = null;
    if (!capabilities.isVpoolProjectPolicyAssign()) {
        storageSystemResources = FileOrchestrationUtils.getFilePolicyStorageResources(_dbClient, vPool, project, null);
        if (storageSystemResources != null && !storageSystemResources.isEmpty()) {
            _log.info("Found replication policy for vpool and project, so get all source recommedation to match target");
            capabilities.put(VirtualPoolCapabilityValuesWrapper.GET_ALL_SOURCE_RECOMMENDATIONS, true);
        }
    }
    List<FileRecommendation> sourceFileRecommendations = new ArrayList<FileRecommendation>();
    // For vPool change get the recommendations from source file system!!!
    if (capabilities.createMirrorExistingFileSystem()) {
        sourceFileRecommendations = getFileRecommendationsForSourceFS(vArray, vPool, capabilities);
        // Remove the source file system from capabilities list
        // otherwise, try to find the remote pools from the same source system!!!
        capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.SOURCE_STORAGE_SYSTEM);
    } else {
        // Get the recommendation for source from vpool!!!
        sourceFileRecommendations = _fileScheduler.getRecommendationsForResources(vArray, project, vPool, capabilities);
        // otherwise, try to find the remote pools from the same source system!!!
        if (capabilities.getFileProtectionSourceStorageDevice() != null) {
            capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.FILE_PROTECTION_SOURCE_STORAGE_SYSTEM);
        }
    }
    if (capabilities.getAllSourceRecommnedations()) {
        capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.GET_ALL_SOURCE_RECOMMENDATIONS);
    }
    // Process the each recommendations for targets
    for (FileRecommendation sourceFileRecommendation : sourceFileRecommendations) {
        String srcSystemType = sourceFileRecommendation.getDeviceType();
        Set<String> systemTypes = new StringSet();
        systemTypes.add(srcSystemType);
        // Remove the existing source nas server if any!!
        if (capabilities.getSourceVirtualNasServer() != null) {
            capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.SOURCE_VIRTUAL_NAS_SERVER);
        }
        // add the new vnas server of current source recommendations!!!
        if (sourceFileRecommendation.getvNAS() != null) {
            capabilities.put(VirtualPoolCapabilityValuesWrapper.SOURCE_VIRTUAL_NAS_SERVER, sourceFileRecommendation.getvNAS());
        }
        // Findout is there any policy was created for the source recommendations!!!
        if (capabilities.getTargetNasServer() != null) {
            capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.TARGET_NAS_SERVER);
        }
        if (capabilities.getTargetStorageSystem() != null) {
            capabilities.removeCapabilityEntry(VirtualPoolCapabilityValuesWrapper.TARGET_STORAGE_SYSTEM);
        }
        if (storageSystemResources != null && !storageSystemResources.isEmpty()) {
            findAndUpdateMatchedPolicyStorageResource(storageSystemResources, sourceFileRecommendation, capabilities);
        }
        for (String targetVArry : capabilities.getFileReplicationTargetVArrays()) {
            // Process for target !!!
            FileMirrorRecommendation fileMirrorRecommendation = new FileMirrorRecommendation(sourceFileRecommendation);
            VirtualPool targetVPool = _dbClient.queryObject(VirtualPool.class, capabilities.getFileReplicationTargetVPool());
            VirtualArray targetVArray = _dbClient.queryObject(VirtualArray.class, URI.create(targetVArry));
            // Filter the target storage pools!!!
            Map<String, Object> attributeMap = new HashMap<String, Object>();
            attributeMap.put(Attributes.system_type.toString(), systemTypes);
            attributeMap.put(Attributes.remote_copy_mode.toString(), capabilities.getFileRpCopyMode());
            attributeMap.put(Attributes.source_storage_system.name(), sourceFileRecommendation.getSourceStorageSystem().toString());
            capabilities.put(VirtualPoolCapabilityValuesWrapper.PERSONALITY, VirtualPoolCapabilityValuesWrapper.FILE_REPLICATION_TARGET);
            // Get target recommendations!!!
            targetFileRecommendations = _fileScheduler.placeFileShare(targetVArray, targetVPool, capabilities, project, attributeMap);
            if (targetFileRecommendations == null || targetFileRecommendations.isEmpty()) {
                _log.info("No target recommendation found, so ignore the source recommedation as well.");
                continue;
            }
            String copyMode = capabilities.getFileRpCopyMode();
            if (targetFileRecommendations != null && !targetFileRecommendations.isEmpty()) {
                // prepare the target recommendation
                FileRecommendation targetRecommendation = targetFileRecommendations.get(0);
                prepareTargetFileRecommendation(copyMode, targetVArray, targetRecommendation, fileMirrorRecommendation);
                fileMirrorRecommendations.add(fileMirrorRecommendation);
            }
        }
        // Got sufficient number of recommendations!!
        if (!capabilities.isVpoolProjectPolicyAssign() && fileMirrorRecommendations.size() >= capabilities.getResourceCount()) {
            break;
        }
    }
    return fileMirrorRecommendations;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 29 with PolicyStorageResource

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

the class FileMirrorScheduler method findAndUpdateMatchedPolicyStorageResource.

private void findAndUpdateMatchedPolicyStorageResource(List<PolicyStorageResource> storageSystemResources, FileRecommendation sourceFileRecommendation, VirtualPoolCapabilityValuesWrapper capabilities) {
    PolicyStorageResource matchedPolicyResource = findMatchedPolicyStorageResource(storageSystemResources, sourceFileRecommendation);
    if (matchedPolicyResource != null) {
        _log.info("Found the valid existing policy storage resource for system {} nas server {}", matchedPolicyResource.getStorageSystem(), matchedPolicyResource.getNasServer());
        FileReplicaPolicyTargetMap targetMap = matchedPolicyResource.getFileReplicaPolicyTargetMap();
        if (targetMap != null && !targetMap.isEmpty()) {
            for (FileReplicaPolicyTarget target : targetMap.values()) {
                if (target.getNasServer() != null && target.getStorageSystem() != null) {
                    capabilities.put(VirtualPoolCapabilityValuesWrapper.TARGET_NAS_SERVER, URI.create(target.getNasServer()));
                    capabilities.put(VirtualPoolCapabilityValuesWrapper.TARGET_STORAGE_SYSTEM, URI.create(target.getStorageSystem()));
                    break;
                }
            }
        }
    }
    return;
}
Also used : FileReplicaPolicyTargetMap(com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap) FileReplicaPolicyTarget(com.emc.storageos.db.client.model.FileReplicaPolicyTarget) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource)

Aggregations

PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)29 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)14 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)11 ArrayList (java.util.ArrayList)11 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)8 FileShare (com.emc.storageos.db.client.model.FileShare)6 StringSet (com.emc.storageos.db.client.model.StringSet)6 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 NASServer (com.emc.storageos.db.client.model.NASServer)5 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)5 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)5 URI (java.net.URI)5 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 WorkflowException (com.emc.storageos.workflow.WorkflowException)4 FileReplicaPolicyTarget (com.emc.storageos.db.client.model.FileReplicaPolicyTarget)3 FileReplicaPolicyTargetMap (com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap)3