Search in sources :

Example 26 with DriverTask

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

the class DellSCMirroring method restoreVolumeMirror.

/**
 * Restore a volume mirror.
 *
 * @param mirrors The mirrors.
 * @return The driver task.
 */
public DriverTask restoreVolumeMirror(List<VolumeMirror> mirrors) {
    LOG.info("Restoring volume mirror not supported");
    // Need to determine what this expects. Mirrors are... mirrored. So
    // nothing to restore to in SC terms.
    DriverTask task = new DellSCDriverTask("restoreVolumeMirror");
    task.setStatus(TaskStatus.FAILED);
    return null;
}
Also used : DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) DriverTask(com.emc.storageos.storagedriver.DriverTask) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask)

Example 27 with DriverTask

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

the class DellSCProvisioning method unexportVolumesFromInitiators.

/**
 * Remove volume exports to initiators.
 *
 * @param initiators The initiators to remove from.
 * @param volumes The volumes to remove.
 * @return The unexport task.
 */
public DriverTask unexportVolumesFromInitiators(List<Initiator> initiators, List<StorageVolume> volumes) {
    LOG.info("Unexporting volumes from initiators");
    DriverTask task = new DellSCDriverTask("unexportVolumes");
    ScServer server = null;
    StringBuilder errBuffer = new StringBuilder();
    int volumesUnmapped = 0;
    for (StorageVolume volume : volumes) {
        String ssn = volume.getStorageSystemId();
        boolean isSnapshot = StringUtils.countMatches(volume.getNativeId(), ".") == 2;
        try {
            StorageCenterAPI api = connectionManager.getConnection(ssn);
            // Find our actual volume
            ScVolume scVol = null;
            if (isSnapshot) {
                scVol = api.findReplayView(volume.getNativeId());
                // For snapshot views we can just delete the view
                if (scVol != null) {
                    api.deleteVolume(scVol.instanceId);
                    volumesUnmapped++;
                    continue;
                }
            } else {
                scVol = api.getVolume(volume.getNativeId());
            }
            if (scVol == null) {
                throw new DellSCDriverException(String.format("Unable to find volume %s", volume.getNativeId()));
            }
            // Look up the server if needed
            if (server == null) {
                server = findScServer(api, ssn, initiators);
            }
            if (server == null) {
                // Unable to find the server, can't continue
                throw new DellSCDriverException(SERVER_CREATE_FAIL_MSG);
            }
            ScMappingProfile[] mappingProfiles = api.findMappingProfiles(server.instanceId, scVol.instanceId);
            for (ScMappingProfile mappingProfile : mappingProfiles) {
                api.deleteMappingProfile(mappingProfile.instanceId);
            }
            volumesUnmapped++;
            LOG.info("Volume '{}' unexported from server '{}'", scVol.name, server.name);
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error unmapping volume %s: %s", volume.getDisplayName(), dex);
            LOG.error(error);
            errBuffer.append(String.format("%s%n", error));
            if (SERVER_CREATE_FAIL_MSG.equals(dex.getMessage())) {
                // Game over
                break;
            }
        }
    }
    task.setMessage(errBuffer.toString());
    if (volumesUnmapped == volumes.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (volumesUnmapped == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) ScServer(com.emc.storageos.driver.dellsc.scapi.objects.ScServer) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ScMappingProfile(com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) DriverTask(com.emc.storageos.storagedriver.DriverTask) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException)

Example 28 with DriverTask

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

the class DellSCProvisioning method createVolumes.

/**
 * Create storage volumes with a given set of capabilities.
 * Before completion of the request, set all required data for provisioned
 * volumes in "volumes" parameter.
 *
 * @param volumes Input/output argument for volumes.
 * @param storageCapabilities Input argument for capabilities. Defines
 *            storage capabilities of volumes to create.
 * @return The volume creation task.
 */
public DriverTask createVolumes(List<StorageVolume> volumes, StorageCapabilities storageCapabilities) {
    DriverTask task = new DellSCDriverTask("createVolume");
    StringBuilder errBuffer = new StringBuilder();
    int volumesCreated = 0;
    for (StorageVolume volume : volumes) {
        LOG.debug("Creating volume {} on system {}", volume.getDisplayName(), volume.getStorageSystemId());
        String ssn = volume.getStorageSystemId();
        try {
            StorageCenterAPI api = connectionManager.getConnection(ssn);
            ScVolume scVol = api.createVolume(ssn, volume.getDisplayName(), volume.getStoragePoolId(), SizeUtil.byteToMeg(volume.getRequestedCapacity()), volume.getConsistencyGroup());
            volume.setProvisionedCapacity(SizeUtil.sizeStrToBytes(scVol.configuredSize));
            // New volumes don't allocate any space
            volume.setAllocatedCapacity(0L);
            volume.setWwn(scVol.deviceId);
            volume.setNativeId(scVol.instanceId);
            volume.setDeviceLabel(scVol.name);
            volume.setAccessStatus(AccessStatus.READ_WRITE);
            volumesCreated++;
            LOG.info("Created volume '{}'", scVol.name);
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error creating volume %s: %s", volume.getDisplayName(), dex);
            LOG.error(error);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (volumesCreated == volumes.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (volumesCreated == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) 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)

Example 29 with DriverTask

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

the class DellSCProvisioning method expandVolume.

/**
 * Expand volume to a new size.
 * Before completion of the request, set all required data for expanded
 * volume in "volume" parameter.
 *
 * @param storageVolume Volume to expand. Type: Input/Output argument.
 * @param newCapacity Requested capacity. Type: input argument.
 * @return The volume expansion task.
 */
public DriverTask expandVolume(StorageVolume storageVolume, long newCapacity) {
    DriverTask task = new DellSCDriverTask("expandVolume");
    try {
        StorageCenterAPI api = connectionManager.getConnection(storageVolume.getStorageSystemId());
        ScVolume scVol = api.expandVolume(storageVolume.getNativeId(), SizeUtil.byteToMeg(newCapacity));
        storageVolume.setProvisionedCapacity(SizeUtil.sizeStrToBytes(scVol.configuredSize));
        task.setStatus(TaskStatus.READY);
        LOG.info("Expanded volume '{}'", scVol.name);
    } catch (DellSCDriverException | StorageCenterAPIException dex) {
        String error = String.format("Error expanding volume %s: %s", storageVolume.getDisplayName(), dex);
        LOG.error(error);
        task.setMessage(error);
        task.setStatus(TaskStatus.FAILED);
    }
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) 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) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)

Example 30 with DriverTask

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

the class DellSCSnapshots method restoreSnapshot.

/**
 * Restore volumes to a snapshot point in time.
 * NOTE: not currently supported.
 *
 * @param snapshots The snapshots to restore to.
 * @return The driver task.
 */
public DriverTask restoreSnapshot(List<VolumeSnapshot> snapshots) {
    DriverTask task = new DellSCDriverTask("restoreVolumeSnapshot");
    // The API to revert a volume to a specific snapshot is currently
    // a private call. We can either support this by:
    // 1) Creating a volume from the snapshot, perform a copy back to the original, delete volume
    // 2) Wait until the snapshot revert call can be made public
    // Going with option 2 for now.
    task.setStatus(TaskStatus.FAILED);
    task.setMessage("Snapshot restore is not supported at this time.");
    LOG.warn("Snapshot restore is not supported at this time.");
    return null;
}
Also used : DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) DriverTask(com.emc.storageos.storagedriver.DriverTask) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask)

Aggregations

DriverTask (com.emc.storageos.storagedriver.DriverTask)80 BlockStorageDriver (com.emc.storageos.storagedriver.BlockStorageDriver)26 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)26 ArrayList (java.util.ArrayList)26 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)22 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)21 Volume (com.emc.storageos.db.client.model.Volume)15 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)15 IOException (java.io.IOException)15 URI (java.net.URI)15 HashMap (java.util.HashMap)13 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)10 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)9 HashSet (java.util.HashSet)9 VolumeClone (com.emc.storageos.storagedriver.model.VolumeClone)7 VolumeSnapshot (com.emc.storageos.storagedriver.model.VolumeSnapshot)7 BlockObject (com.emc.storageos.db.client.model.BlockObject)6 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)6 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)6 ExportMask (com.emc.storageos.db.client.model.ExportMask)6