Search in sources :

Example 1 with ScReplayProfile

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

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

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

the class DellSCUtil method getStorageVolumeFromScVolume.

/**
 * Populates a StorageVolume instance with Storage Center volume data.
 *
 * @param api The API connection.
 * @param volume The Storage Center volume.
 * @param cgInfo Consistency group information or null.
 * @return The StorageVolume.
 * @throws StorageCenterAPIException
 */
public StorageVolume getStorageVolumeFromScVolume(StorageCenterAPI api, ScVolume volume, Map<ScReplayProfile, List<String>> cgInfo) throws StorageCenterAPIException {
    ScVolumeStorageUsage storageUsage = api.getVolumeStorageUsage(volume.instanceId);
    StorageVolume driverVol = new StorageVolume();
    driverVol.setStorageSystemId(volume.scSerialNumber);
    driverVol.setStoragePoolId(volume.storageType.instanceId);
    driverVol.setNativeId(volume.instanceId);
    driverVol.setThinlyProvisioned(true);
    driverVol.setProvisionedCapacity(SizeUtil.sizeStrToBytes(volume.configuredSize));
    driverVol.setAllocatedCapacity(SizeUtil.sizeStrToBytes(storageUsage.totalDiskSpace));
    driverVol.setWwn(volume.deviceId);
    driverVol.setDeviceLabel(volume.name);
    // Check consistency group membership
    if (cgInfo != null) {
        for (ScReplayProfile cg : cgInfo.keySet()) {
            if (cgInfo.get(cg).contains(volume.instanceId)) {
                // Found our volume in a consistency group
                driverVol.setConsistencyGroup(cg.instanceId);
                break;
            }
        }
    }
    return driverVol;
}
Also used : StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) ScVolumeStorageUsage(com.emc.storageos.driver.dellsc.scapi.objects.ScVolumeStorageUsage) ScReplayProfile(com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile)

Example 4 with ScReplayProfile

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

the class DellSCConsistencyGroups method deleteConsistencyGroup.

/**
 * Delete a consistency group.
 *
 * @param volumeConsistencyGroup The group to delete.
 * @return The consistency group delete task.
 */
public DriverTask deleteConsistencyGroup(VolumeConsistencyGroup volumeConsistencyGroup) {
    DellSCDriverTask task = new DellSCDriverTask("deleteVolume");
    try {
        StorageCenterAPI api = connectionManager.getConnection(volumeConsistencyGroup.getStorageSystemId());
        ScReplayProfile[] cgs = api.getConsistencyGroups(volumeConsistencyGroup.getStorageSystemId());
        for (ScReplayProfile cg : cgs) {
            if (cg.instanceId.equals(volumeConsistencyGroup.getNativeId())) {
                api.deleteConsistencyGroup(cg.instanceId);
                break;
            }
        }
        // We either deleted the CG or it was not found, either way we are fine
        task.setStatus(TaskStatus.READY);
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String error = String.format("Error deleting CG %s: %s", volumeConsistencyGroup.getDisplayName(), dex);
        LOG.error(error);
        task.setFailed(error);
    }
    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) ScReplayProfile(com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)

Example 5 with ScReplayProfile

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

the class DellSCConsistencyGroups method createConsistencyGroup.

/**
 * Create a consistency group.
 *
 * @param volumeConsistencyGroup The group to create.
 * @return The consistency group creation task.
 */
public DriverTask createConsistencyGroup(VolumeConsistencyGroup volumeConsistencyGroup) {
    DellSCDriverTask task = new DellSCDriverTask("createConsistencyGroup");
    String ssn = volumeConsistencyGroup.getStorageSystemId();
    try {
        StorageCenterAPI api = connectionManager.getConnection(ssn);
        ScReplayProfile cg = api.createConsistencyGroup(ssn, volumeConsistencyGroup.getDisplayName());
        util.getVolumeConsistencyGroupFromReplayProfile(cg, volumeConsistencyGroup);
        task.setStatus(TaskStatus.READY);
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String error = String.format("Error creating CG %s: %s", volumeConsistencyGroup.getDisplayName(), dex);
        LOG.error(error);
        task.setFailed(error);
    }
    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) ScReplayProfile(com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)

Aggregations

ScReplayProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile)7 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)5 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)4 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)3 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)3 ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)3 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)3 List (java.util.List)3 ArrayList (java.util.ArrayList)2 ScVolumeStorageUsage (com.emc.storageos.driver.dellsc.scapi.objects.ScVolumeStorageUsage)1 PayloadFilter (com.emc.storageos.driver.dellsc.scapi.rest.PayloadFilter)1 RestResult (com.emc.storageos.driver.dellsc.scapi.rest.RestResult)1 VolumeSnapshot (com.emc.storageos.storagedriver.model.VolumeSnapshot)1 HashMap (java.util.HashMap)1