use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class SmisVnxCreateCGMirrorJob method updateStatus.
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMInstance> syncVolumeIter = null;
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
BlockMirrorCreateCompleter completer = (BlockMirrorCreateCompleter) getTaskCompleter();
List<BlockMirror> mirrors = dbClient.queryObject(BlockMirror.class, completer.getIds());
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
updatePools(client, dbClient, mirrors);
}
if (jobStatus == JobStatus.SUCCESS) {
syncVolumeIter = client.associatorInstances(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
processCGMirrors(syncVolumeIter, client, dbClient, storage, mirrors, UUID.randomUUID().toString());
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to create group mirrors");
for (BlockMirror mirror : mirrors) {
mirror.setInactive(true);
}
dbClient.persistObject(mirrors);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error during create CG mirror job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisVnxCreateCGMirrorJob", e);
} finally {
if (syncVolumeIter != null) {
syncVolumeIter.close();
}
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class SmisVnxCreateCGMirrorJob method processCGMirrors.
/**
* Iterate through all created sync volumes, match up with ViPR created mirrors, and update them in ViPR.
*
* @param syncVolumeIter
* @param client
* @param dbClient
* @param storage
* @param mirrors
* @param repGroupID
* @throws Exception
*/
private void processCGMirrors(CloseableIterator<CIMInstance> syncVolumeIter, WBEMClient client, DbClient dbClient, StorageSystem storage, List<BlockMirror> mirrors, String repGroupID) throws Exception {
// Create mapping of volume.nativeDeviceId to BlockMirror object
Map<String, BlockMirror> volIdToMirrorMap = new HashMap<String, BlockMirror>();
for (BlockMirror mirror : mirrors) {
Volume volume = dbClient.queryObject(Volume.class, mirror.getSource());
volIdToMirrorMap.put(volume.getNativeId(), mirror);
}
Calendar now = Calendar.getInstance();
while (syncVolumeIter.hasNext()) {
// Get the target mirror volume native device id
CIMInstance syncVolume = syncVolumeIter.next();
CIMObjectPath syncVolumePath = syncVolume.getObjectPath();
String syncDeviceID = syncVolumePath.getKeyValue(SmisConstants.CP_DEVICE_ID).toString();
String elementName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_ELEMENT_NAME);
String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_WWN_NAME);
String alternateName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_NAME);
// Get the associated volume for this sync volume
String volumeDeviceID = tgtToSrcMap.get(syncDeviceID);
// Lookup mirror associated with the source volume based on the source volume's native id
BlockMirror mirror = volIdToMirrorMap.get(volumeDeviceID);
mirror.setReplicationGroupInstance(repGroupID);
mirror.setProvisionedCapacity(getProvisionedCapacityInformation(client, syncVolume));
mirror.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
mirror.setWWN(wwn);
mirror.setAlternateName(alternateName);
mirror.setNativeId(syncDeviceID);
mirror.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, mirror));
mirror.setDeviceLabel(elementName);
mirror.setInactive(false);
mirror.setCreationTime(now);
CIMInstance syncInstance = getStorageSyncInstanceFromVolume(client, syncVolumePath);
mirror.setSynchronizedInstance(syncInstance.getObjectPath().toString());
mirror.setSyncType(CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_SYNC_TYPE));
dbClient.persistObject(mirror);
_log.info(String.format("For target mirror volume %1$s, going to set BlockMirror %2$s nativeId to %3$s (%4$s). Associated volume is %5$s", syncVolumePath.toString(), mirror.getId().toString(), syncDeviceID, elementName, volumeDeviceID));
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class SRDFUtils method CheckIfVolumeHasReplica.
/**
* Checks if a volume has snapshot, snapshot session, or clone or mirror associated.
*/
private boolean CheckIfVolumeHasReplica(Volume volume) {
boolean forceAdd = false;
URI volumeURI = volume.getId();
URIQueryResultList list = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volumeURI), list);
Iterator<URI> it = list.iterator();
while (it.hasNext()) {
URI snapshotID = it.next();
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotID);
if (snapshot != null) {
log.debug("There are Snapshot(s) available for volume {}", volumeURI);
forceAdd = true;
break;
}
}
// Check snapshot sessions also.
if (!forceAdd) {
List<BlockSnapshotSession> snapSessions = queryActiveResourcesByConstraint(dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(volumeURI));
if (!snapSessions.isEmpty()) {
log.debug("There are snapshot sessions available on volume {}", volumeURI);
forceAdd = true;
}
}
if (!forceAdd) {
// TODO ignore DETACHED clones?
URIQueryResultList cloneList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getAssociatedSourceVolumeConstraint(volumeURI), cloneList);
Iterator<URI> iter = cloneList.iterator();
while (iter.hasNext()) {
URI cloneID = iter.next();
Volume clone = dbClient.queryObject(Volume.class, cloneID);
if (clone != null) {
log.debug("There are Clone(s) available for volume {}", volumeURI);
forceAdd = true;
break;
}
}
}
if (!forceAdd) {
URIQueryResultList mirrorList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeBlockMirrorConstraint(volumeURI), mirrorList);
Iterator<URI> itr = mirrorList.iterator();
while (itr.hasNext()) {
URI mirrorID = itr.next();
BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorID);
if (mirror != null) {
log.debug("There are Mirror(s) available for volume {}", volumeURI);
forceAdd = true;
break;
}
}
}
return forceAdd;
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockObjectConsistencyGroupMigrationTest method verifyBlockObjectResults.
/**
* Verifies that the migration has worked properly. Checks all of the Volume, BlockSnapshot,
* and BlockMirror objects to ensure:
* 1) The old consistencyGroup field is null
* 2) The new consistencyGroups field is not null
* 3) The new consistencyGruops field is not empty
*
* @throws Exception
*/
private void verifyBlockObjectResults() throws Exception {
log.info("Verifying migration of BlockObject.consistencyGroup to BlockObject.consistencyGroups.");
List<BlockObject> blockObjects = new ArrayList<BlockObject>();
// get the volumes
Iterator<Volume> volumeItr = _dbClient.queryIterativeObjects(Volume.class, testVolumeURIs);
// Get the block snapshots
Iterator<BlockSnapshot> blockSnapshotItr = _dbClient.queryIterativeObjects(BlockSnapshot.class, testBlockSnapshotURIs);
// Get the block snapshots
Iterator<BlockMirror> blockMirrorItr = _dbClient.queryIterativeObjects(BlockMirror.class, testBlockMirrorURIs);
while (volumeItr.hasNext()) {
blockObjects.add(volumeItr.next());
}
while (blockSnapshotItr.hasNext()) {
blockObjects.add(blockSnapshotItr.next());
}
while (blockMirrorItr.hasNext()) {
blockObjects.add(blockMirrorItr.next());
}
for (BlockObject blockObject : blockObjects) {
Assert.assertTrue("Volume.consistencyGroup field should be null.", blockObject.getConsistencyGroup().equals(NullColumnValueGetter.getNullURI()));
Assert.assertNotNull("Volume.consistencyGroups field should contain at least 1 consistency group.", blockObject.getConsistencyGroups());
Assert.assertTrue("Volume.consistencyGroups field should contain at least 1 consistency group.", !blockObject.getConsistencyGroups().isEmpty());
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class ReplicationUtils method getMirrorGroupSynchronizedPath.
public static CIMObjectPath getMirrorGroupSynchronizedPath(StorageSystem storage, URI mirrorUri, DbClient dbClient, SmisCommandHelper helper, CIMObjectPathFactory cimPath) {
BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorUri);
Volume sourceVol = dbClient.queryObject(Volume.class, mirror.getSource());
String consistencyGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sourceVol, dbClient);
String replicationGroupName = mirror.getReplicationGroupInstance();
return cimPath.getGroupSynchronizedPath(storage, consistencyGroupName, replicationGroupName);
}
Aggregations