Search in sources :

Example 56 with BlockMirror

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) WBEMClient(javax.wbem.client.WBEMClient) BlockMirrorCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorCreateCompleter) CIMInstance(javax.cim.CIMInstance) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 57 with BlockMirror

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));
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) HashMap(java.util.HashMap) Volume(com.emc.storageos.db.client.model.Volume) Calendar(java.util.Calendar) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance)

Example 58 with BlockMirror

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;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 59 with BlockMirror

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());
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 60 with BlockMirror

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);
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume)

Aggregations

BlockMirror (com.emc.storageos.db.client.model.BlockMirror)115 Volume (com.emc.storageos.db.client.model.Volume)77 URI (java.net.URI)49 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)43 ArrayList (java.util.ArrayList)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 NamedURI (com.emc.storageos.db.client.model.NamedURI)29 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)28 CIMObjectPath (javax.cim.CIMObjectPath)26 CIMInstance (javax.cim.CIMInstance)16 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)15 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)15 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)15 CIMArgument (javax.cim.CIMArgument)14 WBEMException (javax.wbem.WBEMException)14 BlockObject (com.emc.storageos.db.client.model.BlockObject)12 StringSet (com.emc.storageos.db.client.model.StringSet)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 ControllerException (com.emc.storageos.volumecontroller.ControllerException)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9