Search in sources :

Example 1 with ScVolume

use of com.emc.storageos.driver.dellsc.scapi.objects.ScVolume in project coprhd-controller by CoprHD.

the class DellSCStorageDriver method getStorageObject.

/**
 * Get storage object with a given type with specified native ID which belongs to specified storage system.
 *
 * @param storageSystemId The storage system native ID.
 * @param objectId The object ID.
 * @param type The class instance.
 * @param <T> The storage object type.
 * @return Storage object or Null if it does not exist.
 */
@SuppressWarnings("unchecked")
@Override
public <T extends StorageObject> T getStorageObject(String storageSystemId, String objectId, Class<T> type) {
    String requestedType = type.getSimpleName();
    LOG.info("Request for {} object {} from {}", requestedType, objectId, storageSystemId);
    DellSCUtil util = DellSCUtil.getInstance();
    try {
        StorageCenterAPI api = DellSCConnectionManager.getInstance().getConnection(storageSystemId);
        if (requestedType.equals(StorageVolume.class.getSimpleName())) {
            ScVolume volume = api.getVolume(objectId);
            Map<ScReplayProfile, List<String>> cgInfo = util.getGCInfo(api, storageSystemId);
            return (T) util.getStorageVolumeFromScVolume(api, volume, cgInfo);
        } else if (requestedType.equals(VolumeConsistencyGroup.class.getSimpleName())) {
            return (T) util.getVolumeConsistencyGroupFromReplayProfile(api.getConsistencyGroup(objectId), null);
        } else if (requestedType.equals(VolumeSnapshot.class.getSimpleName())) {
            return (T) util.getVolumeSnapshotFromReplay(api.getReplay(objectId), null);
        } else if (requestedType.equals(StoragePool.class.getSimpleName())) {
            return (T) util.getStoragePoolFromStorageType(api, api.getStorageType(objectId), null);
        }
    } catch (StorageCenterAPIException | DellSCDriverException e) {
        String message = String.format("Error getting requested storage object: %s", e);
        LOG.warn(message);
    }
    LOG.warn("Requested object of type {} not found.", requestedType);
    return null;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) ScReplayProfile(com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile) List(java.util.List) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 2 with ScVolume

use of com.emc.storageos.driver.dellsc.scapi.objects.ScVolume in project coprhd-controller by CoprHD.

the class DellSCUtil method getGCInfo.

/**
 * Gets consistency groups and volumes from a given Storage Center.
 *
 * @param api The API connection.
 * @param ssn The Storage Center serial number.
 * @return The consistency groups and their volumes.
 */
public Map<ScReplayProfile, List<String>> getGCInfo(StorageCenterAPI api, String ssn) {
    Map<ScReplayProfile, List<String>> result = new HashMap<>();
    ScReplayProfile[] cgs = api.getConsistencyGroups(ssn);
    for (ScReplayProfile cg : cgs) {
        result.put(cg, new ArrayList<>());
        try {
            ScVolume[] vols = api.getReplayProfileVolumes(cg.instanceId);
            for (ScVolume vol : vols) {
                result.get(cg).add(vol.instanceId);
            }
        } catch (StorageCenterAPIException e) {
            LOG.warn(String.format("Error getting volumes for consistency group %s: %s", cg.instanceId, e));
        }
    }
    return result;
}
Also used : ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) HashMap(java.util.HashMap) ScReplayProfile(com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with ScVolume

use of com.emc.storageos.driver.dellsc.scapi.objects.ScVolume in project coprhd-controller by CoprHD.

the class DellSCCloning method createVolumeClone.

/**
 * Create a clone of a volume.
 *
 * @param clones The clones to create.
 * @return The clone task.
 */
public DriverTask createVolumeClone(List<VolumeClone> clones) {
    LOG.info("Creating volume clone");
    DellSCDriverTask task = new DellSCDriverTask("createVolumeClone");
    StringBuilder errBuffer = new StringBuilder();
    int createCount = 0;
    for (VolumeClone clone : clones) {
        try {
            StorageCenterAPI api = connectionManager.getConnection(clone.getStorageSystemId());
            ScReplay replay = null;
            // Make sure volume is active for the automated tests that try to
            // create temporary snapshot to create the clone from after immediate volume creation
            api.checkAndInitVolume(clone.getParentId());
            if (clone.getSourceType() == SourceType.SNAPSHOT) {
                replay = api.getReplay(clone.getParentId());
            } else {
                // Create temporary replay to create the clone from
                replay = api.createReplay(clone.getParentId(), 5);
            }
            // Now create a new volume from the snapshot
            ScVolume scVol = api.createViewVolume(clone.getDisplayName(), replay.instanceId);
            clone.setProvisionedCapacity(SizeUtil.sizeStrToBytes(scVol.configuredSize));
            // New volumes don't allocate any space
            clone.setAllocatedCapacity(0L);
            clone.setWwn(scVol.deviceId);
            clone.setNativeId(scVol.instanceId);
            clone.setDeviceLabel(scVol.name);
            clone.setAccessStatus(AccessStatus.READ_WRITE);
            clone.setReplicationState(ReplicationState.SYNCHRONIZED);
            createCount++;
        } catch (DellSCDriverException | StorageCenterAPIException dex) {
            String error = String.format("Error creating clone of volume %s: %s", clone.getParentId(), dex);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (createCount == clones.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (createCount == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
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) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)

Example 4 with ScVolume

use of com.emc.storageos.driver.dellsc.scapi.objects.ScVolume 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 5 with ScVolume

use of com.emc.storageos.driver.dellsc.scapi.objects.ScVolume in project coprhd-controller by CoprHD.

the class DellSCProvisioning method getVolumeExportInfo.

/**
 * Gets the mapping information for a volume to initiators.
 *
 * @param volumeId The volume instance ID.
 * @param systemId The storage system ID.
 * @return The mapping details. Map of HostName:HostExportInfo
 */
public Map<String, HostExportInfo> getVolumeExportInfo(String volumeId, String systemId) {
    Map<String, HostExportInfo> result = new HashMap<>();
    Map<String, ScServer> serverCache = new HashMap<>();
    Map<String, Initiator> serverPortCache = new HashMap<>();
    Map<String, StoragePort> portCache = new HashMap<>();
    try {
        StorageCenterAPI api = connectionManager.getConnection(systemId);
        ScVolume scVol = api.getVolume(volumeId);
        if (scVol == null) {
            throw new DellSCDriverException(String.format("Volume %s could not be found.", volumeId));
        }
        ScMapping[] maps = api.getVolumeMaps(scVol.instanceId);
        for (ScMapping map : maps) {
            populateVolumeExportInfo(api, volumeId, map, result, serverCache, serverPortCache, portCache);
        }
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String message = String.format("Error getting export info for volume %s: %s", volumeId, dex);
        LOG.warn(message);
    }
    return result;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) ScServer(com.emc.storageos.driver.dellsc.scapi.objects.ScServer) HashMap(java.util.HashMap) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) Initiator(com.emc.storageos.storagedriver.model.Initiator) ScMapping(com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)

Aggregations

ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)17 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)11 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)11 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)10 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)8 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)5 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)4 RestResult (com.emc.storageos.driver.dellsc.scapi.rest.RestResult)4 DriverTask (com.emc.storageos.storagedriver.DriverTask)4 ArrayList (java.util.ArrayList)4 ScMappingProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile)3 ScReplayProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ScCopyMirrorMigrate (com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate)2 ScMapping (com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)2 ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)2 StoragePort (com.emc.storageos.storagedriver.model.StoragePort)2 VolumeMirror (com.emc.storageos.storagedriver.model.VolumeMirror)2 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)1