use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class BucketService method initiateBucketCreation.
private TaskResourceRep initiateBucketCreation(BucketParam param, Project project, TenantOrg tenant, DataObject.Flag[] flags) throws InternalException {
ArgValidator.checkFieldUriType(param.getVpool(), VirtualPool.class, "vpool");
ArgValidator.checkFieldUriType(param.getVarray(), VirtualArray.class, "varray");
Long softQuota = SizeUtil.translateSize(param.getSoftQuota());
Long hardQuota = SizeUtil.translateSize(param.getHardQuota());
Integer retention = Integer.valueOf(param.getRetention());
// Hard Quota should be more than SoftQuota
verifyQuotaValues(softQuota, hardQuota, param.getLabel());
// check varray
VirtualArray neighborhood = _dbClient.queryObject(VirtualArray.class, param.getVarray());
ArgValidator.checkEntity(neighborhood, param.getVarray(), false);
_permissionsHelper.checkTenantHasAccessToVirtualArray(tenant.getId(), neighborhood);
// check vpool reference
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, param.getVpool());
_permissionsHelper.checkTenantHasAccessToVirtualPool(tenant.getId(), vpool);
ArgValidator.checkEntity(vpool, param.getVpool(), false);
if (!VirtualPool.Type.object.name().equals(vpool.getType())) {
throw APIException.badRequests.virtualPoolNotForObjectStorage(VirtualPool.Type.object.name());
}
// verify retention. Its validated only if Retention is configured.
if (retention != 0 && vpool.getMaxRetention() != 0 && retention > vpool.getMaxRetention()) {
throw APIException.badRequests.insufficientRetentionForVirtualPool(vpool.getLabel(), "bucket");
}
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, Integer.valueOf(1));
capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.FALSE);
capabilities.put(VirtualPoolCapabilityValuesWrapper.QUOTA, hardQuota.toString());
Map<String, Object> attributeMap = new HashMap<String, Object>();
List<BucketRecommendation> placement = _bucketScheduler.placeBucket(neighborhood, vpool, capabilities, attributeMap);
if (placement.isEmpty()) {
StringBuffer errorMessage = new StringBuffer();
if (attributeMap.get(AttributeMatcher.ERROR_MESSAGE) != null) {
errorMessage = (StringBuffer) attributeMap.get(AttributeMatcher.ERROR_MESSAGE);
}
throw APIException.badRequests.noStoragePools(neighborhood.getLabel(), vpool.getLabel(), errorMessage.toString());
}
// Randomly select a recommended pool
Collections.shuffle(placement);
BucketRecommendation recommendation = placement.get(0);
String task = UUID.randomUUID().toString();
Bucket bucket = prepareBucket(param, project, tenant, neighborhood, vpool, flags, recommendation);
_log.info(String.format("createBucket --- Bucket: %1$s, StoragePool: %2$s, StorageSystem: %3$s", bucket.getId(), recommendation.getSourceStoragePool(), recommendation.getSourceStorageSystem()));
Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.CREATE_BUCKET);
op.setDescription("Bucket Create");
// Controller invocation
StorageSystem system = _dbClient.queryObject(StorageSystem.class, recommendation.getSourceStorageSystem());
ObjectController controller = getController(ObjectController.class, system.getSystemType());
controller.createBucket(recommendation.getSourceStorageSystem(), recommendation.getSourceStoragePool(), bucket.getId(), bucket.getName(), bucket.getNamespace(), bucket.getRetention(), bucket.getHardQuota(), bucket.getSoftQuota(), bucket.getOwner(), task);
auditOp(OperationTypeEnum.CREATE_BUCKET, true, AuditLogManager.AUDITOP_BEGIN, param.getLabel(), param.getHardQuota(), neighborhood.getId().toString(), project == null ? null : project.getId().toString());
return toTask(bucket, task, op);
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method prepareFileSystems.
/**
* Prepare the source and target filesystems
*
* @param param
* @param task
* @param taskList
* @param project
* @param varray
* @param vpool
* @param recommendations
* @param cosCapabilities
* @param createInactive
* @return
*/
public List<FileShare> prepareFileSystems(FileSystemParam param, String task, TaskList taskList, Project project, TenantOrg tenantOrg, DataObject.Flag[] flags, VirtualArray varray, VirtualPool vpool, List<Recommendation> recommendations, VirtualPoolCapabilityValuesWrapper cosCapabilities, Boolean createInactive) {
List<FileShare> preparedFileSystems = new ArrayList<>();
Iterator<Recommendation> recommendationsIter = recommendations.iterator();
while (recommendationsIter.hasNext()) {
FileMirrorRecommendation recommendation = (FileMirrorRecommendation) recommendationsIter.next();
// If id is already set in recommendation, do not prepare the fileSystem (fileSystem already exists)
if (recommendation.getId() != null) {
continue;
}
// Get the source file share!!
FileShare sourceFileShare = getPrecreatedFile(taskList, param.getLabel());
if (!cosCapabilities.createMirrorExistingFileSystem()) {
// Set the recommendation only for source file systems which are not meant for vpool change!!
_log.info(String.format("createFileSystem --- FileShare: %1$s, StoragePool: %2$s, StorageSystem: %3$s", sourceFileShare.getId(), recommendation.getSourceStoragePool(), recommendation.getSourceStorageSystem()));
validateFileSystem(recommendation, sourceFileShare);
}
// set the source mirror recommendations
setFileMirrorRecommendation(recommendation, vpool, varray, false, false, sourceFileShare);
FileShare targetFileShare = null;
StringBuilder fileLabelBuilder = null;
VirtualPool targetVpool = vpool;
String targetFsPrefix = sourceFileShare.getName();
if (cosCapabilities.getFileTargetCopyName() != null && !cosCapabilities.getFileTargetCopyName().isEmpty()) {
targetFsPrefix = cosCapabilities.getFileTargetCopyName();
}
if (FileReplicationType.LOCAL.name().equalsIgnoreCase(cosCapabilities.getFileReplicationType())) {
// Stripping out the special characters like ; /-+!@#$%^&())";:[]{}\ | but allow underscore character _
String varrayName = varray.getLabel().replaceAll("[^\\dA-Za-z\\_]", "");
fileLabelBuilder = new StringBuilder(targetFsPrefix).append("-localTarget");
_log.info("Target file system name {}", fileLabelBuilder.toString());
targetFileShare = prepareEmptyFileSystem(fileLabelBuilder.toString(), sourceFileShare.getCapacity(), project, recommendation, tenantOrg, varray, vpool, targetVpool, flags, task);
// Set target file recommendations to target file system!!!
setFileMirrorRecommendation(recommendation, vpool, varray, true, false, targetFileShare);
// Update the source and target relationship!!
setMirrorFileShareAttributes(sourceFileShare, targetFileShare);
preparedFileSystems.add(sourceFileShare);
preparedFileSystems.add(targetFileShare);
} else {
// Source file system!!
preparedFileSystems.add(sourceFileShare);
List<VirtualArray> virtualArrayTargets = new ArrayList<VirtualArray>();
if (cosCapabilities.getFileReplicationTargetVArrays() != null & !cosCapabilities.getFileReplicationTargetVArrays().isEmpty()) {
for (String strVarray : cosCapabilities.getFileReplicationTargetVArrays()) {
virtualArrayTargets.add(_dbClient.queryObject(VirtualArray.class, URI.create(strVarray)));
}
}
for (VirtualArray targetVArray : virtualArrayTargets) {
if (cosCapabilities.getFileReplicationTargetVPool() != null) {
targetVpool = _dbClient.queryObject(VirtualPool.class, cosCapabilities.getFileReplicationTargetVPool());
} else {
targetVpool = vpool;
}
// Stripping out the special characters like ; /-+!@#$%^&())";:[]{}\ | but allow underscore character _
String varrayName = targetVArray.getLabel().replaceAll("[^\\dA-Za-z\\_]", "");
fileLabelBuilder = new StringBuilder(targetFsPrefix).append("-target");
_log.info("Target file system name {}", fileLabelBuilder.toString());
targetFileShare = prepareEmptyFileSystem(fileLabelBuilder.toString(), sourceFileShare.getCapacity(), project, recommendation, tenantOrg, targetVArray, vpool, targetVpool, flags, task);
// Set target file recommendations to target file system!!!
setFileMirrorRecommendation(recommendation, targetVpool, targetVArray, true, false, targetFileShare);
// Update the source and target relationship!!
setMirrorFileShareAttributes(sourceFileShare, targetFileShare);
preparedFileSystems.add(targetFileShare);
}
}
}
return preparedFileSystems;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class FilePolicyService method assignFilePolicyToProjects.
/**
* Assign policy at project level
*
* @param param
* @param filepolicy
*/
private TaskResourceRep assignFilePolicyToProjects(FilePolicyAssignParam param, FilePolicy filePolicy) {
StringBuilder errorMsg = new StringBuilder();
StringBuilder recommendationErrorMsg = new StringBuilder();
ArgValidator.checkFieldNotNull(param.getProjectAssignParams(), "project_assign_param");
ArgValidator.checkFieldUriType(param.getProjectAssignParams().getVpool(), VirtualPool.class, "vpool");
URI vpoolURI = param.getProjectAssignParams().getVpool();
VirtualPool vpool = null;
if (NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool())) {
ArgValidator.checkFieldUriType(vpoolURI, VirtualPool.class, "vpool");
vpool = _permissionsHelper.getObjectById(vpoolURI, VirtualPool.class);
ArgValidator.checkEntity(vpool, vpoolURI, false);
// Check if the vpool supports provided policy type..
FilePolicyServiceUtils.validateVpoolSupportPolicyType(filePolicy, vpool);
// Check if the vpool supports policy at project level..
if (!vpool.getAllowFilePolicyAtProjectLevel()) {
errorMsg.append("Provided vpool :" + vpool.getLabel() + " doesn't support policy at project level");
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
} else if (vpoolURI != null) {
vpool = _dbClient.queryObject(VirtualPool.class, filePolicy.getFilePolicyVpool());
if (!vpoolURI.equals(filePolicy.getFilePolicyVpool())) {
errorMsg.append("File policy: " + filePolicy.getFilePolicyName() + " is already assigned at project level under the vpool: " + vpool.getLabel());
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
}
ArgValidator.checkFieldNotEmpty(param.getProjectAssignParams().getAssigntoProjects(), "assign_to_projects");
Set<URI> projectURIs = param.getProjectAssignParams().getAssigntoProjects();
List<URI> filteredProjectURIs = new ArrayList<URI>();
for (URI projectURI : projectURIs) {
ArgValidator.checkFieldUriType(projectURI, Project.class, "project");
Project project = _permissionsHelper.getObjectById(projectURI, Project.class);
ArgValidator.checkEntity(project, projectURI, false);
if (filePolicy.getAssignedResources() != null && filePolicy.getAssignedResources().contains(project.getId().toString())) {
_log.info("Policy {} is already assigned to project {} ", filePolicy.getFilePolicyName(), project.getLabel());
continue;
}
// only single replication policy per vpool-project combination.
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_replication.name()) && FilePolicyServiceUtils.projectHasReplicationPolicy(_dbClient, projectURI, vpool.getId())) {
errorMsg.append("Virtual pool " + vpool.getLabel() + " project " + project.getLabel() + "pair is already assigned with replication policy.");
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_snapshot.name()) && FilePolicyServiceUtils.projectHasSnapshotPolicyWithSameSchedule(_dbClient, projectURI, vpool.getId(), filePolicy)) {
errorMsg.append("Snapshot policy with similar schedule is already present on project " + project.getLabel());
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
filteredProjectURIs.add(projectURI);
}
if (param.getApplyOnTargetSite() != null) {
filePolicy.setApplyOnTargetSite(param.getApplyOnTargetSite());
}
// Verify the virtual pool has storage pools!!!
List<URI> storageSystems = getAssociatedStorageSystemsByVPool(vpool);
if (storageSystems == null || storageSystems.isEmpty()) {
String errorMessage = "No matching storage pools exists for given vpools ";
_log.error(errorMessage);
throw APIException.badRequests.noStoragePoolsExists(vpool.getLabel());
}
String task = UUID.randomUUID().toString();
TaskResourceRep taskResponse = createAssignFilePolicyTask(filePolicy, task);
FileServiceApi fileServiceApi = getDefaultFileServiceApi();
FilePolicyType policyType = FilePolicyType.valueOf(filePolicy.getFilePolicyType());
switch(policyType) {
case file_snapshot:
Map<URI, List<URI>> vpoolToStorageSystemMap = new HashMap<URI, List<URI>>();
vpoolToStorageSystemMap.put(vpoolURI, getAssociatedStorageSystemsByVPool(vpool));
AssignFileSnapshotPolicyToProjectSchedulingThread.executeApiTask(this, _asyncTaskService.getExecutorService(), _dbClient, filePolicy.getId(), vpoolToStorageSystemMap, filteredProjectURIs, fileServiceApi, taskResponse, task);
break;
case file_replication:
if (filteredProjectURIs.isEmpty()) {
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), "No projects to assign to policy.");
}
// update replication topology info
updateFileReplicationTopologyInfo(param, filePolicy);
List<URI> validRecommendationProjects = new ArrayList<URI>();
List<FileStorageSystemAssociation> associations = new ArrayList<FileStorageSystemAssociation>();
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
StringSet sourceVArraysSet = getSourceVArraySet(vpool, filePolicy);
updatePolicyCapabilities(_dbClient, sourceVArraysSet, vpool, filePolicy, capabilities, errorMsg);
// Replication policy has to be created on each applicable source storage system!!
if (storageSystems != null && !storageSystems.isEmpty()) {
for (Iterator<String> iterator = sourceVArraysSet.iterator(); iterator.hasNext(); ) {
String vArrayURI = iterator.next();
for (URI projectURI : filteredProjectURIs) {
List<FileStorageSystemAssociation> projectAssociations = new ArrayList<FileStorageSystemAssociation>();
Project project = _dbClient.queryObject(Project.class, projectURI);
VirtualArray srcVarray = _dbClient.queryObject(VirtualArray.class, URI.create(vArrayURI));
for (URI storageSystem : storageSystems) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.FILE_PROTECTION_SOURCE_STORAGE_SYSTEM, storageSystem);
try {
List<FileRecommendation> newRecs = _filePlacementManager.getRecommendationsForFileCreateRequest(srcVarray, project, vpool, capabilities);
if (newRecs != null && !newRecs.isEmpty()) {
projectAssociations.addAll(convertRecommendationsToStorageSystemAssociations(newRecs, filePolicy.getApplyAt(), vpool.getId(), projectURI));
}
} catch (Exception ex) {
_log.error("No recommendations found for storage system {} and virtualArray {} with error {} ", storageSystem, srcVarray.getLabel(), ex.getMessage());
if (ex.getMessage() != null) {
recommendationErrorMsg.append(ex.getMessage());
}
// Continue to get the recommedations for next storage system!!
continue;
}
}
if (!projectAssociations.isEmpty()) {
associations.addAll(projectAssociations);
validRecommendationProjects.add(projectURI);
}
}
}
} else {
String errorMessage = "No matching storage pools exists for vpool " + vpool.getLabel();
_log.error(errorMessage);
recommendationErrorMsg.append(errorMessage);
}
// Throw an exception!!
if (associations == null || associations.isEmpty()) {
// If no other resources are assigned to replication policy
// Remove the replication topology from the policy
FileOrchestrationUtils.removeTopologyInfo(filePolicy, _dbClient);
_log.error("No matching storage pools recommendations found for policy {} with due to {}", filePolicy.getFilePolicyName(), recommendationErrorMsg.toString());
throw APIException.badRequests.noFileStorageRecommendationsFound(filePolicy.getFilePolicyName());
}
fileServiceApi.assignFileReplicationPolicyToProjects(associations, vpoolURI, validRecommendationProjects, filePolicy.getId(), task);
break;
default:
break;
}
auditOp(OperationTypeEnum.ASSIGN_FILE_POLICY, true, AuditLogManager.AUDITOP_BEGIN, filePolicy.getLabel());
if (taskResponse != null) {
// As the action done by system admin
// Set system uri as task's tenant!!!
Task taskObj = _dbClient.queryObject(Task.class, taskResponse.getId());
StorageOSUser user = getUserFromContext();
URI userTenantUri = URI.create(user.getTenantId());
FilePolicyServiceUtils.updateTaskTenant(_dbClient, filePolicy, "assign", taskObj, userTenantUri);
}
return taskResponse;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class FilePolicyService method assignFilePolicyToVpools.
/**
* Assigning policy at vpool level
*
* @param param
* @param filepolicy
*/
private TaskResourceRep assignFilePolicyToVpools(FilePolicyAssignParam param, FilePolicy filePolicy) {
StringBuilder errorMsg = new StringBuilder();
StringBuilder recommendationErrorMsg = new StringBuilder();
ArgValidator.checkFieldNotNull(param.getVpoolAssignParams(), "vpool_assign_param");
// Policy has to be applied on specified file vpools..
ArgValidator.checkFieldNotEmpty(param.getVpoolAssignParams().getAssigntoVpools(), "assign_to_vpools");
Set<URI> vpoolURIs = param.getVpoolAssignParams().getAssigntoVpools();
Map<URI, List<URI>> vpoolToStorageSystemMap = new HashMap<URI, List<URI>>();
List<URI> filteredVpoolURIs = new ArrayList<URI>();
StringBuffer vPoolWithNoStoragePools = new StringBuffer();
for (URI vpoolURI : vpoolURIs) {
ArgValidator.checkFieldUriType(vpoolURI, VirtualPool.class, "vpool");
VirtualPool virtualPool = _permissionsHelper.getObjectById(vpoolURI, VirtualPool.class);
ArgValidator.checkEntity(virtualPool, vpoolURI, false);
if (filePolicy.getAssignedResources() != null && filePolicy.getAssignedResources().contains(virtualPool.getId().toString())) {
_log.info("File policy: {} has already been assigned to vpool: {} ", filePolicy.getFilePolicyName(), virtualPool.getLabel());
continue;
}
// only single replication policy per vpool.
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_replication.name()) && (FilePolicyServiceUtils.vPoolHasReplicationPolicy(_dbClient, vpoolURI) || FilePolicyServiceUtils.vPoolHasReplicationPolicyAtProjectLevel(_dbClient, vpoolURI))) {
errorMsg.append("Provided vpool : " + virtualPool.getLabel() + " already assigned with replication policy");
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_snapshot.name()) && FilePolicyServiceUtils.vPoolHasSnapshotPolicyWithSameSchedule(_dbClient, vpoolURI, filePolicy)) {
errorMsg.append("Snapshot policy with similar schedule is already present on vpool " + virtualPool.getLabel());
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
FilePolicyServiceUtils.validateVpoolSupportPolicyType(filePolicy, virtualPool);
List<URI> storageSystems = getAssociatedStorageSystemsByVPool(virtualPool);
if (storageSystems != null && !storageSystems.isEmpty()) {
vpoolToStorageSystemMap.put(vpoolURI, storageSystems);
filteredVpoolURIs.add(vpoolURI);
} else {
vPoolWithNoStoragePools.append(virtualPool.getLabel()).append(",");
}
}
if (filteredVpoolURIs.isEmpty()) {
String errorMessage = "No matching storage pools exists for given vpools ";
_log.error(errorMessage);
throw APIException.badRequests.noStoragePoolsExists(vPoolWithNoStoragePools.toString());
}
if (param.getApplyOnTargetSite() != null) {
filePolicy.setApplyOnTargetSite(param.getApplyOnTargetSite());
}
FileServiceApi fileServiceApi = getDefaultFileServiceApi();
FilePolicyType policyType = FilePolicyType.valueOf(filePolicy.getFilePolicyType());
String task = UUID.randomUUID().toString();
TaskResourceRep taskResponse = null;
switch(policyType) {
case file_snapshot:
taskResponse = createAssignFilePolicyTask(filePolicy, task);
AssignFileSnapshotPolicyToVpoolSchedulingThread.executeApiTask(this, _asyncTaskService.getExecutorService(), _dbClient, filePolicy.getId(), vpoolToStorageSystemMap, fileServiceApi, taskResponse, task);
break;
case file_replication:
// update replication topology info
updateFileReplicationTopologyInfo(param, filePolicy);
List<URI> validRecommendationVpools = new ArrayList<URI>();
List<FileStorageSystemAssociation> associations = new ArrayList<FileStorageSystemAssociation>();
for (URI vpoolURI : filteredVpoolURIs) {
VirtualPool vpool = _permissionsHelper.getObjectById(vpoolURI, VirtualPool.class);
StringSet sourceVArraysSet = getSourceVArraySet(vpool, filePolicy);
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
updatePolicyCapabilities(_dbClient, sourceVArraysSet, vpool, filePolicy, capabilities, errorMsg);
// Replication policy has to be created on each applicable source storage system!!
List<URI> storageSystems = getAssociatedStorageSystemsByVPool(vpool);
if (storageSystems != null && !storageSystems.isEmpty()) {
List<FileStorageSystemAssociation> vpoolAssociations = new ArrayList<FileStorageSystemAssociation>();
for (URI storageSystem : storageSystems) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.FILE_PROTECTION_SOURCE_STORAGE_SYSTEM, storageSystem);
for (Iterator<String> iterator = sourceVArraysSet.iterator(); iterator.hasNext(); ) {
String vArrayURI = iterator.next();
VirtualArray srcVarray = _dbClient.queryObject(VirtualArray.class, URI.create(vArrayURI));
try {
List<FileRecommendation> newRecs = _filePlacementManager.getRecommendationsForFileCreateRequest(srcVarray, null, vpool, capabilities);
if (newRecs != null && !newRecs.isEmpty()) {
vpoolAssociations.addAll(convertRecommendationsToStorageSystemAssociations(newRecs, filePolicy.getApplyAt(), vpool.getId(), null));
}
} catch (Exception ex) {
_log.error("No recommendations found for storage system {} and virtualArray {} with error {} ", storageSystem, srcVarray.getLabel(), ex.getMessage());
if (ex.getMessage() != null) {
recommendationErrorMsg.append(ex.getMessage());
}
// Continue to get the recommendations for next storage system!!
continue;
}
}
}
if (!vpoolAssociations.isEmpty()) {
validRecommendationVpools.add(vpoolURI);
associations.addAll(vpoolAssociations);
}
} else {
String errorMessage = "No matching storage pools exists for vpool " + vpool.getLabel();
_log.error(errorMessage);
recommendationErrorMsg.append(errorMessage);
}
}
// Throw an exception!!
if (associations == null || associations.isEmpty()) {
// If no other resources are assigned to replication policy
// Remove the replication topology from the policy
FileOrchestrationUtils.removeTopologyInfo(filePolicy, _dbClient);
_log.error("No matching storage pools recommendations found for policy {} with due to {}", filePolicy.getFilePolicyName(), recommendationErrorMsg.toString());
throw APIException.badRequests.noFileStorageRecommendationsFound(filePolicy.getFilePolicyName());
}
taskResponse = createAssignFilePolicyTask(filePolicy, task);
fileServiceApi.assignFileReplicationPolicyToVirtualPools(associations, validRecommendationVpools, filePolicy.getId(), task);
break;
default:
break;
}
auditOp(OperationTypeEnum.ASSIGN_FILE_POLICY, true, AuditLogManager.AUDITOP_BEGIN, filePolicy.getLabel());
if (taskResponse != null) {
// As the action done by system admin
// Set system uri as task's tenant!!!
Task taskObj = _dbClient.queryObject(Task.class, taskResponse.getId());
StorageOSUser user = getUserFromContext();
URI userTenantUri = URI.create(user.getTenantId());
FilePolicyServiceUtils.updateTaskTenant(_dbClient, filePolicy, "assign", taskObj, userTenantUri);
}
return taskResponse;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class PlacementTests method testPlacementRpXIONoVplex.
/**
* RP placement tests with XIO (no VPLEX)
*/
@Test
public void testPlacementRpXIONoVplex() {
String[] xio1FE = { "50:FE:FE:FE:FE:FE:FE:00", "50:FE:FE:FE:FE:FE:FE:01" };
String[] xio2FE = { "51:FE:FE:FE:FE:FE:FE:00", "51:FE:FE:FE:FE:FE:FE:01" };
String[] xio3FE = { "52:FE:FE:FE:FE:FE:FE:00", "52:FE:FE:FE:FE:FE:FE:01" };
String[] xio4FE = { "53:FE:FE:FE:FE:FE:FE:00", "53:FE:FE:FE:FE:FE:FE:01" };
String[] xio5FE = { "54:FE:FE:FE:FE:FE:FE:00", "54:FE:FE:FE:FE:FE:FE:01" };
String[] xio6FE = { "55:FE:FE:FE:FE:FE:FE:00", "55:FE:FE:FE:FE:FE:FE:01" };
String[] rp1FE = { "56:FE:FE:FE:FE:FE:FE:00", "56:FE:FE:FE:FE:FE:FE:01" };
String[] rp2FE = { "57:FE:FE:FE:FE:FE:FE:00", "57:FE:FE:FE:FE:FE:FE:01" };
// Create 2 Virtual Arrays
VirtualArray varray1 = PlacementTestUtils.createVirtualArray(_dbClient, "varray1");
VirtualArray varray2 = PlacementTestUtils.createVirtualArray(_dbClient, "varray2");
// Create 2 Networks
StringSet connVA = new StringSet();
connVA.add(varray1.getId().toString());
Network network1 = PlacementTestUtils.createNetwork(_dbClient, rp1FE, "VSANSite1", "FC+BROCADE+FE", connVA);
connVA = new StringSet();
connVA.add(varray2.getId().toString());
Network network2 = PlacementTestUtils.createNetwork(_dbClient, rp2FE, "VSANSite2", "FC+CISCO+FE", connVA);
// Create 6 storage systems
StorageSystem storageSystem1 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio1");
StorageSystem storageSystem2 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio2");
StorageSystem storageSystem3 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio3");
StorageSystem storageSystem4 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio4");
StorageSystem storageSystem5 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio5");
StorageSystem storageSystem6 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio6");
// Create two front-end storage ports XIO1
List<StoragePort> xio1Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio1FE.length; i++) {
xio1Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem1, network1, xio1FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1xio1" + i, "C0+FC0" + i));
}
// Create two front-end storage ports XIO2
List<StoragePort> xio2Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio2FE.length; i++) {
xio2Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem2, network1, xio2FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1xio2" + i, "D0+FC0" + i));
}
// Create two front-end storage ports XIO3
List<StoragePort> xio3Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio3FE.length; i++) {
xio3Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem3, network1, xio3FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1xio3" + i, "E0+FC0" + i));
}
// Create two front-end storage ports XIO4
List<StoragePort> xio4Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio4FE.length; i++) {
xio4Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem4, network2, xio4FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2xio4" + i, "F0+FC0" + i));
}
// Create two front-end storage ports XIO5
List<StoragePort> xio5Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio5FE.length; i++) {
xio5Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem5, network2, xio5FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2xio5" + i, "G0+FC0" + i));
}
// Create two front-end storage ports XIO6
List<StoragePort> xio6Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio6FE.length; i++) {
xio6Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem6, network2, xio6FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2xio6" + i, "H0+FC0" + i));
}
// Create RP system
AbstractChangeTrackingSet<String> wwnSite1 = new StringSet();
for (int i = 0; i < rp1FE.length; i++) {
wwnSite1.add(rp1FE[i]);
}
StringSetMap initiatorsSiteMap = new StringSetMap();
initiatorsSiteMap.put("site1", wwnSite1);
AbstractChangeTrackingSet<String> wwnSite2 = new StringSet();
for (int i = 0; i < rp2FE.length; i++) {
wwnSite2.add(rp2FE[i]);
}
initiatorsSiteMap.put("site2", wwnSite2);
StringSet storSystems = new StringSet();
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", storageSystem1.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", storageSystem2.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", storageSystem3.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", storageSystem4.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", storageSystem5.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", storageSystem6.getSerialNumber()));
StringMap siteVolCap = new StringMap();
siteVolCap.put("site1", "3221225472");
siteVolCap.put("site2", "3221225472");
StringMap siteVolCnt = new StringMap();
siteVolCnt.put("site1", "10");
siteVolCnt.put("site2", "10");
ProtectionSystem rpSystem = PlacementTestUtils.createProtectionSystem(_dbClient, "rp", "rp1", "site1", "site2", null, "IP", initiatorsSiteMap, storSystems, null, Long.valueOf("3221225472"), Long.valueOf("2"), siteVolCap, siteVolCnt);
// RP Site Array objects
RPSiteArray rpSiteArray1 = new RPSiteArray();
rpSiteArray1.setId(URI.create("rsa1"));
rpSiteArray1.setStorageSystem(URI.create("xtremio1"));
rpSiteArray1.setRpInternalSiteName("site1");
rpSiteArray1.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray1);
RPSiteArray rpSiteArray2 = new RPSiteArray();
rpSiteArray2.setId(URI.create("rsa2"));
rpSiteArray2.setStorageSystem(URI.create("xtremio2"));
rpSiteArray2.setRpInternalSiteName("site1");
rpSiteArray2.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray2);
RPSiteArray rpSiteArray3 = new RPSiteArray();
rpSiteArray3.setId(URI.create("rsa3"));
rpSiteArray3.setStorageSystem(URI.create("xtremio3"));
rpSiteArray3.setRpInternalSiteName("site1");
rpSiteArray3.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray3);
RPSiteArray rpSiteArray4 = new RPSiteArray();
rpSiteArray4.setId(URI.create("rsa4"));
rpSiteArray4.setStorageSystem(URI.create("xtremio4"));
rpSiteArray4.setRpInternalSiteName("site2");
rpSiteArray4.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray4);
RPSiteArray rpSiteArray5 = new RPSiteArray();
rpSiteArray5.setId(URI.create("rsa5"));
rpSiteArray5.setStorageSystem(URI.create("xtremio5"));
rpSiteArray5.setRpInternalSiteName("site2");
rpSiteArray5.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray5);
RPSiteArray rpSiteArray6 = new RPSiteArray();
rpSiteArray6.setId(URI.create("rsa6"));
rpSiteArray6.setStorageSystem(URI.create("xtremio6"));
rpSiteArray6.setRpInternalSiteName("site2");
rpSiteArray6.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray6);
// Create a storage pool for xio1
StoragePool pool1 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem1, "pool1", "Pool1", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio2
StoragePool pool2 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem2, "pool2", "Pool2", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio3
StoragePool pool3 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem3, "pool3", "Pool3", Long.valueOf(1024 * 1024 * 1), Long.valueOf(1024 * 1024 * 1), 100, 100, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio4
StoragePool pool4 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem4, "pool4", "Pool4", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio5
StoragePool pool5 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem5, "pool5", "Pool5", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio6
StoragePool pool6 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem6, "pool6", "Pool6", Long.valueOf(1024 * 1024 * 1), Long.valueOf(1024 * 1024 * 1), 100, 100, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a RP virtual pool
VirtualPool rpVpool = new VirtualPool();
rpVpool.setId(URI.create("rpVpool"));
rpVpool.setLabel("rpVpool");
rpVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
rpVpool.setDriveType(SupportedDriveTypes.FC.name());
VpoolProtectionVarraySettings protectionSettings = new VpoolProtectionVarraySettings();
protectionSettings.setVirtualPool(URI.create("vpool"));
protectionSettings.setId(URI.create("protectionSettings"));
_dbClient.createObject(protectionSettings);
List<VpoolProtectionVarraySettings> protectionSettingsList = new ArrayList<VpoolProtectionVarraySettings>();
protectionSettingsList.add(protectionSettings);
StringMap protectionVarray = new StringMap();
protectionVarray.put(varray2.getId().toString(), protectionSettingsList.get(0).getId().toString());
rpVpool.setProtectionVarraySettings(protectionVarray);
rpVpool.setRpCopyMode("SYNCHRONOUS");
rpVpool.setRpRpoType("MINUTES");
rpVpool.setRpRpoValue(Long.valueOf("5"));
StringSet matchedPools = new StringSet();
matchedPools.add(pool1.getId().toString());
matchedPools.add(pool2.getId().toString());
matchedPools.add(pool3.getId().toString());
rpVpool.setMatchedStoragePools(matchedPools);
rpVpool.setUseMatchedPools(true);
StringSet virtualArrays1 = new StringSet();
virtualArrays1.add(varray1.getId().toString());
rpVpool.setVirtualArrays(virtualArrays1);
_dbClient.createObject(rpVpool);
// Create a virtual pool
VirtualPool vpool = new VirtualPool();
vpool.setId(URI.create("vpool"));
vpool.setLabel("vpool");
vpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
vpool.setDriveType(SupportedDriveTypes.FC.name());
matchedPools = new StringSet();
matchedPools.add(pool4.getId().toString());
matchedPools.add(pool5.getId().toString());
matchedPools.add(pool6.getId().toString());
vpool.setMatchedStoragePools(matchedPools);
vpool.setUseMatchedPools(true);
StringSet virtualArrays2 = new StringSet();
virtualArrays2.add(varray2.getId().toString());
vpool.setVirtualArrays(virtualArrays2);
_dbClient.createObject(vpool);
// Create Tenant
TenantOrg tenant = new TenantOrg();
tenant.setId(URI.create("tenant"));
_dbClient.createObject(tenant);
// Create a project object
Project project = new Project();
project.setId(URI.create("project"));
project.setLabel("project");
project.setTenantOrg(new NamedURI(tenant.getId(), project.getLabel()));
_dbClient.createObject(project);
// Create block consistency group
BlockConsistencyGroup cg = new BlockConsistencyGroup();
cg.setProject(new NamedURI(project.getId(), project.getLabel()));
cg.setId(URI.create("blockCG"));
_dbClient.createObject(cg);
// Create capabilities
VirtualPoolCapabilityValuesWrapper capabilities = PlacementTestUtils.createCapabilities("2GB", 1, cg);
// Run single volume placement: Run 10 times to make sure pool3 never comes up for source and pool6 for target.
for (int i = 0; i < 10; i++) {
List recommendations = PlacementTestUtils.invokePlacement(_dbClient, _coordinator, varray1, project, rpVpool, capabilities);
assertNotNull(recommendations);
assertTrue(!recommendations.isEmpty());
assertNotNull(recommendations.get(0));
RPProtectionRecommendation rec = (RPProtectionRecommendation) recommendations.get(0);
assertNotNull(rec.getSourceRecommendations());
assertTrue(!rec.getSourceRecommendations().isEmpty());
assertNotNull(rec.getProtectionDevice());
assertNotNull(rec.getPlacementStepsCompleted().name());
assertTrue("rp1".equals(rec.getProtectionDevice().toString()));
for (RPRecommendation sourceRec : rec.getSourceRecommendations()) {
assertNotNull(sourceRec);
assertNotNull(sourceRec.getInternalSiteName());
assertNotNull(sourceRec.getSourceStorageSystem());
assertNotNull(sourceRec.getSourceStoragePool());
assertTrue(sourceRec.getVirtualArray().toString().equals("varray1"));
assertTrue("site1".equals(sourceRec.getInternalSiteName()));
assertTrue("xtremio2".equals(sourceRec.getSourceStorageSystem().toString()));
assertTrue(("pool2".equals(sourceRec.getSourceStoragePool().toString())) || ("pool1".equals(sourceRec.getSourceStoragePool().toString())));
assertNotNull(sourceRec.getTargetRecommendations());
assertTrue(!sourceRec.getTargetRecommendations().isEmpty());
for (RPRecommendation targetRec : sourceRec.getTargetRecommendations()) {
assertNotNull(targetRec.getSourceStoragePool());
assertTrue("xtremio4".equals(targetRec.getSourceStorageSystem().toString()));
assertTrue("site2".equals(targetRec.getInternalSiteName()));
assertTrue(targetRec.getVirtualArray().toString().equals("varray2"));
assertTrue("pool4".equals(targetRec.getSourceStoragePool().toString()) || "pool5".equals(targetRec.getSourceStoragePool().toString()));
}
}
// source journal
assertNotNull(rec.getSourceJournalRecommendation());
assertNotNull(rec.getSourceJournalRecommendation().getSourceStoragePool());
assertTrue(("pool2".equals(rec.getSourceJournalRecommendation().getSourceStoragePool().toString())) || ("pool1".equals(rec.getSourceJournalRecommendation().getSourceStoragePool().toString())));
// target journal
assertNotNull(rec.getTargetJournalRecommendations());
assertTrue(!rec.getTargetJournalRecommendations().isEmpty());
for (RPRecommendation targetJournalRec : rec.getTargetJournalRecommendations()) {
assertNotNull(targetJournalRec.getSourceStoragePool());
assertTrue(targetJournalRec.getVirtualArray().toString().equals("varray2"));
assertTrue("pool4".equals(targetJournalRec.getSourceStoragePool().toString()) || "pool5".equals(targetJournalRec.getSourceStoragePool().toString()) || "pool6".equals(targetJournalRec.getSourceStoragePool().toString()));
assertTrue("site2".equals(targetJournalRec.getInternalSiteName()));
assertTrue("xtremio4".equals(targetJournalRec.getSourceStorageSystem().toString()) || "xtremio5".equals(targetJournalRec.getSourceStorageSystem().toString()) || "xtremio6".equals(targetJournalRec.getSourceStorageSystem().toString()));
}
_log.info(rec.toString(_dbClient));
}
}
Aggregations