use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class HostService method createHost.
/**
* Creates a new host for the tenant organization. Discovery is initiated
* after the host is created.
*
* @param createParam
* the parameter that has the type and attribute of the host to
* be created.
* @prereq none
* @brief Create host
* @return the host discovery async task representation.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public TaskResourceRep createHost(HostCreateParam createParam, @QueryParam("validate_connection") @DefaultValue("false") final Boolean validateConnection) {
// This is mostly to validate the tenant
URI tid = createParam.getTenant();
if ((tid == null) || tid.toString().isEmpty()) {
_log.error("The tenant id is missing");
throw APIException.badRequests.requiredParameterMissingOrEmpty("tenant");
}
TenantOrg tenant = _permissionsHelper.getObjectById(tid, TenantOrg.class);
ArgValidator.checkEntity(tenant, tid, isIdEmbeddedInURL(tid), true);
validateHostData(createParam, tid, null, validateConnection);
// Create the host
return createNewHost(tenant, createParam);
}
use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class BucketService method createBucket.
/**
* Creates bucket.
*
* <p>
* NOTE: This is an asynchronous operation.
*
* @param param Bucket parameters
* @param id the URN of a ViPR Project
* @brief Create bucket
* @return Task resource representation
* @throws InternalException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep createBucket(BucketParam param, @QueryParam("project") URI id) throws InternalException {
// check project
ArgValidator.checkFieldUriType(id, Project.class, "project");
// Check for all mandatory field
ArgValidator.checkFieldNotNull(param.getLabel(), "name");
Project project = _permissionsHelper.getObjectById(id, Project.class);
ArgValidator.checkEntity(project, id, isIdEmbeddedInURL(id));
ArgValidator.checkFieldNotNull(project.getTenantOrg(), "project");
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg().getURI());
final String namespace = tenant.getNamespace();
if (null == namespace || namespace.isEmpty()) {
throw APIException.badRequests.objNoNamespaceForTenant(tenant.getId());
}
// Check if there already exist a bucket with same name in a Project.
checkForDuplicateName(param.getLabel().replaceAll(SPECIAL_CHAR_REGEX, ""), Bucket.class, id, "project", _dbClient);
return initiateBucketCreation(param, project, tenant, null);
}
use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method createTargetsForExistingSource.
@Override
public TaskResourceRep createTargetsForExistingSource(FileShare fs, Project project, VirtualPool vpool, VirtualArray varray, TaskList taskList, String task, List<Recommendation> recommendations, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) throws InternalException {
List<FileShare> fileList = null;
List<FileShare> fileShares = new ArrayList<FileShare>();
FileSystemParam fsParams = new FileSystemParam();
fsParams.setFsId(fs.getId().toString());
fsParams.setLabel(fs.getLabel());
fsParams.setVarray(fs.getVirtualArray());
fsParams.setVpool(fs.getVirtualPool());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg().getURI());
// Prepare the FileShares
fileList = prepareFileSystems(fsParams, task, taskList, project, tenant, null, varray, vpool, recommendations, vpoolCapabilities, false);
fileShares.addAll(fileList);
// prepare the file descriptors
final List<FileDescriptor> fileDescriptors = prepareFileDescriptors(fileShares, vpoolCapabilities, null);
final FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
try {
// Execute the create mirror copies of fileshare!!!
controller.createTargetsForExistingSource(fs.getId().toString(), fileDescriptors, task);
} catch (InternalException e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
} catch (Exception e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
}
return taskList.getTaskList().get(0);
}
use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method assignFilePolicyToFileSystem.
@Override
public void assignFilePolicyToFileSystem(FileShare fs, FilePolicy filePolicy, Project project, VirtualPool vpool, VirtualArray varray, TaskList taskList, String task, List<Recommendation> recommendations, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) throws InternalException {
List<FileShare> fileList = null;
List<FileShare> fileShares = new ArrayList<>();
FileSystemParam fsParams = new FileSystemParam();
fsParams.setFsId(fs.getId().toString());
fsParams.setLabel(fs.getLabel());
fsParams.setVarray(fs.getVirtualArray());
fsParams.setVpool(fs.getVirtualPool());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg().getURI());
// Prepare the FileShares
fileList = prepareFileSystems(fsParams, task, taskList, project, tenant, null, varray, vpool, recommendations, vpoolCapabilities, false);
fileShares.addAll(fileList);
// prepare the file descriptors
final List<FileDescriptor> fileDescriptors = prepareFileDescriptors(fileShares, vpoolCapabilities, null);
final FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
try {
// Execute the create mirror copies of file share!!!
controller.assignFilePolicyToFileSystem(filePolicy, fileDescriptors, task);
} catch (InternalException e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
} catch (Exception e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
}
}
use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.
the class StorageOSLdapPersonAttributeDao method tenantName.
private List<String> tenantName(Set<URI> uris) {
List<String> tenantNames = new ArrayList<>();
for (URI tId : uris) {
TenantOrg t = _dbClient.queryObject(TenantOrg.class, tId);
tenantNames.add(t.getLabel());
}
return tenantNames;
}
Aggregations