Search in sources :

Example 11 with VpoolRemoteCopyProtectionSettings

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

the class SRDFScheduler method getMatchingPools.

/**
 * Gather matching pools for a collection of varrays
 *
 * @param varrays
 *            The target varrays
 * @param vpool
 *            the requested vpool that must be satisfied by the storage pool
 * @param capabilities
 *            capabilities
 * @param attributeMap
 *            attributeMap
 * @return A list of matching storage pools and varray mapping
 */
private Map<VirtualArray, List<StoragePool>> getMatchingPools(final List<VirtualArray> varrays, final VirtualPool vpool, final VirtualPoolCapabilityValuesWrapper capabilities, Map<String, Object> attributeMap) {
    Map<VirtualArray, List<StoragePool>> varrayStoragePoolMap = new HashMap<VirtualArray, List<StoragePool>>();
    Map<URI, VpoolRemoteCopyProtectionSettings> settingsMap = VirtualPool.getRemoteProtectionSettings(vpool, _dbClient);
    for (VirtualArray varray : varrays) {
        // If there was no vpool specified with the target settings, use the base vpool for this
        // varray.
        VirtualPool targetVpool = vpool;
        VpoolRemoteCopyProtectionSettings settings = settingsMap.get(varray.getId());
        if (settings != null && settings.getVirtualPool() != null) {
            targetVpool = _dbClient.queryObject(VirtualPool.class, settings.getVirtualPool());
        }
        capabilities.put(VirtualPoolCapabilityValuesWrapper.PERSONALITY, VirtualPoolCapabilityValuesWrapper.SRDF_TARGET);
        // Find a matching pool for the target vpool
        varrayStoragePoolMap.put(varray, _blockScheduler.getMatchingPools(varray, targetVpool, capabilities, attributeMap));
    }
    return varrayStoragePoolMap;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI)

Example 12 with VpoolRemoteCopyProtectionSettings

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

the class SRDFUtils method fetchSRDFTargetVirtualPools.

/**
 * Fetch the SRDF Protected target virtual pool uris.
 *
 * @return
 */
public static Set<URI> fetchSRDFTargetVirtualPools(DbClient dbClient) {
    Set<URI> srdfProtectedTargetVPools = new HashSet<URI>();
    try {
        List<URI> vpoolRemoteSettingURIs = dbClient.queryByType(VpoolRemoteCopyProtectionSettings.class, true);
        Iterator<VpoolRemoteCopyProtectionSettings> vPoolRemoteSettingsItr = dbClient.queryIterativeObjects(VpoolRemoteCopyProtectionSettings.class, vpoolRemoteSettingURIs, true);
        while (vPoolRemoteSettingsItr.hasNext()) {
            VpoolRemoteCopyProtectionSettings rSetting = vPoolRemoteSettingsItr.next();
            if (null != rSetting && !NullColumnValueGetter.isNullURI(rSetting.getVirtualPool())) {
                srdfProtectedTargetVPools.add(rSetting.getVirtualPool());
            }
        }
    } catch (Exception ex) {
        log.error("Exception occurred while fetching SRDF enabled virtualpools", ex);
    }
    return srdfProtectedTargetVPools;
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) URI(java.net.URI) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) WBEMException(javax.wbem.WBEMException) HashSet(java.util.HashSet)

Example 13 with VpoolRemoteCopyProtectionSettings

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

the class FileReplicationPolicyUpdateTargetPoolMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("File replication policy to update it's target pool in topology migration START");
    DbClient dbClient = getDbClient();
    try {
        List<URI> virtualPoolURIs = dbClient.queryByType(VirtualPool.class, true);
        Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolURIs, true);
        List<FileReplicationTopology> replPolicyTopologies = new ArrayList<FileReplicationTopology>();
        Map<String, FilePolicy> replicationPolicies = getRemoteReplicationPolicies();
        if (replicationPolicies.isEmpty()) {
            logger.info("No remote replication policies found in system... ");
            return;
        }
        // Update the target vpool in topology for that policy
        while (virtualPools.hasNext()) {
            VirtualPool virtualPool = virtualPools.next();
            if (VirtualPool.Type.file.name().equals(virtualPool.getType()) && virtualPool.getFileReplicationType() != null && FileReplicationType.REMOTE.name().equalsIgnoreCase(virtualPool.getFileReplicationType())) {
                logger.info("Getting replicaiton policies associated with vpool {} ", virtualPool.getLabel());
                // Get the existing replication policy
                // which was created with vpool name followed by _Replication_Policy
                String polName = virtualPool.getLabel() + "_Replication_Policy";
                FilePolicy replPolicy = replicationPolicies.get(polName);
                if (replPolicy != null) {
                    // Get the replication topologies for the policy!!
                    List<FileReplicationTopology> policyTopologies = queryDBReplicationTopologies(replPolicy);
                    if (policyTopologies != null && !policyTopologies.isEmpty()) {
                        // Get the target vpool from the vpool!
                        String targetVarray = null;
                        String targetVPool = null;
                        Map<URI, VpoolRemoteCopyProtectionSettings> remoteSettings = virtualPool.getFileRemoteProtectionSettings(virtualPool, dbClient);
                        if (remoteSettings != null && !remoteSettings.isEmpty()) {
                            // till now CoprHD supports only single target!!
                            for (Map.Entry<URI, VpoolRemoteCopyProtectionSettings> entry : remoteSettings.entrySet()) {
                                if (entry != null) {
                                    targetVarray = entry.getKey().toString();
                                    if (entry.getValue() != null && entry.getValue().getVirtualPool() != null) {
                                        targetVPool = entry.getValue().getVirtualPool().toString();
                                    }
                                    break;
                                }
                            }
                        }
                        for (FileReplicationTopology topology : policyTopologies) {
                            if (virtualPool.getVirtualArrays().contains(topology.getSourceVArray().toASCIIString()) && topology.getTargetVArrays().contains(targetVarray)) {
                                if (targetVarray != null && targetVPool != null) {
                                    topology.setTargetVAVPool(targetVarray + SEPARATOR + targetVPool);
                                    replPolicyTopologies.add(topology);
                                }
                            }
                        }
                    }
                } else {
                    logger.info("No remote replication policy with name {} ", polName);
                }
            }
        }
        // Udate DB
        if (!replPolicyTopologies.isEmpty()) {
            logger.info("Modified {} topologies ", replPolicyTopologies.size());
            dbClient.updateObject(replPolicyTopologies);
        }
    } catch (Exception ex) {
        logger.error("Exception occured while migrating file replication policy topology ");
        logger.error(ex.getMessage(), ex);
    }
    logger.info("File replication policy to update it's target pool in topology migration END");
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) DbClient(com.emc.storageos.db.client.DbClient) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) HashMap(java.util.HashMap) Map(java.util.Map) FileReplicationTopology(com.emc.storageos.db.client.model.FileReplicationTopology)

Example 14 with VpoolRemoteCopyProtectionSettings

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

the class ImplicitPoolMatcher method getRemoteProtectionSettings.

/**
 * Return the Remote protection setting objects associated with this virtual pool.
 *
 * @param vpool
 *            the virtual pool
 * @return a mapping of virtual arrays to the remote protection settings for that copy
 */
public static Map<String, List<VpoolRemoteCopyProtectionSettings>> getRemoteProtectionSettings(VirtualPool vpool, DbClient dbClient) {
    Map<String, List<VpoolRemoteCopyProtectionSettings>> settings = null;
    if (vpool.getProtectionRemoteCopySettings() != null) {
        settings = new HashMap<String, List<VpoolRemoteCopyProtectionSettings>>();
        for (String protectionVarray : vpool.getProtectionRemoteCopySettings().keySet()) {
            VpoolRemoteCopyProtectionSettings remoteSettings = dbClient.queryObject(VpoolRemoteCopyProtectionSettings.class, URI.create(vpool.getProtectionRemoteCopySettings().get(protectionVarray)));
            if (remoteSettings.getVirtualPool() == null) {
                _logger.info("NULL True");
            }
            String vPoolUri = null;
            if (remoteSettings.getVirtualPool() == null || remoteSettings.getVirtualPool().toString().isEmpty()) {
                vPoolUri = vpool.getId().toString();
            } else {
                vPoolUri = remoteSettings.getVirtualPool().toString();
            }
            if (null == settings.get(vPoolUri)) {
                settings.put(vPoolUri, new ArrayList<VpoolRemoteCopyProtectionSettings>());
            }
            settings.get(vPoolUri).add(remoteSettings);
        }
    }
    return settings;
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 15 with VpoolRemoteCopyProtectionSettings

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

the class VirtualPoolFileReplicationPolicyMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("File Virtual pool to file replication policy migration START");
    DbClient dbClient = getDbClient();
    try {
        List<URI> virtualPoolURIs = dbClient.queryByType(VirtualPool.class, true);
        Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolURIs, true);
        List<VirtualPool> modifiedVpools = new ArrayList<VirtualPool>();
        List<FilePolicy> replPolicies = new ArrayList<FilePolicy>();
        // Establish relation from policy to FilePolicyResource
        while (virtualPools.hasNext()) {
            VirtualPool virtualPool = virtualPools.next();
            if (VirtualPool.Type.file.name().equals(virtualPool.getType()) && virtualPool.getFileReplicationType() != null && !FileReplicationType.NONE.name().equalsIgnoreCase(virtualPool.getFileReplicationType())) {
                logger.info("vpool {} has enabled with replication, Creating appropriate file policy.....", virtualPool.getLabel());
                // Create replication policy
                FilePolicy replPolicy = new FilePolicy();
                replPolicy.setId(URIUtil.createId(FilePolicy.class));
                replPolicy.setFilePolicyDescription("Policy created from virtual pool " + virtualPool.getLabel() + " while system upgrade");
                String polName = virtualPool.getLabel() + "_Replication_Policy";
                replPolicy.setLabel(polName);
                replPolicy.setFilePolicyName(polName);
                replPolicy.setLabel(polName);
                replPolicy.setFilePolicyType(FilePolicyType.file_replication.name());
                replPolicy.setFilePolicyVpool(virtualPool.getId());
                // Replication policy was created always at file system level!!
                replPolicy.setApplyAt(FilePolicyApplyLevel.file_system.name());
                if (virtualPool.getFileReplicationCopyMode().equals(VirtualPool.RPCopyMode.ASYNCHRONOUS.name())) {
                    replPolicy.setFileReplicationCopyMode(FilePolicy.FileReplicationCopyMode.ASYNC.name());
                } else {
                    replPolicy.setFileReplicationCopyMode(FilePolicy.FileReplicationCopyMode.SYNC.name());
                }
                replPolicy.setFileReplicationType(virtualPool.getFileReplicationType());
                replPolicy.setPriority(FilePolicyPriority.Normal.toString());
                // Set the policy schedule based on vPool RPO
                if (virtualPool.getFrRpoValue() != null && virtualPool.getFrRpoType() != null) {
                    replPolicy.setScheduleRepeat((long) virtualPool.getFrRpoValue());
                    replPolicy.setScheduleTime("00:00AM");
                    replPolicy.setScheduleFrequency(virtualPool.getFrRpoType().toLowerCase());
                    // Virtual pool was supporting only Minutes/Hours/Days for RPO type
                    // Day of the week and month is not applicable!!
                    replPolicy.setScheduleDayOfWeek(NullColumnValueGetter.getNullStr());
                    replPolicy.setScheduleDayOfMonth(0L);
                }
                // set topology reference to policy
                if (FileReplicationType.REMOTE.name().equalsIgnoreCase(virtualPool.getFileReplicationType())) {
                    logger.info("Creating replication topology for remote replication vpool {} .....", virtualPool.getLabel());
                    StringSet replicationTopologies = new StringSet();
                    StringSet targetVarrays = new StringSet();
                    String targetVarray = null;
                    String targetVPool = null;
                    Map<URI, VpoolRemoteCopyProtectionSettings> remoteSettings = virtualPool.getFileRemoteProtectionSettings(virtualPool, dbClient);
                    if (remoteSettings != null && !remoteSettings.isEmpty()) {
                        for (Map.Entry<URI, VpoolRemoteCopyProtectionSettings> entry : remoteSettings.entrySet()) {
                            if (entry != null) {
                                targetVarray = entry.getKey().toString();
                                if (entry.getValue() != null && entry.getValue().getVirtualPool() != null) {
                                    targetVPool = entry.getValue().getVirtualPool().toString();
                                }
                                break;
                            }
                        }
                        if (targetVarray != null) {
                            targetVarrays.add(targetVarray);
                        }
                    }
                    if (virtualPool.getVirtualArrays() != null && !virtualPool.getVirtualArrays().isEmpty()) {
                        for (String srcvArray : virtualPool.getVirtualArrays()) {
                            FileReplicationTopology dbReplTopology = new FileReplicationTopology();
                            dbReplTopology.setId(URIUtil.createId(FileReplicationTopology.class));
                            dbReplTopology.setPolicy(replPolicy.getId());
                            dbReplTopology.setSourceVArray(URI.create(srcvArray));
                            dbReplTopology.setTargetVArrays(targetVarrays);
                            if (targetVarray != null && targetVPool != null) {
                                dbReplTopology.setTargetVAVPool(targetVarray + SEPARATOR + targetVPool);
                            }
                            dbClient.createObject(dbReplTopology);
                            replicationTopologies.add(dbReplTopology.getId().toString());
                        }
                        replPolicy.setReplicationTopologies(replicationTopologies);
                        logger.info("Created {} replication topologies from vpool {}", replicationTopologies.size(), virtualPool.getLabel().toString());
                    }
                }
                // Fetch if there are any file system were provisioned with the vpool
                // if present, link them to replication policy!!
                URIQueryResultList resultList = new URIQueryResultList();
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolFileshareConstraint(virtualPool.getId()), resultList);
                for (Iterator<URI> fileShareItr = resultList.iterator(); fileShareItr.hasNext(); ) {
                    FileShare fs = dbClient.queryObject(FileShare.class, fileShareItr.next());
                    if (!fs.getInactive() && fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.SOURCE.name())) {
                        StorageSystem system = dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
                        updatePolicyStorageResouce(system, replPolicy, fs);
                        fs.addFilePolicy(replPolicy.getId());
                        dbClient.updateObject(fs);
                    }
                }
                replPolicies.add(replPolicy);
                virtualPool.setAllowFilePolicyAtFSLevel(true);
                virtualPool.setFileReplicationSupported(true);
                modifiedVpools.add(virtualPool);
            }
        }
        // Udate DB
        if (!replPolicies.isEmpty()) {
            logger.info("Created {} replication policies ", replPolicies.size());
            dbClient.createObject(replPolicies);
        }
        if (!modifiedVpools.isEmpty()) {
            logger.info("Modified {} vpools ", modifiedVpools.size());
            dbClient.updateObject(modifiedVpools);
        }
    } catch (Exception ex) {
        logger.error("Exception occured while migrating file replication policy for Virtual pools");
        logger.error(ex.getMessage(), ex);
    }
    logger.info("Virtual pool file replication policy migration END");
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) DbClient(com.emc.storageos.db.client.DbClient) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) StringSet(com.emc.storageos.db.client.model.StringSet) Map(java.util.Map) FileReplicaPolicyTargetMap(com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap) FileReplicationTopology(com.emc.storageos.db.client.model.FileReplicationTopology) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

VpoolRemoteCopyProtectionSettings (com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings)32 URI (java.net.URI)29 ArrayList (java.util.ArrayList)21 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)20 StringSet (com.emc.storageos.db.client.model.StringSet)15 NamedURI (com.emc.storageos.db.client.model.NamedURI)14 List (java.util.List)13 StringMap (com.emc.storageos.db.client.model.StringMap)12 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)11 StoragePool (com.emc.storageos.db.client.model.StoragePool)9 Volume (com.emc.storageos.db.client.model.Volume)8 Recommendation (com.emc.storageos.volumecontroller.Recommendation)8 SRDFRecommendation (com.emc.storageos.volumecontroller.SRDFRecommendation)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)7 SRDFCopyRecommendation (com.emc.storageos.volumecontroller.SRDFCopyRecommendation)6 Network (com.emc.storageos.db.client.model.Network)5