Search in sources :

Example 36 with ProtectionSet

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

the class ProtectionSetToBlockConsistencyGroupMigration method createRpBlockConsistencyGroups.

/**
 * Create RP BlockConsistencyGroup objects for each ProtectionSet.
 */
private void createRpBlockConsistencyGroups() {
    DbClient dbClient = this.getDbClient();
    List<URI> protectionSetURIs = dbClient.queryByType(ProtectionSet.class, false);
    Iterator<ProtectionSet> protectionSets = dbClient.queryIterativeObjects(ProtectionSet.class, protectionSetURIs);
    while (protectionSets.hasNext()) {
        ProtectionSet ps = protectionSets.next();
        Project project = dbClient.queryObject(Project.class, ps.getProject());
        BlockConsistencyGroup cg = new BlockConsistencyGroup();
        cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
        cg.setLabel(ps.getLabel());
        cg.setDeviceName(ps.getLabel());
        cg.setType(BlockConsistencyGroup.Types.RP.toString());
        cg.setProject(new NamedURI(project.getId(), project.getLabel()));
        cg.setTenant(project.getTenantOrg());
        dbClient.createObject(cg);
        log.debug("Created ConsistencyGroup (id={}) based on ProtectionSet (id={})", cg.getId().toString(), ps.getId().toString());
        // Organize the volumes by replication set
        for (String protectionVolumeID : ps.getVolumes()) {
            URI uri = URI.create(protectionVolumeID);
            Volume protectionVolume = dbClient.queryObject(Volume.class, uri);
            protectionVolume.addConsistencyGroup(cg.getId().toString());
            dbClient.persistObject(protectionVolume);
            log.debug("Volume (id={}) added to ConsistencyGroup (id={})", protectionVolume.getId().toString(), cg.getId().toString());
        }
    }
}
Also used : Project(com.emc.storageos.db.client.model.Project) DbClient(com.emc.storageos.db.client.DbClient) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 37 with ProtectionSet

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

the class RecoverPointConsistencyGroupMigrationTest method prepareRPConsistencyGroupData.

/**
 * Prepares the data for RP volume tests.
 *
 * @throws Exception When an error occurs preparing the RP volume data.
 */
private void prepareRPConsistencyGroupData() throws Exception {
    log.info("Preparing RecoverPoint consistency group data for RecoverPointConsistencyGroupMigration");
    TenantOrg tenantOrg = new TenantOrg();
    URI tenantOrgURI = URIUtil.createId(TenantOrg.class);
    tenantOrg.setId(tenantOrgURI);
    _dbClient.createObject(tenantOrg);
    Project proj = new Project();
    URI projectURI = URIUtil.createId(Project.class);
    String projectLabel = "project";
    proj.setId(projectURI);
    proj.setLabel(projectLabel);
    proj.setTenantOrg(new NamedURI(tenantOrgURI, projectLabel));
    _dbClient.createObject(proj);
    // Create CG 1 volumes
    ProtectionSet cg1ps = createProtectionSetData("cg1", projectURI);
    List<Volume> cg1Volumes = createRpVolumes("cg1volume1", 1, cg1ps);
    cg1Volumes.addAll(createRpVolumes("cg1volume2", 1, cg1ps));
    addVolumesToProtectionSet(cg1ps.getId(), cg1Volumes);
    createBlockSnapshotData("cg1Snap", cg1Volumes);
    // Create CG 2 volumes
    ProtectionSet cg2ps = createProtectionSetData("cg2", projectURI);
    List<Volume> cg2Volumes = createRpVolumes("cg2volume1", 2, cg2ps);
    cg2Volumes.addAll(createRpVolumes("cg2volume2", 2, cg2ps));
    addVolumesToProtectionSet(cg2ps.getId(), cg2Volumes);
    createBlockSnapshotData("cg2Snap", cg2Volumes);
    // Create CG 3 volumes
    ProtectionSet cg3ps = createProtectionSetData("cg3", projectURI);
    List<Volume> cg3Volumes = createRpVolumes("cg3volume1", 3, cg3ps);
    addVolumesToProtectionSet(cg3ps.getId(), cg3Volumes);
    createBlockSnapshotData("cg3Snap", cg3Volumes);
    // Verify the rp volume data exists in the database.
    for (URI volumeURI : rpTestVolumeURIs) {
        Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
        Assert.assertNotNull(String.format("RecoverPoint test volume %s not found", volumeURI), volume);
    }
}
Also used : Project(com.emc.storageos.db.client.model.Project) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 38 with ProtectionSet

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

the class RecoverPointConsistencyGroupMigrationTest method verifyBlockConsistencyGroupResults.

/**
 * Verifies the migration results for BlockConsistencyGroups.
 *
 * @throws Exception When an error occurs verifying the BlockConsistencyGroup
 *             migration results.
 */
private void verifyBlockConsistencyGroupResults() throws Exception {
    log.info("Verifying created BlockConsistencyGroups for RecoverPointConsistencyGroupMigration.");
    List<URI> cgURIs = _dbClient.queryByType(BlockConsistencyGroup.class, false);
    Iterator<BlockConsistencyGroup> cgs = _dbClient.queryIterativeObjects(BlockConsistencyGroup.class, cgURIs);
    List<BlockConsistencyGroup> consistencyGroups = new ArrayList<BlockConsistencyGroup>();
    while (cgs.hasNext()) {
        consistencyGroups.add(cgs.next());
    }
    for (URI protectionSetURI : rpTestProtectionSetURIs) {
        ProtectionSet protectionSet = _dbClient.queryObject(ProtectionSet.class, protectionSetURI);
        Assert.assertNotNull(String.format("RecoverPoint test ProtectionSet %s not found", protectionSetURI), protectionSet);
        // A BlockConsistencyGroup should have been created for each ProtectionSet
        BlockConsistencyGroup cg = null;
        for (BlockConsistencyGroup consistencyGroup : consistencyGroups) {
            cg = consistencyGroup;
            if (cg.getLabel().equals(protectionSet.getLabel())) {
                break;
            }
        }
        Project project = _dbClient.queryObject(Project.class, protectionSet.getProject());
        Assert.assertTrue(String.format("Field deviceName is not properly set for consistency group %s", cg.getId().toString()), cg.getDeviceName().equals(protectionSet.getLabel()));
        Assert.assertTrue(String.format("Field type should be set to RP for consistency group %s", cg.getId().toString()), cg.getType().equals(BlockConsistencyGroup.Types.RP.toString()));
        Assert.assertTrue(String.format("Field project does not match the corresponding field for protection set %s", protectionSet.getId().toString()), project.getId().equals(protectionSet.getProject()));
        Assert.assertTrue(String.format("Field tenant does not match the corresponding field for protection set %s", protectionSet.getId().toString()), cg.getTenant().getURI().equals(project.getTenantOrg().getURI()));
        // Verify the consistency group volumes match the protection set volumes
        // Find all volumes assigned to the group
        final URIQueryResultList cgVolumesResults = new URIQueryResultList();
        _dbClient.queryByConstraint(getVolumesByConsistencyGroup(cg.getId().toString()), cgVolumesResults);
        List<Volume> cgVolumes = new ArrayList<Volume>();
        Iterator<URI> cgVolumeURIs = cgVolumesResults.iterator();
        while (cgVolumeURIs.hasNext()) {
            Volume cgVol = _dbClient.queryObject(Volume.class, cgVolumeURIs.next());
            cgVolumes.add(cgVol);
        }
        for (Volume cgVolume : cgVolumes) {
            log.info(String.format("CG (%s) volume (%s) found.", cg.getLabel(), cgVolume.getLabel()));
        }
        Iterator<String> protectionSetVolumeURIs = protectionSet.getVolumes().iterator();
        while (protectionSetVolumeURIs.hasNext()) {
            boolean found = false;
            String protectionSetVolumeURI = protectionSetVolumeURIs.next();
            for (Volume cgVolume : cgVolumes) {
                if (cgVolume.getId().toString().equals(protectionSetVolumeURI)) {
                    found = true;
                    break;
                }
            }
            Assert.assertTrue(String.format("All ProtectionSet volumes MUST be part of the BlockConsistencyGroup.  " + "ProtectionSet volume %s was not found in BlockConsistencyGroup %s.", protectionSetVolumeURI, cg.getId().toString()), found);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Project(com.emc.storageos.db.client.model.Project) Volume(com.emc.storageos.db.client.model.Volume)

Example 39 with ProtectionSet

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

the class RecoverPointConsistencyGroupMigrationTest method createProtectionSetData.

private ProtectionSet createProtectionSetData(String cgName, URI projectURI) throws Exception {
    ProtectionSet protectionSet = new ProtectionSet();
    URI protectionSetURI = URIUtil.createId(ProtectionSet.class);
    rpTestProtectionSetURIs.add(protectionSetURI);
    protectionSet.setId(protectionSetURI);
    protectionSet.setLabel("ViPR-" + cgName);
    protectionSet.setProtectionId("790520997");
    protectionSet.setProtectionStatus("ENABLED");
    protectionSet.setProject(projectURI);
    _dbClient.createObject(protectionSet);
    return protectionSet;
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 40 with ProtectionSet

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

the class RPCommunicationInterface method updatePostFailoverPersonalities.

/**
 * After a failover, we need to swap personalities of source and target volumes,
 * and reset the target lists in each volume.
 *
 * @param volume any volume in a protection set
 * @throws InternalException
 */
private void updatePostFailoverPersonalities(Volume volume) throws InternalException {
    _log.info("Changing personality of source and targets");
    ProtectionSet protectionSet = _dbClient.queryObject(ProtectionSet.class, volume.getProtectionSet());
    List<URI> volumeIDs = new ArrayList<URI>();
    for (String volumeString : protectionSet.getVolumes()) {
        URI volumeURI;
        try {
            volumeURI = new URI(volumeString);
            volumeIDs.add(volumeURI);
        } catch (URISyntaxException e) {
            _log.error("URI syntax incorrect: ", e);
        }
    }
    // 
    for (URI protectionVolumeID : volumeIDs) {
        Volume protectionVolume = _dbClient.queryObject(Volume.class, protectionVolumeID);
        if (protectionVolume == null || protectionVolume.getInactive()) {
            continue;
        }
        if ((protectionVolume.getPersonality().equals(Volume.PersonalityTypes.TARGET.toString())) && (protectionVolume.getRpCopyName().equals(volume.getRpCopyName()))) {
            // This is a TARGET we failed over to. We need to build up all of its targets
            for (URI potentialTargetVolumeID : volumeIDs) {
                Volume potentialTargetVolume = _dbClient.queryObject(Volume.class, potentialTargetVolumeID);
                if (potentialTargetVolume == null || potentialTargetVolume.getInactive()) {
                    continue;
                }
                if (potentialTargetVolume.getRSetName() != null && potentialTargetVolume.getRSetName().equals(protectionVolume.getRSetName()) && !potentialTargetVolumeID.equals(protectionVolume.getId())) {
                    if (protectionVolume.getRpTargets() == null) {
                        protectionVolume.setRpTargets(new StringSet());
                    }
                    protectionVolume.getRpTargets().add(String.valueOf(potentialTargetVolume.getId()));
                }
            }
            _log.info("Change personality of failover target " + protectionVolume.getWWN() + " to source");
            protectionVolume.setPersonality(Volume.PersonalityTypes.SOURCE.toString());
            volume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
            _dbClient.updateObject(protectionVolume);
        } else if (protectionVolume.getPersonality().equals(Volume.PersonalityTypes.SOURCE.toString())) {
            _log.info("Change personality of source volume " + protectionVolume.getWWN() + " to target");
            protectionVolume.setPersonality(Volume.PersonalityTypes.TARGET.toString());
            volume.setAccessState(Volume.VolumeAccessState.NOT_READY.name());
            protectionVolume.setRpTargets(new StringSet());
            _dbClient.updateObject(protectionVolume);
        } else if (!protectionVolume.getPersonality().equals(Volume.PersonalityTypes.METADATA.toString())) {
            _log.info("Target " + protectionVolume.getWWN() + " is a target that remains a target");
        // TODO: Handle failover to CRR. Need to remove the CDP volumes (including journals)
        }
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)57 Volume (com.emc.storageos.db.client.model.Volume)39 URI (java.net.URI)30 NamedURI (com.emc.storageos.db.client.model.NamedURI)26 ArrayList (java.util.ArrayList)25 StringSet (com.emc.storageos.db.client.model.StringSet)18 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)14 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)13 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)11 URISyntaxException (java.net.URISyntaxException)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)9 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)9 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)9 HashSet (java.util.HashSet)8 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)7 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)6 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)6 RecoverPointVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext)6