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());
}
Aggregations