Search in sources :

Example 1 with GetCGsResponse

use of com.emc.storageos.recoverpoint.responses.GetCGsResponse in project coprhd-controller by CoprHD.

the class RPUnManagedObjectDiscoverer method discoverUnManagedObjects.

/**
 * Discovers the RP CGs and all the volumes therein. It updates/creates the UnManagedProtectionSet
 * objects and updates (if it exists) the UnManagedVolume objects with RP information needed for
 * ingestion
 *
 * @param accessProfile access profile
 * @param dbClient db client
 * @param partitionManager partition manager
 * @throws Exception
 */
public void discoverUnManagedObjects(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) throws Exception {
    this.partitionManager = partitionManager;
    log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
    ProtectionSystem protectionSystem = dbClient.queryObject(ProtectionSystem.class, accessProfile.getSystemId());
    if (protectionSystem == null) {
        log.error("Discovery is not run!  Protection System not found: " + accessProfile.getSystemId());
        return;
    }
    RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
    unManagedCGsInsert = new ArrayList<UnManagedProtectionSet>();
    unManagedCGsUpdate = new ArrayList<UnManagedProtectionSet>();
    unManagedVolumesToDelete = new ArrayList<UnManagedVolume>();
    unManagedVolumesToUpdateByWwn = new HashMap<String, UnManagedVolume>();
    unManagedCGsReturnedFromProvider = new HashSet<URI>();
    // Get all of the consistency groups (and their volumes) from RP
    Set<GetCGsResponse> cgs = rp.getAllCGs();
    if (cgs == null) {
        log.warn("No CGs were found on protection system: " + protectionSystem.getLabel());
        return;
    }
    // This section of code allows us to cache XIO native GUID to workaround an issue
    // with RP's understanding of XIO volume WWNs (128-bit) and the rest of the world's
    // understanding of the XIO volume WWN once it's exported (64-bit)
    Map<String, String> rpWwnToNativeWwn = new HashMap<String, String>();
    List<URI> storageSystemIds = dbClient.queryByType(StorageSystem.class, true);
    List<String> storageNativeIdPrefixes = new ArrayList<String>();
    if (storageSystemIds != null) {
        Iterator<StorageSystem> storageSystemsItr = dbClient.queryIterativeObjects(StorageSystem.class, storageSystemIds);
        while (storageSystemsItr.hasNext()) {
            StorageSystem storageSystem = storageSystemsItr.next();
            if (storageSystem.getSystemType().equalsIgnoreCase(Type.xtremio.name())) {
                storageNativeIdPrefixes.add(storageSystem.getNativeGuid());
            }
        }
    }
    for (GetCGsResponse cg : cgs) {
        try {
            log.info("Processing returned CG: " + cg.getCgName());
            boolean newCG = false;
            // UnManagedProtectionSet native GUID is protection system GUID + consistency group ID
            String nativeGuid = protectionSystem.getNativeGuid() + Constants.PLUS + cg.getCgId();
            // First check to see if this protection set is already part of our managed DB
            if (null != DiscoveryUtils.checkProtectionSetExistsInDB(dbClient, nativeGuid)) {
                log.info("Protection Set " + nativeGuid + " already is managed by ViPR, skipping unmanaged discovery");
                continue;
            }
            // Now check to see if the unmanaged CG exists in the database
            UnManagedProtectionSet unManagedProtectionSet = DiscoveryUtils.checkUnManagedProtectionSetExistsInDB(dbClient, nativeGuid);
            if (null == unManagedProtectionSet) {
                log.info("Creating new unmanaged protection set for CG: " + cg.getCgName());
                unManagedProtectionSet = new UnManagedProtectionSet();
                unManagedProtectionSet.setId(URIUtil.createId(UnManagedProtectionSet.class));
                unManagedProtectionSet.setNativeGuid(nativeGuid);
                unManagedProtectionSet.setProtectionSystemUri(protectionSystem.getId());
                StringSet protectionId = new StringSet();
                protectionId.add("" + cg.getCgId());
                unManagedProtectionSet.putCGInfo(SupportedCGInformation.PROTECTION_ID.toString(), protectionId);
                // Default MP to false until proven otherwise
                unManagedProtectionSet.getCGCharacteristics().put(UnManagedProtectionSet.SupportedCGCharacteristics.IS_MP.name(), Boolean.FALSE.toString());
                newCG = true;
            } else {
                log.info("Found existing unmanaged protection set for CG: " + cg.getCgName() + ", using " + unManagedProtectionSet.getId().toString());
            }
            unManagedCGsReturnedFromProvider.add(unManagedProtectionSet.getId());
            // Update the fields for the CG
            unManagedProtectionSet.setCgName(cg.getCgName());
            unManagedProtectionSet.setLabel(cg.getCgName());
            // Indicate whether the CG is in a healthy state or not to ingest.
            unManagedProtectionSet.getCGCharacteristics().put(UnManagedProtectionSet.SupportedCGCharacteristics.IS_HEALTHY.name(), cg.getCgState().equals(GetCGStateResponse.HEALTHY) ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
            // Indicate whether the CG is sync or async
            unManagedProtectionSet.getCGCharacteristics().put(UnManagedProtectionSet.SupportedCGCharacteristics.IS_SYNC.name(), cg.getCgPolicy().synchronous ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
            // Fill in RPO type and value information
            StringSet rpoType = new StringSet();
            rpoType.add(cg.getCgPolicy().rpoType);
            unManagedProtectionSet.putCGInfo(SupportedCGInformation.RPO_TYPE.toString(), rpoType);
            StringSet rpoValue = new StringSet();
            rpoValue.add(cg.getCgPolicy().rpoValue.toString());
            unManagedProtectionSet.putCGInfo(SupportedCGInformation.RPO_VALUE.toString(), rpoValue);
            if (null == cg.getCopies()) {
                log.info("Protection Set " + nativeGuid + " does not contain any copies.  Skipping...");
                continue;
            }
            if (null == cg.getRsets()) {
                log.info("Protection Set " + nativeGuid + " does not contain any replication sets.  Skipping...");
                continue;
            }
            // clean up the existing journal and replicationsets info in the unmanaged protection set, so that updated info is populated
            if (!newCG) {
                cleanUpUnManagedResources(unManagedProtectionSet, unManagedVolumesToUpdateByWwn, dbClient);
            }
            // Now map UnManagedVolume objects to the journal and rset (sources/targets) and put RP fields in them
            Map<String, String> rpCopyAccessStateMap = new HashMap<String, String>();
            mapCgJournals(unManagedProtectionSet, cg, rpCopyAccessStateMap, rpWwnToNativeWwn, storageNativeIdPrefixes, dbClient);
            mapCgSourceAndTargets(unManagedProtectionSet, cg, rpCopyAccessStateMap, rpWwnToNativeWwn, storageNativeIdPrefixes, dbClient);
            if (newCG) {
                unManagedCGsInsert.add(unManagedProtectionSet);
            } else {
                unManagedCGsUpdate.add(unManagedProtectionSet);
            }
        } catch (Exception ex) {
            log.error("Error processing RP CG {}", cg.getCgName(), ex);
        }
    }
    handlePersistence(dbClient, false);
    cleanUp(protectionSystem, dbClient);
}
Also used : GetCGsResponse(com.emc.storageos.recoverpoint.responses.GetCGsResponse) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) URI(java.net.URI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) StringSet(com.emc.storageos.db.client.model.StringSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with GetCGsResponse

use of com.emc.storageos.recoverpoint.responses.GetCGsResponse in project coprhd-controller by CoprHD.

the class RecoverPointClient method getAllCGs.

/**
 * Returns all CGs, policies, and volumes within the CG.
 *
 * @return a set of RP consistency group objects
 * @throws RecoverPointException
 */
public Set<GetCGsResponse> getAllCGs() throws RecoverPointException {
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    // TODO: Refactor to break down into smaller pieces
    Set<GetCGsResponse> cgs = new HashSet<GetCGsResponse>();
    try {
        // Quickly get a map of cluster/sitenames
        Map<Long, String> clusterIdToInternalSiteNameMap = new HashMap<Long, String>();
        FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
        for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
            clusterIdToInternalSiteNameMap.put(siteSettings.getCluster().getId(), siteSettings.getInternalClusterName());
        }
        // Go through all of the CGs and retrieve important pieces of information
        List<ConsistencyGroupUID> allCgs = functionalAPI.getAllConsistencyGroups();
        for (ConsistencyGroupUID cg : allCgs) {
            ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
            ConsistencyGroupState state = functionalAPI.getGroupState(cg);
            logger.info("Processing CG found on RecoverPoint system: " + settings.getName());
            // First storage attributes about the top-level CG
            GetCGsResponse cgResp = new GetCGsResponse();
            cgResp.setCgName(settings.getName());
            cgResp.setCgId(cg.getId());
            cgResp.setCgPolicy(new GetCGsResponse.GetPolicyResponse());
            // Find and store the policy information
            if (settings.getActiveLinksSettings() != null) {
                for (ConsistencyGroupLinkSettings cgls : settings.getActiveLinksSettings()) {
                    if (cgls.getLinkPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy() != null) {
                        if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType() != null) {
                            if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType().toString().equalsIgnoreCase(ProtectionMode.SYNCHRONOUS.toString())) {
                                cgResp.getCgPolicy().synchronous = true;
                            } else {
                                cgResp.getCgPolicy().synchronous = false;
                            }
                        }
                        if (cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag() != null) {
                            cgResp.getCgPolicy().rpoType = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getType().name();
                            cgResp.getCgPolicy().rpoValue = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getValue();
                        }
                    }
                }
            }
            // We assume CG health until we see something that indicates otherwise.
            cgResp.setCgState(GetCGsResponse.GetCGStateResponse.HEALTHY);
            RecoverPointCGState cgState = this.getCGState(cg);
            if (cgState.equals(RecoverPointCGState.DELETED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_ERROR);
            } else if (cgState.equals(RecoverPointCGState.MIXED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
            } else if (cgState.equals(RecoverPointCGState.PAUSED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
            } else if (cgState.equals(RecoverPointCGState.STOPPED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
            }
            // Fill in the Copy information
            if (settings.getGroupCopiesSettings() == null) {
                continue;
            }
            Map<String, String> copyUIDToNameMap = new HashMap<String, String>();
            Map<String, String> copyNameToRoleMap = new HashMap<String, String>();
            // used to set the copy uid on the rset volume when adding rsets
            Set<String> productionCopiesUID = new HashSet<String>();
            // Retrieve all RP copies for this CG
            for (ConsistencyGroupCopySettings copySettings : settings.getGroupCopiesSettings()) {
                GetCopyResponse copy = new GetCopyResponse();
                copy.setName(copySettings.getName());
                String copyID = copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + copySettings.getCopyUID().getGlobalCopyUID().getCopyUID();
                copyUIDToNameMap.put(copyID, copySettings.getName());
                for (ConsistencyGroupCopyState copyState : state.getGroupCopiesStates()) {
                    if (!RecoverPointUtils.copiesEqual(copySettings.getCopyUID(), copyState.getCopyUID())) {
                        continue;
                    }
                    // Get the access image and enabled information
                    copy.setAccessState(copyState.getStorageAccessState().toString());
                    copy.setAccessedImage(copyState.getAccessedImage() != null ? copyState.getAccessedImage().getDescription() : null);
                    copy.setEnabled(copyState.isEnabled());
                    copy.setActive(copyState.isActive());
                }
                // Set ID fields (these are immutable no matter if things are renamed)
                copy.setCgId(copySettings.getCopyUID().getGroupUID().getId());
                copy.setClusterId(copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId());
                copy.setCopyId(copySettings.getCopyUID().getGlobalCopyUID().getCopyUID());
                if (ConsistencyGroupCopyRole.ACTIVE.equals(copySettings.getRoleInfo().getRole()) || ConsistencyGroupCopyRole.TEMPORARY_ACTIVE.equals(copySettings.getRoleInfo().getRole())) {
                    productionCopiesUID.add(copyID);
                    copy.setProduction(true);
                    // Standby Production role is defined as: copy is production and copy is NOT active.
                    if (copy.isActive()) {
                        copy.setRole(GetCopyResponse.GetCopyRole.ACTIVE_PRODUCTION);
                    } else {
                        copy.setRole(GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION);
                    }
                } else if (ConsistencyGroupCopyRole.REPLICA.equals(copySettings.getRoleInfo().getRole())) {
                    copy.setProduction(false);
                    copy.setRole(GetCopyResponse.GetCopyRole.TARGET);
                } else {
                    copy.setProduction(false);
                    copy.setRole(GetCopyResponse.GetCopyRole.UNKNOWN);
                }
                // Add an entry for this copy name and its defined role
                copyNameToRoleMap.put(copy.getName(), copy.getRole().toString());
                if (copySettings.getJournal() == null || copySettings.getJournal().getJournalVolumes() == null) {
                    continue;
                }
                for (JournalVolumeSettings journal : copySettings.getJournal().getJournalVolumes()) {
                    GetVolumeResponse volume = new GetVolumeResponse();
                    volume.setRpCopyName(copySettings.getName());
                    volume.setInternalSiteName(clusterIdToInternalSiteNameMap.get(journal.getClusterUID().getId()));
                    // Need to extract the naaUids to format: 600601608D20370089260942815CE511
                    volume.setWwn(RecoverPointUtils.getGuidBufferAsString(journal.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
                    if (copy.getJournals() == null) {
                        copy.setJournals(new ArrayList<GetVolumeResponse>());
                    }
                    copy.getJournals().add(volume);
                }
                if (cgResp.getCopies() == null) {
                    cgResp.setCopies(new ArrayList<GetCopyResponse>());
                }
                cgResp.getCopies().add(copy);
            }
            // Retrieve all replication sets for this CG
            for (ReplicationSetSettings rsetSettings : settings.getReplicationSetsSettings()) {
                GetRSetResponse rset = new GetRSetResponse();
                rset.setName(rsetSettings.getReplicationSetName());
                if (rsetSettings.getVolumes() == null) {
                    continue;
                }
                for (UserVolumeSettings volume : rsetSettings.getVolumes()) {
                    GetVolumeResponse volResp = new GetVolumeResponse();
                    // Get the RP copy name, needed to match up sources to targets
                    String copyID = volume.getGroupCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + volume.getGroupCopyUID().getGlobalCopyUID().getCopyUID();
                    volResp.setRpCopyName(copyUIDToNameMap.get(copyID));
                    volResp.setInternalSiteName(clusterIdToInternalSiteNameMap.get(volume.getClusterUID().getId()));
                    if (productionCopiesUID.contains(copyID)) {
                        volResp.setProduction(true);
                        // volumes copy name to role mapping that was populated earlier.
                        if (GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION.toString().equalsIgnoreCase(copyNameToRoleMap.get(volResp.getRpCopyName()))) {
                            volResp.setProductionStandby(true);
                        }
                    } else {
                        volResp.setProduction(false);
                    }
                    // Need to extract the naaUids to format: 600601608D20370089260942815CE511
                    volResp.setWwn(RecoverPointUtils.getGuidBufferAsString(volume.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
                    if (rset.getVolumes() == null) {
                        rset.setVolumes(new ArrayList<GetVolumeResponse>());
                    }
                    rset.getVolumes().add(volResp);
                }
                if (cgResp.getRsets() == null) {
                    cgResp.setRsets(new ArrayList<GetRSetResponse>());
                }
                cgResp.getRsets().add(rset);
            }
            cgs.add(cgResp);
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.failedToLookupConsistencyGroups(getCause(e));
    }
    return cgs;
}
Also used : GetCGsResponse(com.emc.storageos.recoverpoint.responses.GetCGsResponse) GetCopyResponse(com.emc.storageos.recoverpoint.responses.GetCopyResponse) UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) HashMap(java.util.HashMap) ClusterConfiguration(com.emc.fapiclient.ws.ClusterConfiguration) GetRSetResponse(com.emc.storageos.recoverpoint.responses.GetRSetResponse) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) HashSet(java.util.HashSet) JournalVolumeSettings(com.emc.fapiclient.ws.JournalVolumeSettings) GetVolumeResponse(com.emc.storageos.recoverpoint.responses.GetVolumeResponse) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) FullRecoverPointSettings(com.emc.fapiclient.ws.FullRecoverPointSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException)

Example 3 with GetCGsResponse

use of com.emc.storageos.recoverpoint.responses.GetCGsResponse in project coprhd-controller by CoprHD.

the class RecoverPointClientIntegrationTest method testGetAllCGs.

@Test
public void testGetAllCGs() {
    logger.info("Testing RecoverPoint CG Retrieval");
    Set<GetCGsResponse> cgs;
    try {
        cgs = rpClient.getAllCGs();
        Set<String> wwns = new HashSet<String>();
        for (GetCGsResponse cg : cgs) {
            logger.info("CG: " + cg);
            assertNotNull(cg.getCgName());
            assertNotNull(cg.getCgId());
            // Make sure certain fields are filled-in
            if (cg.getCopies() != null) {
                for (GetCopyResponse copy : cg.getCopies()) {
                    assertNotNull(copy.getJournals());
                    assertNotNull(copy.getName());
                    for (GetVolumeResponse volume : copy.getJournals()) {
                        assertNotNull(volume.getInternalSiteName());
                        assertNotNull(volume.getRpCopyName());
                        assertNotNull(volume.getWwn());
                        // Make sure the same volume isn't in more than one place in the list.
                        assertFalse(wwns.contains(volume.getWwn()));
                        wwns.add(volume.getWwn());
                    }
                }
            }
            if (cg.getRsets() != null) {
                for (GetRSetResponse rset : cg.getRsets()) {
                    assertNotNull(rset.getName());
                    assertNotNull(rset.getVolumes());
                    for (GetVolumeResponse volume : rset.getVolumes()) {
                        assertNotNull(volume.getInternalSiteName());
                        assertNotNull(volume.getRpCopyName());
                        assertNotNull(volume.getWwn());
                        // Make sure the same volume isn't in more than one place in the list.
                        assertFalse(wwns.contains(volume.getWwn()));
                        wwns.add(volume.getWwn());
                    }
                }
            }
        // Make sure you have journals, sources, and targets
        }
    } catch (RecoverPointException e) {
        fail(e.getMessage());
    }
}
Also used : GetCGsResponse(com.emc.storageos.recoverpoint.responses.GetCGsResponse) GetCopyResponse(com.emc.storageos.recoverpoint.responses.GetCopyResponse) GetRSetResponse(com.emc.storageos.recoverpoint.responses.GetRSetResponse) GetVolumeResponse(com.emc.storageos.recoverpoint.responses.GetVolumeResponse) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with GetCGsResponse

use of com.emc.storageos.recoverpoint.responses.GetCGsResponse in project coprhd-controller by CoprHD.

the class RPHelper method validateCGForDelete.

/**
 * Validate the CG before performing destructive operations.
 * If additional volumes appear in the RP CG on the hardware, this method returns false
 * Clerical errors (such as missing DB entries) result in an Exception
 *
 * @param dbClient
 *            dbclient
 * @param system
 *            protection system
 * @param cgId
 *            BlockConsistencyGroup ID
 * @param volumes
 *            list of volumes
 * @return true if CG is what we expect on the hardware, false otherwise
 */
public static boolean validateCGForDelete(DbClient dbClient, ProtectionSystem system, URI cgId, Set<URI> volumes) {
    _log.info("validateCGForDelete {} - start", system.getId());
    // Retrieve all of the RP CGs, their RSets, and their volumes
    RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
    Set<GetCGsResponse> cgList = rp.getAllCGs();
    if (cgList == null || cgList.isEmpty()) {
        String errMsg = "Could not retrieve CGs from the RPA to perform validation.";
        throw DeviceControllerExceptions.recoverpoint.unableToPerformValidation(errMsg);
    }
    // Grab all of the source volumes from the CG according to ViPR
    List<Volume> srcVolumes = RPHelper.getCgVolumes(dbClient, cgId, PersonalityTypes.SOURCE.toString());
    if (srcVolumes == null || srcVolumes.isEmpty()) {
        String errMsg = "Could not retrieve volumes from the database for CG to perform validation";
        throw DeviceControllerExceptions.recoverpoint.unableToPerformValidation(errMsg);
    }
    // Get the protection set ID from the first source volume. All volumes will have the same pset ID.
    URI psetId = srcVolumes.get(0).getProtectionSet().getURI();
    if (NullColumnValueGetter.isNullURI(psetId)) {
        String errMsg = "Could not retrieve protection set ID from the database for CG to perform validation";
        throw DeviceControllerExceptions.recoverpoint.unableToPerformValidation(errMsg);
    }
    // Get the protection set, which is required to get the CG ID on the RPA
    ProtectionSet pset = dbClient.queryObject(ProtectionSet.class, psetId);
    if (pset == null) {
        String errMsg = "Could not retrieve protection set from the database for CG to perform validation";
        throw DeviceControllerExceptions.recoverpoint.unableToPerformValidation(errMsg);
    }
    // Pre-populate the wwn fields for comparisons later.
    List<String> srcVolumeWwns = new ArrayList<>();
    for (Volume srcVolume : srcVolumes) {
        srcVolumeWwns.add(srcVolume.getWWN());
    }
    // This loop finds the CG on the hardware from the list of all CGs. Ignores all CGs that don't match our ID.
    for (GetCGsResponse cgResponse : cgList) {
        // Compare the stored CG ID (unique per RP System, doesn't change even if CG name changes)
        if (Long.parseLong(pset.getProtectionId()) != cgResponse.getCgId()) {
            continue;
        }
        // Make sure we have rsets before we continue. If the CG has no RSets on the hardware, throw
        if (cgResponse.getRsets() == null || cgResponse.getRsets().isEmpty()) {
            String errMsg = "Could not retrieve replication sets from the hardware to perform validation";
            throw DeviceControllerExceptions.recoverpoint.unableToPerformValidation(errMsg);
        }
        // Find one of our volumes
        for (GetRSetResponse rsetResponse : cgResponse.getRsets()) {
            // Make sure we have volumes in the RSet before we continue
            if (rsetResponse == null || rsetResponse.getVolumes() == null || rsetResponse.getVolumes().isEmpty()) {
                String errMsg = "Could not retrieve the volumes in the replication set from the hardware to perform validation";
                throw DeviceControllerExceptions.recoverpoint.unableToPerformValidation(errMsg);
            }
            // list of WWNs is the list of source volumes we know about.
            for (GetVolumeResponse volumeResponse : rsetResponse.getVolumes()) {
                // This hardware volume should be represented in the list of srcVolumes
                if (!srcVolumeWwns.contains(volumeResponse.getWwn())) {
                    _log.warn("Found at least one volume that isn't in our list of source volumes {}, therefore we can not delete the entire CG.", volumeResponse.getWwn());
                    return false;
                }
            }
        }
    }
    _log.info("validateCGForDelete {} - end", system.getId());
    return true;
}
Also used : GetCGsResponse(com.emc.storageos.recoverpoint.responses.GetCGsResponse) GetRSetResponse(com.emc.storageos.recoverpoint.responses.GetRSetResponse) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) GetVolumeResponse(com.emc.storageos.recoverpoint.responses.GetVolumeResponse) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

GetCGsResponse (com.emc.storageos.recoverpoint.responses.GetCGsResponse)4 GetRSetResponse (com.emc.storageos.recoverpoint.responses.GetRSetResponse)3 GetVolumeResponse (com.emc.storageos.recoverpoint.responses.GetVolumeResponse)3 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)2 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)2 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)2 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)2 GetCopyResponse (com.emc.storageos.recoverpoint.responses.GetCopyResponse)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)1 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)1 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)1 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)1 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)1 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)1 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)1 FullRecoverPointSettings (com.emc.fapiclient.ws.FullRecoverPointSettings)1