use of com.emc.storageos.model.project.ProjectElement in project coprhd-controller by CoprHD.
the class AbstractRequestWrapperFilter method createTenantNProject.
private void createTenantNProject(KeystoneTenant tenant) {
_internalTenantServiceClient.setServer(_keystoneUtils.getVIP());
// Create Tenant via internal API call.
TenantOrgRestRep tenantResp = _internalTenantServiceClient.createTenant(_keystoneUtils.prepareTenantParam(tenant));
// Create Project via internal API call.
ProjectParam projectParam = new ProjectParam(tenant.getName() + CinderConstants.PROJECT_NAME_SUFFIX);
ProjectElement projectResp = _internalTenantServiceClient.createProject(tenantResp.getId(), projectParam);
_keystoneUtils.tagProjectWithOpenstackId(projectResp.getId(), tenant.getId(), tenantResp.getId().toString());
// Creates OSTenant representation of Openstack Tenant
OSTenant osTenant = _keystoneUtils.mapToOsTenant(tenant);
osTenant.setId(URIUtil.createId(OSTenant.class));
_dbClient.createObject(osTenant);
}
use of com.emc.storageos.model.project.ProjectElement in project coprhd-controller by CoprHD.
the class InternalTenantServiceClient method createProject.
public ProjectElement createProject(URI id, ProjectParam param) {
String path = String.format(INTERNAL_CREATE_PROJECT, id.toString());
WebResource rRoot = createRequest(path);
ProjectElement resp = null;
try {
resp = addSignature(rRoot).post(ProjectElement.class, param);
} catch (Exception e) {
_log.error("Could not create project. Err:{}", e.getStackTrace());
}
return resp;
}
use of com.emc.storageos.model.project.ProjectElement in project coprhd-controller by CoprHD.
the class OpenStackSynchronizationTaskTest method testCreateProject.
@Test
public void testCreateProject() {
URI projectId = URIUtil.createId(Project.class);
ProjectElement projectParam = new ProjectElement();
projectParam.setId(projectId);
when(_internalTenantsService.createProject(any(), any())).thenReturn(projectParam);
URI result = _synchronizationTask.createProject(tenantOrg.getId(), keystoneTenant);
verify(_internalTenantsService).createProject(any(), any());
assertNotNull(result);
assertEquals(projectId, result);
}
use of com.emc.storageos.model.project.ProjectElement in project coprhd-controller by CoprHD.
the class VPlexBlockServiceApiImpl method getVplexProject.
/**
* Returns the Project assigned to this VPlex for its artifacts.
* If there is no existing Project, one is created.
*
* @param vplexSystem A StorageSystem instance representing a VPlex.
* @param dbClient A reference to a database client.
*
* @return Project instance that was created for holding this VPlex's private volumes/export groups.
*/
public static Project getVplexProject(StorageSystem vplexSystem, DbClient dbClient, TenantsService tenantsService) {
BasePermissionsHelper helper = new BasePermissionsHelper(dbClient);
TenantOrg rootTenant = helper.getRootTenant();
PrefixConstraint constraint = PrefixConstraint.Factory.getLabelPrefixConstraint(Project.class, vplexSystem.getNativeGuid());
URIQueryResultList result = new URIQueryResultList();
dbClient.queryByConstraint(constraint, result);
Iterator<URI> iter = result.iterator();
while (iter.hasNext()) {
Project project = dbClient.queryObject(Project.class, iter.next());
if (project == null || project.getInactive() == true) {
continue;
}
if (project.getLabel().equals(vplexSystem.getNativeGuid()) && project.getTenantOrg().getURI().toString().equals(rootTenant.getId().toString())) {
return project;
}
}
// Create the project
ProjectParam projectParam = new ProjectParam(vplexSystem.getNativeGuid());
ProjectElement projectElement = tenantsService.createProject(rootTenant.getId(), projectParam, TenantOrg.PROVIDER_TENANT_ORG, rootTenant.getId().toString());
URI projectId = projectElement.getId();
Project project = dbClient.queryObject(Project.class, projectId);
project.addInternalFlags(DataObject.Flag.INTERNAL_OBJECT);
dbClient.updateObject(project);
return project;
}
use of com.emc.storageos.model.project.ProjectElement in project coprhd-controller by CoprHD.
the class TenantsService method createProject.
/**
* Create a project
*
* @param param Project parameters
* @param id the URN of a ViPR Tenant/Subtenant
* @prereq none
* @brief Create project
* @return Project details
*/
@POST
@Path("/{id}/projects")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN, Role.PROJECT_ADMIN })
public ProjectElement createProject(@PathParam("id") URI id, ProjectParam param) {
ProjectElement projectElement = createProject(id, param, getUserFromContext().getName(), getUserFromContext().getTenantId().toString());
auditOp(OperationTypeEnum.CREATE_PROJECT, true, null, param.getName(), id.toString(), projectElement.getId().toString());
return projectElement;
}
Aggregations