Search in sources :

Example 6 with ProjectElement

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);
}
Also used : ProjectParam(com.emc.storageos.model.project.ProjectParam) ProjectElement(com.emc.storageos.model.project.ProjectElement) TenantOrgRestRep(com.emc.storageos.model.tenant.TenantOrgRestRep)

Example 7 with ProjectElement

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;
}
Also used : ProjectElement(com.emc.storageos.model.project.ProjectElement) WebResource(com.sun.jersey.api.client.WebResource) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException)

Example 8 with ProjectElement

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);
}
Also used : ProjectElement(com.emc.storageos.model.project.ProjectElement) URI(java.net.URI) Test(org.junit.Test)

Example 9 with ProjectElement

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;
}
Also used : Project(com.emc.storageos.db.client.model.Project) ProjectParam(com.emc.storageos.model.project.ProjectParam) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) ProjectElement(com.emc.storageos.model.project.ProjectElement) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) BasePermissionsHelper(com.emc.storageos.security.authorization.BasePermissionsHelper) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 10 with ProjectElement

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;
}
Also used : ProjectElement(com.emc.storageos.model.project.ProjectElement) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

ProjectElement (com.emc.storageos.model.project.ProjectElement)12 ProjectParam (com.emc.storageos.model.project.ProjectParam)8 ClientResponse (com.sun.jersey.api.client.ClientResponse)3 URI (java.net.URI)3 Test (org.junit.Test)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 Project (com.emc.storageos.db.client.model.Project)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 TenantOrgRestRep (com.emc.storageos.model.tenant.TenantOrgRestRep)2 ContainmentPrefixConstraint (com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint)1 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)1 FCTN_VPLEX_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI)1 BulkIdParam (com.emc.storageos.model.BulkIdParam)1 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1 ACLAssignmentChanges (com.emc.storageos.model.auth.ACLAssignmentChanges)1 ACLEntry (com.emc.storageos.model.auth.ACLEntry)1 FileShareBulkRep (com.emc.storageos.model.file.FileShareBulkRep)1 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)1