use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class AbstractMirrorOperations method createSingleVolumeMirror.
@Override
public void createSingleVolumeMirror(StorageSystem storage, URI mirror, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("createSingleVolumeMirror operation START");
try {
BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirror);
StoragePool targetPool = _dbClient.queryObject(StoragePool.class, mirrorObj.getPool());
Volume source = _dbClient.queryObject(Volume.class, mirrorObj.getSource());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, source.getTenant().getURI());
String tenantName = tenant.getLabel();
String targetLabelToUse = _nameGenerator.generate(tenantName, mirrorObj.getLabel(), mirror.toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH);
CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
CIMArgument[] inArgs = null;
if (storage.checkIfVmax3()) {
CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storage, storage, source, targetPool);
CIMInstance replicaSettingData = getDefaultReplicationSettingData(storage);
inArgs = _helper.getCreateElementReplicaMirrorInputArguments(storage, source, targetPool, createInactive, targetLabelToUse, volumeGroupPath, replicaSettingData);
} else {
inArgs = _helper.getCreateElementReplicaMirrorInputArguments(storage, source, targetPool, createInactive, targetLabelToUse);
}
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, replicationSvcPath, SmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateMirrorJob(job, storage.getId(), !createInactive, taskCompleter)));
// Resynchronizing state applies to the initial copy as well as future
// re-synchronization's.
mirrorObj.setSyncState(SynchronizationState.RESYNCHRONIZING.toString());
_dbClient.persistObject(mirrorObj);
}
} catch (final InternalException e) {
_log.info("Problem making SMI-S call: ", e);
taskCompleter.error(_dbClient, e);
} catch (Exception e) {
_log.info("Problem making SMI-S call: ", e);
ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class AbstractReplicaOperations method fractureListReplica.
@Override
public void fractureListReplica(StorageSystem storage, List<URI> replicaList, Boolean sync, TaskCompleter taskCompleter) {
_log.info("fractureListReplica operation START");
try {
List<? extends BlockObject> replicas = BlockObject.fetch(_dbClient, replicaList);
int operation = (sync != null && sync) ? SmisConstants.SPLIT_VALUE : SmisConstants.FRACTURE_VALUE;
int copyState = (operation == SmisConstants.SPLIT_VALUE) ? SmisConstants.SPLIT : SmisConstants.FRACTURED;
modifyListReplica(storage, replicaList, replicas, operation, copyState);
for (BlockObject replica : replicas) {
if (replica instanceof BlockMirror) {
((BlockMirror) replica).setSyncState(SynchronizationState.FRACTURED.name());
} else if (replica instanceof Volume) {
((Volume) replica).setReplicaState(ReplicationState.SYNCHRONIZED.name());
}
}
_dbClient.updateObject(replicas);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Problem making SMI-S call", e);
ServiceError error = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, error);
}
_log.info("fractureListReplica operation END");
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class StorageScheduler method initializeMirror.
/**
* Adds a BlockMirror structure for a Volume. It also calls addMirrorToVolume to
* link the mirror into the volume's mirror set.
*
* @param volume Volume
* @param vPool
* @param recommendedPoolURI Pool that should be used to create the mirror
* @param volumeLabel
* @param dbClient
* @return BlockMirror (persisted)
*/
public static BlockMirror initializeMirror(Volume volume, VirtualPool vPool, URI recommendedPoolURI, String volumeLabel, DbClient dbClient) {
BlockMirror createdMirror = new BlockMirror();
createdMirror.setSource(new NamedURI(volume.getId(), volume.getLabel()));
createdMirror.setId(URIUtil.createId(BlockMirror.class));
URI cgUri = volume.getConsistencyGroup();
if (!NullColumnValueGetter.isNullURI(cgUri)) {
createdMirror.setConsistencyGroup(cgUri);
}
createdMirror.setLabel(volumeLabel);
createdMirror.setStorageController(volume.getStorageController());
createdMirror.setSystemType(volume.getSystemType());
createdMirror.setVirtualArray(volume.getVirtualArray());
// Hence for timebeing, we are setting the source policy in mirror.
if (!NullColumnValueGetter.isNullURI(volume.getAutoTieringPolicyUri())) {
createdMirror.setAutoTieringPolicyUri(volume.getAutoTieringPolicyUri());
}
createdMirror.setProtocol(new StringSet());
createdMirror.getProtocol().addAll(volume.getProtocol());
createdMirror.setCapacity(volume.getCapacity());
createdMirror.setProject(new NamedURI(volume.getProject().getURI(), createdMirror.getLabel()));
createdMirror.setTenant(new NamedURI(volume.getTenant().getURI(), createdMirror.getLabel()));
createdMirror.setPool(recommendedPoolURI);
createdMirror.setVirtualPool(vPool.getId());
createdMirror.setSyncState(SynchronizationState.UNKNOWN.toString());
createdMirror.setSyncType(BlockMirror.MIRROR_SYNC_TYPE);
createdMirror.setThinlyProvisioned(volume.getThinlyProvisioned());
dbClient.createObject(createdMirror);
addMirrorToVolume(volume, createdMirror, dbClient);
return createdMirror;
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class StorageScheduler method prepareRecommendedVolumes.
/**
* Create volumes from recommendation object.
*
* @param param volume creation parameters
* @param task task
* @param taskList task list
* @param project project
* @param neighborhood virtual array
* @param vPool virtual pool
* @param volumeCount number of volumes to create
* @param recommendations recommendation structures
* @param consistencyGroup consistency group to use
* @param volumeCounter how many volumes are created
* @param volumeLabel volume label
* @param preparedVolumes volumes that have been prepared
* @param cosCapabilities virtual pool wrapper
* @param createInactive create the device in an inactive state
*/
/**
* Create volumes from recommendations objects.
*
* @param size -- size of volumes in bytes
* @param task -- overall task id
* @param taskList -- a TaskList new tasks may be inserted into
* @param project -- Project object
* @param neighborhood -- Virtual array
* @param vPool -- Virtual pool
* @param volumeCount -- number of like volumes to be created
* @param recommendations -- List of Recommendation objects describing pools to use for volumes
* @param consistencyGroup -- The BlockConsistencyGroup object to be used for the volumes
* @param volumeCounter -- The current volume counter, used to generate unique names for like volumes
* @param volumeLabel -- Label (prefix) of the volumes to be created
* @param preparedVolumes -- Output argument that receives the prepared volumes
* @param cosCapabilities - VirtualPoolCapabilityValuesWrapper contains parameters for volume creation
* @param createInactive-- used to set the Volume syncActive flag (to the inverted sense of createInactive)
*/
public void prepareRecommendedVolumes(Long size, String task, TaskList taskList, Project project, VirtualArray neighborhood, VirtualPool vPool, Integer volumeCount, List<Recommendation> recommendations, BlockConsistencyGroup consistencyGroup, int volumeCounter, String volumeLabel, List<Volume> preparedVolumes, VirtualPoolCapabilityValuesWrapper cosCapabilities, Boolean createInactive) {
Iterator<Recommendation> recommendationsIter = recommendations.iterator();
while (recommendationsIter.hasNext()) {
VolumeRecommendation recommendation = (VolumeRecommendation) recommendationsIter.next();
// if id is already set in recommendation, do not prepare the volume (volume already exists)
if (recommendation.getId() != null) {
continue;
}
// prepare block volume
if (recommendation.getType().toString().equals(VolumeRecommendation.VolumeType.BLOCK_VOLUME.toString())) {
String newVolumeLabel = AbstractBlockServiceApiImpl.generateDefaultVolumeLabel(volumeLabel, volumeCounter++, volumeCount);
// Grab the existing volume and task object from the incoming task list
Volume volume = getPrecreatedVolume(_dbClient, taskList, newVolumeLabel);
boolean volumePrecreated = false;
if (volume != null) {
volumePrecreated = true;
}
long thinVolumePreAllocationSize = 0;
if (null != vPool.getThinVolumePreAllocationPercentage()) {
thinVolumePreAllocationSize = VirtualPoolUtil.getThinVolumePreAllocationSize(vPool.getThinVolumePreAllocationPercentage(), size);
}
volume = prepareVolume(_dbClient, volume, size, thinVolumePreAllocationSize, project, neighborhood, vPool, recommendation, newVolumeLabel, consistencyGroup, cosCapabilities, createInactive);
// set volume id in recommendation
recommendation.setId(volume.getId());
// add volume to reserved capacity map of storage pool
addVolumeCapacityToReservedCapacityMap(_dbClient, volume);
preparedVolumes.add(volume);
if (!volumePrecreated) {
Operation op = _dbClient.createTaskOpStatus(Volume.class, volume.getId(), task, ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
volume.getOpStatus().put(task, op);
TaskResourceRep volumeTask = toTask(volume, task, op);
// This task addition is inconsequential since we've already returned the source volume tasks.
// It is good to continue to have a task associated with this volume AND store its status in the volume.
taskList.getTaskList().add(volumeTask);
}
} else if (recommendation.getType().toString().equals(VolumeRecommendation.VolumeType.BLOCK_LOCAL_MIRROR.toString())) {
// prepare local mirror based on source volume and storage pool recommendation
VolumeRecommendation volumeRecommendation = (VolumeRecommendation) recommendation.getParameter(VolumeRecommendation.BLOCK_VOLUME);
URI volumeId = volumeRecommendation.getId();
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
String mirrorLabel = volumeLabel;
if (volume.isInCG()) {
mirrorLabel = ControllerUtils.getMirrorLabel(volume.getLabel(), volumeLabel);
}
if (volumeCount > 1) {
mirrorLabel = ControllerUtils.getMirrorLabel(mirrorLabel, volumeCounter++);
}
// Prepare a single mirror based on source volume and storage pool recommendation
BlockMirror mirror = initializeMirror(volume, vPool, recommendation.getCandidatePools().get(0), mirrorLabel, _dbClient);
// set mirror id in recommendation
recommendation.setId(mirror.getId());
preparedVolumes.add(mirror);
// add mirror to reserved capacity map of storage pool
addVolumeCapacityToReservedCapacityMap(_dbClient, mirror);
}
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class VmaxMirrorOperations method detachGroupMirrors.
@Override
public void detachGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean deleteGroup, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("START detach group mirror operation");
if (!storage.getUsingSmis80()) {
throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
}
try {
callEMCRefreshIfRequired(_dbClient, _helper, storage, mirrorList);
CIMObjectPath groupSynchronized = ReplicationUtils.getMirrorGroupSynchronizedPath(storage, mirrorList.get(0), _dbClient, _helper, _cimPath);
if (_helper.checkExists(storage, groupSynchronized, false, false) != null) {
CIMArgument[] detachCGMirrorInput = _helper.getDetachSynchronizationInputArguments(groupSynchronized);
// Invoke method to detach local mirrors
UnsignedInteger32 result = (UnsignedInteger32) _helper.callModifyReplica(storage, detachCGMirrorInput, new CIMArgument[5]);
if (JOB_COMPLETED_NO_ERROR.equals(result)) {
List<BlockMirror> mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
if (deleteGroup) {
ReplicationUtils.deleteReplicationGroup(storage, mirrors.get(0).getReplicationGroupInstance(), _dbClient, _helper, _cimPath);
}
// Set mirrors replication group to null
for (BlockMirror mirror : mirrors) {
if (deleteGroup) {
mirror.setConsistencyGroup(NullColumnValueGetter.getNullURI());
mirror.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
}
mirror.setSyncState(NullColumnValueGetter.getNullStr());
}
_dbClient.persistObject(mirrors);
taskCompleter.ready(_dbClient);
} else {
String msg = String.format("SMI-S call returned unsuccessfully: %s", result);
taskCompleter.error(_dbClient, DeviceControllerException.errors.smis.jobFailed(msg));
}
} else {
_log.error("Unable to find group synchronized {}", groupSynchronized.toString());
BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(mirror.getReplicationGroupInstance());
taskCompleter.error(_dbClient, error);
}
} catch (Exception e) {
_log.error("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, error);
}
}
Aggregations