Search in sources :

Example 1 with SynchronizationState

use of com.emc.storageos.storagedriver.model.VolumeMirror.SynchronizationState in project coprhd-controller by CoprHD.

the class DellSCDiscovery method getVolumeMirrors.

/**
 * Gets all mirrors of a volume.
 *
 * @param storageVolume The volume.
 * @return The mirrors.
 */
public List<VolumeMirror> getVolumeMirrors(StorageVolume storageVolume) {
    LOG.info("Getting mirrors for volume {}", storageVolume.getNativeId());
    List<VolumeMirror> result = new ArrayList<>();
    try {
        StorageCenterAPI api = connectionManager.getConnection(storageVolume.getStorageSystemId());
        ScVolume scVolume = api.getVolume(storageVolume.getNativeId());
        if (scVolume != null && scVolume.cmmSource) {
            ScCopyMirrorMigrate[] cmms = api.getVolumeCopyMirrorMigrate(scVolume.instanceId);
            for (ScCopyMirrorMigrate cmm : cmms) {
                if ("Mirror".equals(cmm.type)) {
                    ScVolume targetVol = api.getVolume(cmm.destinationVolume.instanceId);
                    VolumeMirror mirror = new VolumeMirror();
                    mirror.setAccessStatus(AccessStatus.READ_WRITE);
                    mirror.setDeviceLabel(targetVol.name);
                    mirror.setDisplayName(targetVol.name);
                    mirror.setNativeId(targetVol.instanceId);
                    mirror.setParentId(cmm.sourceVolume.instanceId);
                    mirror.setStorageSystemId(storageVolume.getStorageSystemId());
                    SynchronizationState syncState = SynchronizationState.SYNCHRONIZED;
                    if (cmm.percentComplete != 100) {
                        syncState = SynchronizationState.COPYINPROGRESS;
                    }
                    mirror.setSyncState(syncState);
                    mirror.setWwn(targetVol.deviceId);
                    result.add(mirror);
                }
            }
        }
    } catch (DellSCDriverException e) {
        String msg = String.format("Error getting mirrors for volume %s", storageVolume.getNativeId(), e);
        LOG.warn(msg);
    }
    return result;
}
Also used : ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) ScCopyMirrorMigrate(com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate) VolumeMirror(com.emc.storageos.storagedriver.model.VolumeMirror) ArrayList(java.util.ArrayList) SynchronizationState(com.emc.storageos.storagedriver.model.VolumeMirror.SynchronizationState)

Aggregations

DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)1 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)1 ScCopyMirrorMigrate (com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate)1 ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)1 VolumeMirror (com.emc.storageos.storagedriver.model.VolumeMirror)1 SynchronizationState (com.emc.storageos.storagedriver.model.VolumeMirror.SynchronizationState)1 ArrayList (java.util.ArrayList)1