Search in sources :

Example 16 with VolumeSnapshot

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

the class HP3PARSnapshotHelper method restoreSnapshot.

public DriverTask restoreSnapshot(List<VolumeSnapshot> snapshots, DriverTask task, Registry driverRegistry) {
    // 3par system)
    for (VolumeSnapshot snap : snapshots) {
        try {
            _log.info("3PARDriver: restoreSnapshot for storage system system id {}, snapshot name {} , native id {} , all = {} - start", snap.getStorageSystemId(), snap.getDisplayName(), snap.getNativeId(), snap.toString());
            // get Api client
            HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(snap.getStorageSystemId(), driverRegistry);
            // restore virtual copy
            hp3parApi.restoreVirtualCopy(snap.getNativeId());
            task.setStatus(DriverTask.TaskStatus.READY);
            _log.info("3PARDriver: restoreSnapshot for storage system  id {}, snapshot display name {} - end", snap.getStorageSystemId(), snap.getDisplayName());
        } catch (Exception e) {
            String msg = String.format("3PARDriver: Unable to restore snapshot display name %s with native id %s for storage system id %s; Error: %s.\n", snap.getDisplayName(), snap.getNativeId(), snap.getStorageSystemId(), e.getMessage());
            _log.error(msg);
            task.setMessage(msg);
            task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
            e.printStackTrace();
        }
    }
    return task;
}
Also used : VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 17 with VolumeSnapshot

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

the class DellSCUtil method getVolumeSnapshotFromReplay.

/**
 * Gets a VolumeSnapshot object for a given replay.
 *
 * @param replay The Storage Center snapshot.
 * @param snapshot The VolumeSnapshot object to populate or null.
 * @return The VolumeSnapshot object.
 */
public VolumeSnapshot getVolumeSnapshotFromReplay(ScReplay replay, VolumeSnapshot snapshot) {
    VolumeSnapshot snap = snapshot;
    if (snap == null) {
        snap = new VolumeSnapshot();
    }
    snap.setNativeId(replay.instanceId);
    snap.setDeviceLabel(replay.instanceName);
    snap.setDisplayName(replay.instanceName);
    snap.setStorageSystemId(String.valueOf(replay.scSerialNumber));
    snap.setWwn(replay.globalIndex);
    snap.setParentId(replay.createVolume.instanceId);
    snap.setAllocatedCapacity(SizeUtil.sizeStrToBytes(replay.size));
    snap.setProvisionedCapacity(SizeUtil.sizeStrToBytes(replay.size));
    return snap;
}
Also used : VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 18 with VolumeSnapshot

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

the class DellSCSnapshots method createVolumeSnapshot.

/**
 * Create volume snapshots.
 *
 * @param snapshots The list of snapshots to create.
 * @param storageCapabilities The requested capabilities of the snapshots.
 * @return The snapshot creation task.
 */
public DriverTask createVolumeSnapshot(List<VolumeSnapshot> snapshots, StorageCapabilities storageCapabilities) {
    DellSCDriverTask task = new DellSCDriverTask("createVolumeSnapshot");
    StringBuilder errBuffer = new StringBuilder();
    int createCount = 0;
    for (VolumeSnapshot snapshot : snapshots) {
        try {
            StorageCenterAPI api = connectionManager.getConnection(snapshot.getStorageSystemId());
            // Make sure we can create a replay.
            // Automated tests have an artificial workflow where they create a volume
            // and try to create a snapshot without ever having data written to it. The
            // SC array will not activate a volume until it is mapped, so if we try to
            // create a snapshot right away it will fail. As a workaround, since we know
            // this should only ever happen in a test scenario, we temporarily map/unmap
            // it to get it to be activated.
            api.checkAndInitVolume(snapshot.getParentId());
            ScReplay replay = api.createReplay(snapshot.getParentId());
            util.getVolumeSnapshotFromReplay(replay, snapshot);
            createCount++;
        } catch (DellSCDriverException | StorageCenterAPIException dex) {
            String error = String.format("Error creating snapshot of volume %s: %s", snapshot.getParentId(), dex);
            errBuffer.append(String.format("%s%n", error));
        }
    }
    task.setMessage(errBuffer.toString());
    if (createCount == snapshots.size()) {
        task.setStatus(TaskStatus.READY);
    } else if (createCount == 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) ScReplay(com.emc.storageos.driver.dellsc.scapi.objects.ScReplay) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 19 with VolumeSnapshot

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

the class StorageDriverSimulator method getVolumeSnapshots.

@Override
public List<VolumeSnapshot> getVolumeSnapshots(StorageVolume volume) {
    List<VolumeSnapshot> snapshots = new ArrayList<>();
    for (int i = 0; i < NUMBER_OF_SNAPS_FOR_VOLUME; i++) {
        VolumeSnapshot snapshot = new VolumeSnapshot();
        snapshot.setParentId(volume.getNativeId());
        snapshot.setNativeId(volume.getNativeId() + "snap-" + i);
        snapshot.setDeviceLabel(volume.getNativeId() + "snap-" + i);
        snapshot.setStorageSystemId(volume.getStorageSystemId());
        snapshot.setAccessStatus(StorageObject.AccessStatus.READ_ONLY);
        if (SNAPS_IN_CG) {
            snapshot.setConsistencyGroup(volume.getConsistencyGroup() + "snapSet-" + i);
        }
        snapshot.setAllocatedCapacity(1000L);
        snapshot.setProvisionedCapacity(volume.getProvisionedCapacity());
        snapshot.setWwn(String.format("%s%s", snapshot.getStorageSystemId(), snapshot.getNativeId()));
        snapshots.add(snapshot);
        if (GENERATE_EXPORT_DATA) {
            // generate export data for this snap --- the same export data as for its parent volume
            generateExportDataForVolumeReplica(volume, snapshot);
        }
    }
    return snapshots;
}
Also used : ArrayList(java.util.ArrayList) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 20 with VolumeSnapshot

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

the class StorageDriverSimulator method createConsistencyGroupSnapshot.

@Override
public DriverTask createConsistencyGroupSnapshot(VolumeConsistencyGroup consistencyGroup, List<VolumeSnapshot> snapshots, List<CapabilityInstance> capabilities) {
    String snapTimestamp = Long.toString(System.currentTimeMillis());
    for (VolumeSnapshot snapshot : snapshots) {
        snapshot.setNativeId("snap-" + snapshot.getParentId() + consistencyGroup.getDisplayName() + UUID.randomUUID().toString());
        snapshot.setConsistencyGroup(snapTimestamp);
        snapshot.setSnapSetId(snapTimestamp);
    }
    String taskType = "create-group-snapshot";
    String taskId = String.format("%s+%s+%s", DRIVER_NAME, taskType, UUID.randomUUID().toString());
    DriverTask task = new DriverSimulatorTask(taskId);
    task.setStatus(DriverTask.TaskStatus.READY);
    task.setMessage("Created snapshots for consistency group " + snapshots.get(0).getConsistencyGroup());
    _log.info("StorageDriver: createGroupSnapshot information for storage system {}, snapshots nativeIds {} - end", snapshots.get(0).getStorageSystemId(), snapshots.toString());
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Aggregations

VolumeSnapshot (com.emc.storageos.storagedriver.model.VolumeSnapshot)22 DriverTask (com.emc.storageos.storagedriver.DriverTask)8 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)7 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)7 ArrayList (java.util.ArrayList)7 Volume (com.emc.storageos.db.client.model.Volume)6 BlockStorageDriver (com.emc.storageos.storagedriver.BlockStorageDriver)5 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 URI (java.net.URI)4 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)3 ScReplay (com.emc.storageos.driver.dellsc.scapi.objects.ScReplay)3 VolumeDetailsCommandResult (com.emc.storageos.hp3par.command.VolumeDetailsCommandResult)3 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)2 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)2 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)2 VolumeClone (com.emc.storageos.storagedriver.model.VolumeClone)2 HashMap (java.util.HashMap)2 StringSet (com.emc.storageos.db.client.model.StringSet)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1