use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BaseIngestionRequestContext in project coprhd-controller by CoprHD.
the class UnManagedVolumeService method ingestExportedVolumes.
/**
* Ingest Exported Volumes
*
* For each UnManaged Volume Find the list of masking views this volume
* is exposed to.
*
* If only 1 masking view verify if all the initiators are available on
* the existing MV. Verify the storage Ports are available in given
* VArray Verify if this export mask is available already If not, then
* create a new Export Mask with the storage Ports, initiators from
* ViPr. Else, add volume to export mask.
*
* If more than 1 masking view verify if all the initiators are
* available on all existing MVs. Verify the storage Ports within each
* Masking view are available in given VArray. Verify if this export
* mask is available already If not, then create a new Export Mask with
* the storage Ports, initiators from ViPr. Else, add volume to export
* mask.
*
* @param exportIngestParam
* @brief Add volumes to new or existing export masks; create masks when needed
* @return TaskList
* @throws InternalException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/ingest-exported")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskList ingestExportedVolumes(VolumeExportIngestParam exportIngestParam) throws InternalException {
TaskList taskList = new TaskList();
Map<String, TaskResourceRep> taskMap = new HashMap<String, TaskResourceRep>();
BaseIngestionRequestContext requestContext = null;
try {
if (exportIngestParam.getUnManagedVolumes().size() > getMaxBulkSize()) {
throw APIException.badRequests.exceedingLimit("unmanaged volumes", getMaxBulkSize());
}
Project project = _permissionsHelper.getObjectById(exportIngestParam.getProject(), Project.class);
ArgValidator.checkEntity(project, exportIngestParam.getProject(), false);
VirtualArray varray = VolumeIngestionUtil.getVirtualArrayForVolumeCreateRequest(project, exportIngestParam.getVarray(), _permissionsHelper, _dbClient);
VirtualPool vpool = VolumeIngestionUtil.getVirtualPoolForVolumeCreateRequest(project, exportIngestParam.getVpool(), _permissionsHelper, _dbClient);
// allow ingestion for VPool without Virtual Arrays
if (null != vpool.getVirtualArrays() && !vpool.getVirtualArrays().isEmpty() && !vpool.getVirtualArrays().contains(exportIngestParam.getVarray().toString())) {
throw APIException.internalServerErrors.virtualPoolNotMatchingVArray(exportIngestParam.getVarray());
}
// check for Quotas
long unManagedVolumesCapacity = VolumeIngestionUtil.getTotalUnManagedVolumeCapacity(_dbClient, exportIngestParam.getUnManagedVolumes());
_logger.info("UnManagedVolume provisioning quota validation successful");
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg().getURI());
CapacityUtils.validateQuotasForProvisioning(_dbClient, vpool, project, tenant, unManagedVolumesCapacity, "volume");
VolumeIngestionUtil.checkIngestionRequestValidForUnManagedVolumes(exportIngestParam.getUnManagedVolumes(), vpool, _dbClient);
requestContext = new BaseIngestionRequestContext(_dbClient, exportIngestParam.getUnManagedVolumes(), vpool, varray, project, tenant, exportIngestParam.getVplexIngestionMethod());
while (requestContext.hasNext()) {
UnManagedVolume unManagedVolume = requestContext.next();
if (null == unManagedVolume) {
_logger.warn("No Unmanaged Volume with URI {} found in database. Continuing...", requestContext.getCurrentUnManagedVolumeUri());
continue;
}
String taskId = UUID.randomUUID().toString();
Operation operation = _dbClient.createTaskOpStatus(UnManagedVolume.class, requestContext.getCurrentUnManagedVolumeUri(), taskId, ResourceOperationTypeEnum.INGEST_EXPORTED_BLOCK_OBJECTS);
TaskResourceRep task = toTask(unManagedVolume, taskId, operation);
taskMap.put(unManagedVolume.getId().toString(), task);
}
taskList.getTaskList().addAll(taskMap.values());
// find or create ExportGroup for this set of volumes being ingested
URI exportGroupResourceUri = null;
String resourceType = ExportGroupType.Host.name();
String computeResourcelabel = null;
if (null != exportIngestParam.getCluster()) {
resourceType = ExportGroupType.Cluster.name();
Cluster cluster = _dbClient.queryObject(Cluster.class, exportIngestParam.getCluster());
exportGroupResourceUri = cluster.getId();
computeResourcelabel = cluster.getLabel();
requestContext.setCluster(exportIngestParam.getCluster());
} else {
Host host = _dbClient.queryObject(Host.class, exportIngestParam.getHost());
exportGroupResourceUri = host.getId();
computeResourcelabel = host.getHostName();
requestContext.setHost(exportIngestParam.getHost());
}
ExportGroup exportGroup = VolumeIngestionUtil.verifyExportGroupExists(requestContext, requestContext.getProject().getId(), exportGroupResourceUri, exportIngestParam.getVarray(), resourceType, _dbClient);
if (null == exportGroup) {
_logger.info("Creating Export Group with label {}", computeResourcelabel);
ResourceAndUUIDNameGenerator nameGenerator = new ResourceAndUUIDNameGenerator();
exportGroup = VolumeIngestionUtil.initializeExportGroup(requestContext.getProject(), resourceType, exportIngestParam.getVarray(), computeResourcelabel, _dbClient, nameGenerator, requestContext.getTenant());
requestContext.setExportGroupCreated(true);
}
requestContext.setExportGroup(exportGroup);
_logger.info("ExportGroup {} created ", exportGroup.forDisplay());
IngestVolumesExportedSchedulingThread.executeApiTask(_asyncTaskService.getExecutorService(), requestContext, ingestStrategyFactory, this, _dbClient, taskMap, taskList);
} catch (InternalException e) {
_logger.error("InternalException occurred due to: {}", e);
throw e;
} catch (Exception e) {
_logger.error("Unexpected exception occurred due to: {}", e);
throw APIException.internalServerErrors.genericApisvcError(ExceptionUtils.getExceptionMessage(e), e);
}
return taskList;
}
use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BaseIngestionRequestContext in project coprhd-controller by CoprHD.
the class UnManagedVolumeService method ingestVolumes.
/**
* UnManaged volumes are volumes, which are present within ViPR
* storage systems, but have not been ingested by ViPR. Volume ingest is the process of
* moving unmanaged volumes under ViPR management and provides the flexibility of
* determining which volumes are ingested by ViPR A virtual pool, project, and virtual
* array must be associated with an unmanaged volume before it can be ingested by ViPR
* List of supported virtual pools for each unmanaged volume is exposed using
* /vdc/unmanaged/volumes/bulk. Using unsupported virtual pool would result in an error.
* Size of unmanaged volumes which can be ingested via a single API Call is limited to
* 4000.
*
* @param param
* parameters required for unmanaged volume ingestion
* @prereq none
* @brief Ingest unmanaged volumes
* @throws InternalException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/ingest")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskList ingestVolumes(VolumeIngest param) throws InternalException {
if (param.getUnManagedVolumes().size() > getMaxBulkSize()) {
throw APIException.badRequests.exceedingLimit("unmanaged volumes", getMaxBulkSize());
}
TaskList taskList = new TaskList();
Map<String, String> taskMap = new HashMap<String, String>();
BaseIngestionRequestContext requestContext = null;
try {
// Get and validate the project.
Project project = _permissionsHelper.getObjectById(param.getProject(), Project.class);
ArgValidator.checkEntity(project, param.getProject(), false);
// Get and validate the varray
VirtualArray varray = VolumeIngestionUtil.getVirtualArrayForVolumeCreateRequest(project, param.getVarray(), _permissionsHelper, _dbClient);
// Get and validate the vpool.
VirtualPool vpool = VolumeIngestionUtil.getVirtualPoolForVolumeCreateRequest(project, param.getVpool(), _permissionsHelper, _dbClient);
// allow ingestion for VPool without Virtual Arrays
if (null != vpool.getVirtualArrays() && !vpool.getVirtualArrays().isEmpty() && !vpool.getVirtualArrays().contains(param.getVarray().toString())) {
throw APIException.internalServerErrors.virtualPoolNotMatchingVArray(param.getVarray());
}
// check for Quotas
long unManagedVolumesCapacity = VolumeIngestionUtil.getTotalUnManagedVolumeCapacity(_dbClient, param.getUnManagedVolumes());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg().getURI());
CapacityUtils.validateQuotasForProvisioning(_dbClient, vpool, project, tenant, unManagedVolumesCapacity, "volume");
_logger.info("UnManagedVolume provisioning quota validation successful for {}", unManagedVolumesCapacity);
requestContext = new BaseIngestionRequestContext(_dbClient, param.getUnManagedVolumes(), vpool, varray, project, tenant, param.getVplexIngestionMethod());
while (requestContext.hasNext()) {
UnManagedVolume unManagedVolume = requestContext.next();
if (null == unManagedVolume) {
_logger.info("No Unmanaged Volume with URI {} found in database. Continuing...", requestContext.getCurrentUnManagedVolumeUri());
continue;
}
String taskId = UUID.randomUUID().toString();
Operation operation = _dbClient.createTaskOpStatus(UnManagedVolume.class, unManagedVolume.getId(), taskId, ResourceOperationTypeEnum.INGEST_VOLUMES);
TaskResourceRep task = toTask(unManagedVolume, taskId, operation);
taskList.getTaskList().add(task);
taskMap.put(unManagedVolume.getId().toString(), taskId);
}
IngestVolumesUnexportedSchedulingThread.executeApiTask(_asyncTaskService.getExecutorService(), requestContext, ingestStrategyFactory, this, _dbClient, taskMap, taskList);
} catch (InternalException e) {
throw e;
} catch (Exception e) {
_logger.debug("Unexpected ingestion exception:", e);
throw APIException.internalServerErrors.genericApisvcError(ExceptionUtils.getExceptionMessage(e), e);
}
return taskList;
}
Aggregations