Search in sources :

Example 26 with ProtectionSet

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

the class BlockObjectMultipleConsistencyGroupsMigrationTest method verifyRpConsistencyGroupWithDuplicatesMigration.

/**
 * Verify the RP consistency group and its volumes have been properly migrated.
 *
 * @throws Exception
 */
private void verifyRpConsistencyGroupWithDuplicatesMigration() throws Exception {
    log.info("Verifying duplicate protection sets were cleaned up.");
    List<URI> protSetIds = _dbClient.queryByType(ProtectionSet.class, true);
    List<String> protSetNames = new ArrayList<String>();
    for (URI id : protSetIds) {
        ProtectionSet protSet = _dbClient.queryObject(ProtectionSet.class, id);
        if (protSet == null || protSet.getInactive()) {
            continue;
        }
        if (protSetNames.contains(protSet.getLabel())) {
            // fail duplicate protection set
            Assert.fail("Duplicate protection sets exist after migration " + protSet.getLabel());
        } else {
            protSetNames.add(protSet.getLabel());
            // verify that there are no duplicates or stale volumes on the volume list
            List<String> volumeIds = new ArrayList<String>();
            for (String volId : protSet.getVolumes()) {
                Volume vol = _dbClient.queryObject(Volume.class, URI.create(volId));
                if (vol == null || vol.getInactive()) {
                    // fail stale volume on protection set
                    Assert.fail(String.format("Stale volume %s exists on protection set %s exist after migration", volId, protSet.getLabel()));
                } else if (volumeIds.contains(volId)) {
                    // fail duplicate volume on protection set
                    Assert.fail(String.format("Duplicate volume %s exists on protection set %s exist after migration", volId, protSet.getLabel()));
                } else if (vol.getProtectionSet() == null || vol.getProtectionSet().getURI() == null || !vol.getProtectionSet().getURI().equals(protSet.getId())) {
                    // fail volume does not point back to protection set
                    Assert.fail(String.format("Volume %s does not point back to protection set %s exist after migration", volId, protSet.getLabel()));
                } else {
                    volumeIds.add(volId);
                }
            }
        }
    }
    // make sure there are no dangling protection sets on volumes
    List<URI> volumes = _dbClient.queryByType(Volume.class, true);
    for (URI id : volumes) {
        Volume vol = _dbClient.queryObject(Volume.class, id);
        if (vol.getProtectionSet() != null && vol.getProtectionSet().getURI() != null) {
            ProtectionSet protSet = _dbClient.queryObject(ProtectionSet.class, vol.getProtectionSet().getURI());
            if (protSet == null || protSet.getInactive()) {
                // fail dangling protection set
                Assert.fail(String.format("Stale protection set %s on volume %s exists after migration", vol.getProtectionSet().getURI(), id));
            }
        }
    }
    // make sure there are no dangling protection sets on snapshots
    List<URI> snapshots = _dbClient.queryByType(BlockSnapshot.class, true);
    for (URI id : snapshots) {
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, id);
        if (snapshot.getProtectionSet() != null) {
            ProtectionSet protSet = _dbClient.queryObject(ProtectionSet.class, snapshot.getProtectionSet());
            if (protSet == null || protSet.getInactive()) {
                // fail dangling protection set
                Assert.fail(String.format("Stale protection set %s on snapshot %s exists after migration", snapshot.getProtectionSet(), id));
            }
        }
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 27 with ProtectionSet

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

the class BlockObjectMultipleConsistencyGroupsMigrationTest method prepareRPConsistencyGroupDataWithDuplicates.

/**
 * Prepare the RecoverPoint only volumes and associated consistency group data.
 *
 * @throws Exception
 */
private void prepareRPConsistencyGroupDataWithDuplicates() throws Exception {
    String cg2Name = "rpCg3";
    // Create the RecoverPoint BlockConsistencyGroup that will be shared by all the
    // RP volumes.
    BlockConsistencyGroup rpCg = createBlockConsistencyGroup(cg2Name, null, Types.RP.name(), true);
    // Save the CG references for migration verification.
    rpConsistencyGroupURI3 = rpCg.getId();
    // create a protection set and volumes and add them to the CG
    addProtectionSetAndVolumes(rpCg, "ps-dup", 3);
    // create a protection set and volumes and add them to the CG
    addProtectionSetAndVolumes(rpCg, "ps-dup", 3);
    // same volume in two protection sets
    // Create the ProtectionSet that the RP volumes will belong to.
    String prefix = "ps-dup2-";
    ProtectionSet cg2ps1 = createProtectionSet(prefix + "ProtectionSet", projectURI);
    ProtectionSet cg2ps2 = createProtectionSet(prefix + "ProtectionSet", projectURI);
    // Create all the RP volumes
    List<Volume> rpCgVolumes = createRpVolumes(prefix + "VolumeA", 1, cg2ps1, false);
    // Add the RP volumes to the RP consistency group
    addVolumesToBlockConsistencyGroup(rpCg.getId(), rpCgVolumes);
    // Add the RP volumes to the protection set
    addVolumesToProtectionSet(cg2ps1.getId(), rpCgVolumes);
    addVolumesToProtectionSet(cg2ps2.getId(), rpCgVolumes);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 28 with ProtectionSet

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

the class BlockObjectMultipleConsistencyGroupsMigrationTest method createProtectionSet.

/**
 * Convenience method to create a ProtectionSet.
 *
 * @param cgName
 * @param projectURI
 * @return
 * @throws Exception
 */
private ProtectionSet createProtectionSet(String cgName, URI projectURI) throws Exception {
    ProtectionSet protectionSet = new ProtectionSet();
    URI protectionSetURI = URIUtil.createId(ProtectionSet.class);
    protectionSet.setId(protectionSetURI);
    protectionSet.setLabel("ViPR-" + cgName);
    protectionSet.setProtectionId("790520997");
    protectionSet.setProtectionStatus("ENABLED");
    protectionSet.setProject(projectURI);
    protectionSet.setProtectionSystem(protectionSystemURI);
    _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 29 with ProtectionSet

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

the class MetroPointVolumeInternalSiteNameMigrationTest method createProtectionSet.

private URI createProtectionSet() {
    ProtectionSet ps = new ProtectionSet();
    URI psURI = URIUtil.createId(ProtectionSet.class);
    ps.setId(psURI);
    ps.setLabel("protectionSet");
    _dbClient.createObject(ps);
    return psURI;
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 30 with ProtectionSet

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

the class RecoverPointConsistencyGroupMigrationTest method addVolumesToProtectionSet.

private void addVolumesToProtectionSet(URI protectionSetURI, List<Volume> volumes) {
    ProtectionSet protectionSet = _dbClient.queryObject(ProtectionSet.class, protectionSetURI);
    StringSet vols = new StringSet();
    for (Volume volume : volumes) {
        vols.add(volume.getId().toString());
    }
    protectionSet.setVolumes(vols);
    _dbClient.persistObject(protectionSet);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) StringSet(com.emc.storageos.db.client.model.StringSet)

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