Search in sources :

Example 1 with RestoreFromCloneDriverTask

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

the class RestoreFromGroupCloneExternalDeviceJob method doTaskSucceeded.

/**
 * {@inheritDoc}
 */
@Override
protected void doTaskSucceeded(DriverTask driverTask, DbClient dbClient) throws Exception {
    s_logger.info(String.format("Successfully restored group clone: %s", driverTask.getMessage()));
    // Update the ViPR volumes representing the clones with the
    // corresponding driver clone.
    List<Volume> updatedVolumes = new ArrayList<>();
    for (URI volumeURI : _volumeURIs) {
        Volume volume = dbClient.queryObject(Volume.class, volumeURI);
        if (volume == null) {
            s_logger.error(String.format("Failed to find volume %s", volumeURI));
            throw DeviceControllerException.exceptions.objectNotFound(volumeURI);
        }
        // Update the ViPR clone with the driver clone information.
        RestoreFromCloneDriverTask restoreDriverTask = (RestoreFromCloneDriverTask) driverTask;
        List<VolumeClone> updatedClones = restoreDriverTask.getClones();
        for (VolumeClone updatedClone : updatedClones) {
            if (ExternalDeviceUtils.isVolumeExternalDeviceClone(volume, updatedClone, dbClient)) {
                ExternalDeviceUtils.updateRestoredClone(volume, updatedClone, dbClient, false);
                updatedVolumes.add(volume);
                break;
            }
        }
    }
    dbClient.updateObject(updatedVolumes);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) RestoreFromCloneDriverTask(com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask) ArrayList(java.util.ArrayList) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) URI(java.net.URI)

Example 2 with RestoreFromCloneDriverTask

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

the class RestoreFromCloneSimulatorOperation method getSuccessMessage.

@SuppressWarnings("unchecked")
@Override
public String getSuccessMessage(Object... args) {
    List<VolumeClone> clones;
    if ((args != null) && (args.length > 0)) {
        clones = (List<VolumeClone>) args[0];
    } else {
        // Must be asynchronous, so updated clones are in the task.
        RestoreFromCloneDriverTask restoreCloneTask = (RestoreFromCloneDriverTask) _task;
        clones = restoreCloneTask.getClones();
    }
    return String.format("StorageDriver: restoreFromClone : clones %s", clones.toString());
}
Also used : RestoreFromCloneDriverTask(com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Example 3 with RestoreFromCloneDriverTask

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

the class RestoreFromCloneSimulatorOperation method createDriverTask.

/**
 * Create the restore from clone task that is returned by the request.
 *
 * @param clones A list of the clones to be restored.
 */
private void createDriverTask(List<VolumeClone> clones) {
    String taskId = String.format("%s+%s+%s", StorageDriverSimulator.DRIVER_NAME, OP_NAME, UUID.randomUUID().toString());
    _log.info("Creating task {} for operation of type {}", taskId, OP_NAME);
    _task = new RestoreFromCloneDriverTask(taskId, clones);
    _task.setStatus(DriverTask.TaskStatus.PROVISIONING);
}
Also used : RestoreFromCloneDriverTask(com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask)

Example 4 with RestoreFromCloneDriverTask

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

the class RestoreFromCloneExternalDeviceJob method doTaskSucceeded.

/**
 * {@inheritDoc}
 */
@Override
protected void doTaskSucceeded(DriverTask driverTask, DbClient dbClient) throws Exception {
    // Get the ViPR volume representing the clone.
    s_logger.info(String.format("Successfully restored clone %s:%s", _volumeURI, driverTask.getMessage()));
    Volume volume = dbClient.queryObject(Volume.class, _volumeURI);
    if (volume == null) {
        s_logger.error(String.format("Failed to find volume %s", _volumeURI));
        throw DeviceControllerException.exceptions.objectNotFound(_volumeURI);
    }
    // Update the ViPR clone with the driver clone information.
    // Note that we know ViPR only allows you to restore a single
    // non-group clone at a time.
    RestoreFromCloneDriverTask restoreDriverTask = (RestoreFromCloneDriverTask) driverTask;
    List<VolumeClone> updatedClones = restoreDriverTask.getClones();
    VolumeClone updatedClone = updatedClones.get(0);
    ExternalDeviceUtils.updateRestoredClone(volume, updatedClone, dbClient, true);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) RestoreFromCloneDriverTask(com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Example 5 with RestoreFromCloneDriverTask

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

the class RestoreFromCloneSimulatorOperation method updateOnAsynchronousSuccess.

@Override
public void updateOnAsynchronousSuccess() {
    RestoreFromCloneDriverTask restoreCloneTask = (RestoreFromCloneDriverTask) _task;
    updateCloneInfo(restoreCloneTask.getClones());
}
Also used : RestoreFromCloneDriverTask(com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask)

Aggregations

RestoreFromCloneDriverTask (com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask)5 VolumeClone (com.emc.storageos.storagedriver.model.VolumeClone)3 Volume (com.emc.storageos.db.client.model.Volume)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1