Search in sources :

Example 1 with VolumeMirror

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

the class DellSCStorageDriver method deleteConsistencyGroupMirror.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.storagedriver.DefaultStorageDriver#deleteConsistencyGroupMirror(java.util.List)
     */
@Override
public DriverTask deleteConsistencyGroupMirror(List<VolumeMirror> mirrors) {
    DellSCDriverTask task = new DellSCDriverTask("deleteConsistencyGroupMirror");
    StringBuilder errBuffer = new StringBuilder();
    int deletedCount = 0;
    for (VolumeMirror mirror : mirrors) {
        DriverTask subTask = mirrorHelper.deleteVolumeMirror(mirror);
        if (subTask.getStatus() == TaskStatus.FAILED) {
            errBuffer.append(String.format("%s%n", subTask.getMessage()));
        } else {
            deletedCount++;
        }
    }
    task.setMessage(errBuffer.toString());
    if (deletedCount == mirrors.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (deletedCount == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) VolumeMirror(com.emc.storageos.storagedriver.model.VolumeMirror)

Example 2 with VolumeMirror

use of com.emc.storageos.storagedriver.model.VolumeMirror 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)

Example 3 with VolumeMirror

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

the class DellSCMirroring method splitVolumeMirror.

/**
 * Delete volume mirror but leave the destination volume intact.
 *
 * @param mirrors The mirrors to split.
 * @return The split task.
 */
public DriverTask splitVolumeMirror(List<VolumeMirror> mirrors) {
    LOG.info("Splitting volume mirror");
    DellSCDriverTask task = new DellSCDriverTask("splitVolumeMirror");
    StringBuilder errBuffer = new StringBuilder();
    int mirrorSplit = 0;
    for (VolumeMirror mirror : mirrors) {
        try {
            StorageCenterAPI api = connectionManager.getConnection(mirror.getStorageSystemId());
            api.deleteMirror(mirror.getNativeId());
            task.setStatus(TaskStatus.READY);
            mirrorSplit++;
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error splitting volume mirror %s: %s", mirror.getDisplayName(), dex);
            LOG.error(error);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (mirrorSplit == mirrors.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (mirrorSplit == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) VolumeMirror(com.emc.storageos.storagedriver.model.VolumeMirror)

Example 4 with VolumeMirror

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

the class DellSCMirroring method createVolumeMirror.

/**
 * Create volume mirrors.
 *
 * @param mirrors The volume mirrors to create.
 * @return The creation task.
 */
public DriverTask createVolumeMirror(List<VolumeMirror> mirrors) {
    LOG.info("Creating volume mirror");
    DriverTask task = new DellSCDriverTask("createVolumeMirror");
    StringBuilder errBuffer = new StringBuilder();
    int mirrorsCreated = 0;
    for (VolumeMirror mirror : mirrors) {
        LOG.debug("Creating mirror of volume {}", mirror.getParentId());
        String ssn = mirror.getStorageSystemId();
        try {
            StorageCenterAPI api = connectionManager.getConnection(ssn);
            ScVolume srcVol = api.getVolume(mirror.getParentId());
            ScVolume destVol = api.createVolume(ssn, mirror.getDisplayName(), srcVol.storageType.instanceId, SizeUtil.byteToMeg(SizeUtil.sizeStrToBytes(srcVol.configuredSize)), null);
            ScCopyMirrorMigrate scCmm = api.createMirror(ssn, srcVol.instanceId, destVol.instanceId);
            mirror.setNativeId(scCmm.instanceId);
            mirror.setSyncState(SynchronizationState.COPYINPROGRESS);
            mirrorsCreated++;
            LOG.info("Created volume mirror '{}'", scCmm.instanceId);
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error creating volume mirror %s: %s", mirror.getDisplayName(), dex);
            LOG.error(error);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (mirrorsCreated == mirrors.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (mirrorsCreated == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) DriverTask(com.emc.storageos.storagedriver.DriverTask) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ScCopyMirrorMigrate(com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) VolumeMirror(com.emc.storageos.storagedriver.model.VolumeMirror)

Aggregations

VolumeMirror (com.emc.storageos.storagedriver.model.VolumeMirror)4 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)3 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)3 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)2 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)2 ScCopyMirrorMigrate (com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate)2 ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)2 DriverTask (com.emc.storageos.storagedriver.DriverTask)2 SynchronizationState (com.emc.storageos.storagedriver.model.VolumeMirror.SynchronizationState)1 ArrayList (java.util.ArrayList)1