Search in sources :

Example 1 with CinderSnapshotCreateJob

use of com.emc.storageos.volumecontroller.impl.cinder.job.CinderSnapshotCreateJob in project coprhd-controller by CoprHD.

the class CinderStorageDevice method doCreateSnapshot.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doCreateSnapshot
     * (com.emc.storageos.db.client.model.StorageSystem,
     * java.util.List,
     * java.lang.Boolean,
     * java.lang.Boolean,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doCreateSnapshot(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.debug("In CinderStorageDevice.doCreateSnapshot method.");
    boolean operationFailed = false;
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Snapshot Start - Array:%s, ", storage.getSerialNumber()));
    BlockSnapshot snapshot = null;
    try {
        snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotList.get(0));
        Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
        logMsgBuilder.append(String.format("%nSnapshot:%s for Volume %s", snapshot.getLabel(), volume.getLabel()));
        log.info(logMsgBuilder.toString());
        CinderEndPointInfo endPoint = CinderUtils.getCinderEndPoint(storage.getActiveProviderURI(), dbClient);
        CinderApi cinderApi = cinderApiFactory.getApi(storage.getActiveProviderURI(), endPoint);
        String snapshotID = cinderApi.createSnapshot(volume.getNativeId(), snapshot.getLabel());
        if (snapshotID != null) {
            CinderJob createSnapshotJob = new CinderSnapshotCreateJob(snapshotID, snapshot.getLabel(), volume.getStorageController(), CinderConstants.ComponentType.snapshot.name(), endPoint, taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(createSnapshotJob));
        }
    } catch (Exception e) {
        String message = String.format("Exception when trying to create snapshot(s) on array %s", storage.getSerialNumber());
        log.error(message, e);
        ServiceError error = DeviceControllerErrors.cinder.operationFailed("doCreateSnapshot", e.getMessage());
        taskCompleter.error(dbClient, error);
        operationFailed = true;
    }
    if (operationFailed && null != snapshot) {
        snapshot.setInactive(true);
        dbClient.persistObject(snapshot);
    }
    logMsgBuilder = new StringBuilder(String.format("Create Snapshot End - Array:%s, ", storage.getSerialNumber()));
    log.info(logMsgBuilder.toString());
}
Also used : CinderSnapshotCreateJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderSnapshotCreateJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CinderApi(com.emc.storageos.cinder.api.CinderApi) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CinderJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderJob) CinderException(com.emc.storageos.cinder.errorhandling.CinderException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

CinderEndPointInfo (com.emc.storageos.cinder.CinderEndPointInfo)1 CinderApi (com.emc.storageos.cinder.api.CinderApi)1 CinderException (com.emc.storageos.cinder.errorhandling.CinderException)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 Volume (com.emc.storageos.db.client.model.Volume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 CinderJob (com.emc.storageos.volumecontroller.impl.cinder.job.CinderJob)1 CinderSnapshotCreateJob (com.emc.storageos.volumecontroller.impl.cinder.job.CinderSnapshotCreateJob)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1