use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class AbstractBlockFullCopyApiImpl method getVarrayFromCache.
/**
* Gets the varray from cache.
*
* @param vArrayCache the varray cache
* @param vArrayURI the virtual array
* @return the varray from cache
*/
protected VirtualArray getVarrayFromCache(Map<URI, VirtualArray> vArrayCache, URI vArrayURI) {
if (vArrayCache.get(vArrayURI) == null) {
VirtualArray vArray = _dbClient.queryObject(VirtualArray.class, vArrayURI);
vArrayCache.put(vArrayURI, vArray);
}
return vArrayCache.get(vArrayURI);
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class DefaultBlockFullCopyApiImpl method create.
/**
* {@inheritDoc}
*/
@Override
public TaskList create(List<BlockObject> fcSourceObjList, VirtualArray varray, String name, boolean createInactive, int count, String taskId) {
// Get the placement recommendations for the full copies and
// prepare the ViPR volumes to represent the full copies.
// TBD We are getting recommendations one at a time instead
// of for all full copies at the same time as was done
// previously. However, now we are allowing for creating
// full copies for multiple volume form a CG. These volumes
// could have different vpools and sizes. Therefore, I don't
// see how we can get them at the same time for all volumes
// as the capabilities could be different. I guess the
// possible result is that if the volumes are the same, they
// could be placed in the same storage pool and if the pool
// is approaching capacity, there may not actually be enough
// space in the recommended pool.
int sourceCounter = 0;
List<Volume> volumesList = new ArrayList<Volume>();
BlockObject aFCSource = null;
Map<URI, VirtualArray> vArrayCache = new HashMap<URI, VirtualArray>();
List<BlockObject> sortedSourceObjectList = sortFullCopySourceList(fcSourceObjList);
try {
for (BlockObject fcSourceObj : sortedSourceObjectList) {
// Make sure when there are multiple source objects,
// each full copy has a unique name.
aFCSource = fcSourceObj;
// volumes in VolumeGroup can be from different vArrays
varray = getVarrayFromCache(vArrayCache, fcSourceObj.getVirtualArray());
String copyName = null;
boolean inApplication = false;
if (aFCSource instanceof Volume && ((Volume) aFCSource).getApplication(_dbClient) != null) {
inApplication = true;
}
if (NullColumnValueGetter.isNotNullValue(fcSourceObj.getReplicationGroupInstance()) && inApplication) {
copyName = name + "-" + fcSourceObj.getReplicationGroupInstance() + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
} else {
copyName = name + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
}
VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(fcSourceObj, _dbClient);
VirtualPoolCapabilityValuesWrapper capabilities = getCapabilitiesForFullCopyCreate(fcSourceObj, vpool, count);
List<VolumeRecommendation> placementRecommendations = getPlacementRecommendations(fcSourceObj, capabilities, varray, vpool.getId());
volumesList.addAll(prepareClonesForEachRecommendation(copyName, name, fcSourceObj, capabilities, createInactive, placementRecommendations));
}
} catch (Exception ex) {
handlePlacementFailure(volumesList);
throw ex;
}
// get volume descriptors
List<VolumeDescriptor> volumeDescriptors = prepareVolumeDescriptorsForFullCopy(volumesList, createInactive);
// get all tasks
TaskList tasks = getTasksForCreateFullCopy(aFCSource, volumesList, taskId);
try {
BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
controller.createFullCopy(volumeDescriptors, taskId);
} catch (InternalException ie) {
handleFailedRequest(taskId, tasks, volumesList, ie, true);
}
return tasks;
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class VPlexBlockFullCopyApiImpl method prepareFullCopyPrimaryVolumes.
/**
* Places and prepares the primary copy volumes when copying a VPLEX virtual
* volume.
*
* @param name The base name for the volume.
* @param copyCount The number of copies to be made.
* @param srcBlockObject The primary volume of the VPLEX volume or snapshot being copied.
* @param srcCapabilities The capabilities of the primary volume.
* @param volumeDescriptors The list of descriptors.
* @param vPool The vPool to which the source object belongs to.
*
* @return A list of the prepared primary volumes for the VPLEX volume copy.
*/
private List<Volume> prepareFullCopyPrimaryVolumes(String name, int copyCount, BlockObject srcBlockObject, VirtualPoolCapabilityValuesWrapper srcCapabilities, List<VolumeDescriptor> volumeDescriptors, VirtualPool vPool) {
List<Volume> copyPrimaryVolumes = new ArrayList<>();
// Get the placement recommendations for the primary volume copies.
// Use the same method as is done for native volume copy.
VirtualArray vArray = _dbClient.queryObject(VirtualArray.class, srcBlockObject.getVirtualArray());
List<VolumeRecommendation> recommendations = ((VPlexScheduler) _scheduler).getBlockScheduler().getRecommendationsForVolumeClones(vArray, vPool, srcBlockObject, srcCapabilities);
if (recommendations.isEmpty()) {
throw APIException.badRequests.noStorageForPrimaryVolumesForVplexVolumeCopies();
}
// Prepare the copy volumes for each recommendation. Again,
// use the same manner as is done for native volume copy.
StringBuilder nameBuilder = new StringBuilder(name);
nameBuilder.append("-0");
int copyIndex = (copyCount > 1) ? 1 : 0;
for (VolumeRecommendation recommendation : recommendations) {
Volume volume = StorageScheduler.prepareFullCopyVolume(_dbClient, nameBuilder.toString(), srcBlockObject, recommendation, copyIndex++, srcCapabilities);
volume.addInternalFlags(Flag.INTERNAL_OBJECT);
_dbClient.persistObject(volume);
copyPrimaryVolumes.add(volume);
// Create the volume descriptor and add it to the passed list.
VolumeDescriptor volumeDescriptor = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_IMPORT_VOLUME, volume.getStorageController(), volume.getId(), volume.getPool(), srcCapabilities);
volumeDescriptors.add(volumeDescriptor);
}
return copyPrimaryVolumes;
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class FileSystemIngestionUtil method getVirtualArrayForFileSystemCreateRequest.
/**
* Gets and verifies that the varray passed in the request is
* accessible to the tenant.
*
* @param project
* A reference to the project.
* @param neighborhoodUri
* The Varray URI.
*
* @return A reference to the varray.
*/
public static VirtualArray getVirtualArrayForFileSystemCreateRequest(Project project, URI neighborhoodUri, PermissionsHelper permissionsHelper, DbClient dbClient) {
ArgValidator.checkUri(neighborhoodUri);
VirtualArray neighborhood = dbClient.queryObject(VirtualArray.class, neighborhoodUri);
ArgValidator.checkEntity(neighborhood, neighborhoodUri, false);
permissionsHelper.checkTenantHasAccessToVirtualArray(project.getTenantOrg().getURI(), neighborhood);
return neighborhood;
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class ProtectionValidator method validateProtectionCopies.
/**
* Validates the RP protection copies. The protection copy consists of
* a virtual array, virtual pool, and copy policy - each of which are
* validated if they are specified.
*
* @param copies The protection copies
* @param dbClient The dbclient
*/
private void validateProtectionCopies(Set<VirtualPoolProtectionVirtualArraySettingsParam> copies, DbClient dbClient) {
if (copies != null) {
for (VirtualPoolProtectionVirtualArraySettingsParam settingsParam : copies) {
// a protection copy.
if (settingsParam.getVarray() != null && !settingsParam.getVarray().toString().isEmpty()) {
ArgValidator.checkUri(settingsParam.getVarray());
VirtualArray neighborhood = dbClient.queryObject(VirtualArray.class, settingsParam.getVarray());
ArgValidator.checkEntity(neighborhood, settingsParam.getVarray(), false);
} else {
throw APIException.badRequests.protectionVirtualPoolArrayMissing();
}
// Validate the protection copy virtual pool if it has been specified.
if (settingsParam.getVpool() != null && !String.valueOf(settingsParam.getVpool()).isEmpty()) {
ArgValidator.checkUri(settingsParam.getVpool());
VirtualPool protectionCopyVPool = dbClient.queryObject(VirtualPool.class, settingsParam.getVpool());
ArgValidator.checkEntity(protectionCopyVPool, settingsParam.getVpool(), false);
}
// Validate the copy policy
if (settingsParam.getCopyPolicy() != null && settingsParam.getCopyPolicy().getJournalSize() != null) {
if (!isParsableToDouble(settingsParam.getCopyPolicy().getJournalSize()) && !settingsParam.getCopyPolicy().getJournalSize().matches(JOURNAL_REGEX_1) && !settingsParam.getCopyPolicy().getJournalSize().matches(JOURNAL_REGEX_2) && !settingsParam.getCopyPolicy().getJournalSize().equals(JOURNAL_MIN)) {
throw APIException.badRequests.protectionVirtualPoolJournalSizeInvalid("copy", settingsParam.getCopyPolicy().getJournalSize());
}
}
}
}
}
Aggregations