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));
}
}
}
}
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);
}
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;
}
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;
}
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);
}
Aggregations