Search in sources :

Example 16 with StorageCenterAPI

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

the class DellSCConnectionManager method getConnection.

/**
 * Gets a new Storage Center API connection.
 *
 * @param host The host name or IP.
 * @param port The connection port.
 * @param user The connection user name.
 * @param password The connection password.
 * @param isProvider The isProvider flag to indicate the provider call
 * @return The API connection.
 * @throws StorageCenterAPIException
 */
@SuppressWarnings("resource")
public StorageCenterAPI getConnection(String host, int port, String user, String password, boolean isProvider) throws StorageCenterAPIException {
    // First see if we already have a connection for this system
    StorageCenterAPI result = connectionMap.get(host);
    if (result == null) {
        result = StorageCenterAPI.openConnection(host, port, user, password);
        StorageCenter[] scs = result.getStorageCenterInfo();
        for (StorageCenter sc : scs) {
            // Saving per system for backward compatibility
            saveConnectionInfo(sc.scSerialNumber, host, port, user, password);
            systemLookup.put(sc.scSerialNumber, host);
        }
        saveConnectionInfo(host, host, port, user, password);
        connectionMap.put(host, result);
    } else {
        // Make sure our connection is still good
        result = validateConnection(result, result.getHost());
        /*
             * Update the SC Connection Info only during storage provider discovery
             * bugfix-COP-25081-dell-sc-fail-to-recognize-new-arrays
             */
        if (isProvider) {
            StorageCenter[] scs = result.getStorageCenterInfo();
            for (StorageCenter sc : scs) {
                // Saving per system for backward compatibility
                saveConnectionInfo(sc.scSerialNumber, host, port, user, password);
                systemLookup.put(sc.scSerialNumber, host);
            }
        }
    }
    return result;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) StorageCenter(com.emc.storageos.driver.dellsc.scapi.objects.StorageCenter)

Example 17 with StorageCenterAPI

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

the class DellSCConsistencyGroups method createConsistencyGroupSnapshot.

/**
 * Create consistency group snapshots.
 *
 * @param volumeConsistencyGroup The consistency group.
 * @param snapshots The snapshots.
 * @param capabilities The requested capabilities.
 * @return The create task.
 */
public DriverTask createConsistencyGroupSnapshot(VolumeConsistencyGroup volumeConsistencyGroup, List<VolumeSnapshot> snapshots, List<CapabilityInstance> capabilities) {
    DellSCDriverTask task = new DellSCDriverTask("createCGSnapshot");
    try {
        StorageCenterAPI api = connectionManager.getConnection(volumeConsistencyGroup.getStorageSystemId());
        // Make sure all of our volumes are active for the automated tests that try to
        // snap right away before writing anything to them.
        ScVolume[] volumes = api.getConsistencyGroupVolumes(volumeConsistencyGroup.getNativeId());
        for (ScVolume volume : volumes) {
            api.checkAndInitVolume(volume.instanceId);
        }
        ScReplay[] replays = api.createConsistencyGroupSnapshots(volumeConsistencyGroup.getNativeId());
        if (populateCgSnapshotInfo(snapshots, replays)) {
            task.setStatus(TaskStatus.READY);
        } else {
            task.setStatus(TaskStatus.PARTIALLY_FAILED);
        }
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String error = String.format("Error creating CG snapshots %s: %s", volumeConsistencyGroup.getDisplayName(), dex);
        LOG.error(error);
        task.setFailed(error);
    }
    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) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)

Example 18 with StorageCenterAPI

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

Example 19 with StorageCenterAPI

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

the class DellSCConsistencyGroups method addVolumesToConsistencyGroup.

/**
 * Add volumes to consistency groups.
 *
 * @param volumes The volumes to add.
 * @param capabilities The requested capabilities.
 * @return The driver task.
 */
public DriverTask addVolumesToConsistencyGroup(List<StorageVolume> volumes, StorageCapabilities capabilities) {
    DellSCDriverTask task = new DellSCDriverTask("addVolumesToCG");
    StringBuilder errBuffer = new StringBuilder();
    int addCount = 0;
    for (StorageVolume volume : volumes) {
        String ssn = volume.getStorageSystemId();
        try {
            StorageCenterAPI api = connectionManager.getConnection(ssn);
            api.addVolumeToConsistencyGroup(volume.getNativeId(), volume.getConsistencyGroup());
            addCount++;
        } catch (StorageCenterAPIException | DellSCDriverException dex) {
            String error = String.format("Error adding volume %s to consistency group: %s", volume.getNativeId(), dex);
            LOG.warn(error);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (addCount == volumes.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (addCount == 0) {
        task.setStatus(TaskStatus.FAILED);
    } else {
        task.setStatus(TaskStatus.PARTIALLY_FAILED);
    }
    return task;
}
Also used : 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 20 with StorageCenterAPI

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

the class DellSCDiscovery method getStorageVolumes.

/**
 * Discover storage volumes.
 *
 * @param storageSystem The storage system on which to discover.
 * @param storageVolumes The discovered storage volumes.
 * @param token Used for paging. Input 0 indicates that the first page should be returned. Output 0 indicates
 *            that last page was returned
 * @return The discovery task.
 */
public DriverTask getStorageVolumes(StorageSystem storageSystem, List<StorageVolume> storageVolumes, MutableInt token) {
    LOG.info("Getting volumes from {}", storageSystem.getNativeId());
    DellSCDriverTask task = new DellSCDriverTask("getVolumes");
    try {
        StorageCenterAPI api = connectionManager.getConnection(storageSystem.getNativeId());
        Map<ScReplayProfile, List<String>> cgInfo = util.getGCInfo(api, storageSystem.getNativeId());
        ScVolume[] volumes = api.getAllVolumes(storageSystem.getNativeId());
        for (ScVolume volume : volumes) {
            if (volume.inRecycleBin || volume.liveVolume || volume.cmmDestination || volume.replicationDestination) {
                continue;
            }
            StorageVolume driverVol = util.getStorageVolumeFromScVolume(api, volume, cgInfo);
            storageVolumes.add(driverVol);
        }
        task.setStatus(TaskStatus.READY);
    } catch (DellSCDriverException | StorageCenterAPIException e) {
        String msg = String.format("Error getting volume info: %s", e);
        LOG.warn(msg);
        task.setFailed(msg);
    }
    return task;
}
Also used : ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) 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) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)27 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)25 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)24 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)22 ScVolume (com.emc.storageos.driver.dellsc.scapi.objects.ScVolume)11 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)7 DriverTask (com.emc.storageos.storagedriver.DriverTask)5 ArrayList (java.util.ArrayList)5 ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)4 ScReplayProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScReplayProfile)4 ScCopyMirrorMigrate (com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate)3 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)3 StorageCenter (com.emc.storageos.driver.dellsc.scapi.objects.StorageCenter)3 StoragePort (com.emc.storageos.storagedriver.model.StoragePort)3 VolumeMirror (com.emc.storageos.storagedriver.model.VolumeMirror)3 VolumeSnapshot (com.emc.storageos.storagedriver.model.VolumeSnapshot)3 List (java.util.List)3 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)2 ScMapping (com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)2 ScMappingProfile (com.emc.storageos.driver.dellsc.scapi.objects.ScMappingProfile)2