use of com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateCGSnapshotJob in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method createGroupSnapshots.
/**
* Should implement create of a snapshot from a source volume that is part of a
* consistency group.
*
* Implementation note: In this method we will kick of the asynchronous creation
* of the target devices required for the CG snaps. Upon the successful
* device creation, the post operations will take place, which will include the
* creation of the target group and the group snapshot operation.
*
* @param storage [required] - StorageSystem object representing the array
* @param snapshotList [required] - BlockSnapshot URI list representing the previously created
* snap for the volume
* @param createInactive whether the snapshot needs to to be created with sync_active=true/false
* @param readOnly - Indicates if the snapshot should be read only.
* @param taskCompleter - TaskCompleter object used for the updating operation status.
* @throws DeviceControllerException
*/
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("START createGroupSnapshots");
// Target group CIM Path
CIMObjectPath targetGroupPath = null;
// List of target device ids
List<String> targetDeviceIds = null;
// The source consistency group name
String sourceGroupName = null;
try {
final BlockSnapshot first = _dbClient.queryObject(BlockSnapshot.class, snapshotList.get(0));
sourceGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(first, _dbClient);
Volume snapVolume = _dbClient.queryObject(Volume.class, first.getParent());
boolean thinProvisioning = snapVolume.getThinlyProvisioned() != null && snapVolume.getThinlyProvisioned();
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, snapVolume.getTenant().getURI());
String tenantName = tenant.getLabel();
final String snapLabelToUse = _nameGenerator.generate(tenantName, first.getLabel(), snapshotList.get(0).toString(), '-', storage.getUsingSmis80() ? SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH : SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
// CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, first, _dbClient, _helper, _cimPath);
final Map<String, List<Volume>> volumesBySizeMap = new HashMap<String, List<Volume>>();
// Group volumes by pool and size
for (URI uri : snapshotList) {
final BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, uri);
final Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
final String key = volume.getPool() + "-" + volume.getCapacity();
final List<Volume> currentVolumes = volumesBySizeMap.containsKey(key) ? volumesBySizeMap.get(key) : new ArrayList<Volume>();
currentVolumes.add(volume);
volumesBySizeMap.put(key, currentVolumes);
}
// For VMAX3, we need the target group to tag the setting instance
if (storage.checkIfVmax3() || !storage.getUsingSmis80()) {
targetDeviceIds = new ArrayList<String>();
for (Entry<String, List<Volume>> entry : volumesBySizeMap.entrySet()) {
final List<Volume> volumes = entry.getValue();
final Volume volume = volumes.get(0);
final URI poolId = volume.getPool();
CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storage, storage, volume, null);
// Create target devices based on the array model
final List<String> newDeviceIds = kickOffTargetDevicesCreation(storage, volumeGroupPath, sourceGroupName, snapLabelToUse, createInactive, thinProvisioning, volumes.size(), poolId, volume.getCapacity(), taskCompleter);
targetDeviceIds.addAll(newDeviceIds);
}
// Create target device group
targetGroupPath = ReplicationUtils.createTargetDeviceGroup(storage, sourceGroupName, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath, SYNC_TYPE.SNAPSHOT);
}
// Create CG snapshot
CIMObjectPath job = VmaxGroupOperationsUtils.internalCreateGroupReplica(storage, sourceGroupName, snapLabelToUse, targetGroupPath, createInactive, thinProvisioning, taskCompleter, SYNC_TYPE.SNAPSHOT, _dbClient, _helper, _cimPath);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateCGSnapshotJob(job, storage.getId(), !createInactive, sourceGroupName, taskCompleter)));
}
} catch (Exception e) {
final String errMsg = format("An exception occurred when trying to create snapshots for consistency group {0} on storage system {1}", sourceGroupName, storage.getId());
_log.error(errMsg, e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupSnapshots", e.getMessage());
taskCompleter.error(_dbClient, error);
// Roll back changes
rollbackCreateSnapshot(storage, targetGroupPath, targetDeviceIds, taskCompleter);
throw new SmisException(errMsg, e);
}
}
use of com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateCGSnapshotJob in project coprhd-controller by CoprHD.
the class VnxSnapshotOperations method createGroupSnapshots.
/**
* Should implement create of a snapshot from a source volume that is part of a
* consistency group.
*
* @param storage [required] - StorageSystem object representing the array
* @param snapshot [required] - BlockSnapshot URI representing the previously created
* snap for the volume
* @param createInactive - Indicates if the snapshots should be created but not
* activated
* @param readOnly - Indicates if the snapshot should be read only.
* @param taskCompleter - TaskCompleter object used for the updating operation status.
* @throws DeviceControllerException
*/
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
URI snapshot = snapshotList.get(0);
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
if (ControllerUtils.isNotInRealVNXRG(volume, _dbClient)) {
throw DeviceControllerException.exceptions.groupSnapshotNotSupported(volume.getReplicationGroupInstance());
}
// CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, snapshotObj, _dbClient, _helper, _cimPath);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
String tenantName = tenant.getLabel();
String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, _dbClient);
CIMObjectPath cgPath = _cimPath.getReplicationGroupPath(storage, groupName);
CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
CIMArgument[] inArgs = _helper.getCreateGroupReplicaInputArgumentsForVNX(storage, cgPath, createInactive, snapLabelToUse, SYNC_TYPE.SNAPSHOT.getValue());
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, replicationSvc, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateCGSnapshotJob(job, storage.getId(), !createInactive, null, taskCompleter)));
}
} catch (Exception e) {
_log.info("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
setInactive(((BlockSnapshotCreateCompleter) taskCompleter).getSnapshotURIs(), true);
}
}
Aggregations