Search in sources :

Example 11 with TenantOrgRestRep

use of com.emc.storageos.model.tenant.TenantOrgRestRep 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 12 with TenantOrgRestRep

use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.

the class BlockStorageUtils method getVolumeTagCommand.

/**
 * Returns the viprcli command for adding a tag to a block volume
 *
 * @param blockObjectId the id of the block object
 * @param tagName the tag name
 * @param tagValue the tag value
 * @return viprcli command
 */
public static String getVolumeTagCommand(URI blockObjectId, String tagName, String tagValue) {
    BlockObjectRestRep blockObject = getBlockResource(blockObjectId);
    URI projectId = getProjectId(blockObject);
    ProjectRestRep project = getProject(projectId);
    TenantOrgRestRep tenant = getTenant(project.getTenant().getId());
    return ExecutionUtils.getMessage("viprcli.volume.tag", blockObject.getName(), tenant.getName(), project.getName(), tagName, tagValue);
}
Also used : TenantOrgRestRep(com.emc.storageos.model.tenant.TenantOrgRestRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Example 13 with TenantOrgRestRep

use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.

the class InternalTenantServiceClient method createTenant.

public TenantOrgRestRep createTenant(TenantCreateParam param) {
    WebResource rRoot = createRequest(INTERNAL_CREATE_TENANT);
    TenantOrgRestRep resp = null;
    try {
        resp = addSignature(rRoot).post(TenantOrgRestRep.class, param);
    } catch (Exception e) {
        _log.error("Could not create tenant. Err:{}", e.getStackTrace());
    }
    return resp;
}
Also used : WebResource(com.sun.jersey.api.client.WebResource) TenantOrgRestRep(com.emc.storageos.model.tenant.TenantOrgRestRep) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException)

Example 14 with TenantOrgRestRep

use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.

the class InternalTenantServiceClient method setTenantNamespace.

/**
 * Set namespace mapping info for tenant or subtenant
 *
 * @param tenantId the URN of a ViPR Tenant/Subtenant
 * @param namespace name of the target namespace the tenant will be mapped to
 * @return the updated Tenant/Subtenant instance
 */
public TenantOrgRestRep setTenantNamespace(URI tenantId, String namespace) {
    String setNamespacePath = String.format(INTERNAL_TENANT_SET_NAMESPACE, tenantId.toString(), namespace);
    WebResource rRoot = createRequest(setNamespacePath);
    TenantOrgRestRep resp = null;
    try {
        resp = addSignature(rRoot).put(TenantOrgRestRep.class);
    } catch (UniformInterfaceException e) {
        _log.warn("could not attach namespace to tenant {}. Err:{}", tenantId, e);
    }
    return resp;
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) WebResource(com.sun.jersey.api.client.WebResource) TenantOrgRestRep(com.emc.storageos.model.tenant.TenantOrgRestRep)

Example 15 with TenantOrgRestRep

use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.

the class TenantUtils method getAllTenants.

public static List<TenantOrgRestRep> getAllTenants() {
    List<TenantOrgRestRep> tenants = Lists.newArrayList();
    TenantOrgRestRep rootTenant = findRootTenant();
    tenants.add(rootTenant);
    tenants.addAll(getSubTenants(id(rootTenant)));
    return tenants;
}
Also used : TenantOrgRestRep(com.emc.storageos.model.tenant.TenantOrgRestRep)

Aggregations

TenantOrgRestRep (com.emc.storageos.model.tenant.TenantOrgRestRep)22 TenantCreateParam (com.emc.storageos.model.tenant.TenantCreateParam)5 URI (java.net.URI)5 ProjectParam (com.emc.storageos.model.project.ProjectParam)4 UserMappingAttributeParam (com.emc.storageos.model.tenant.UserMappingAttributeParam)3 UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)3 ProjectElement (com.emc.storageos.model.project.ProjectElement)2 TenantResponse (com.emc.storageos.model.tenant.TenantResponse)2 UserInfo (com.emc.storageos.model.user.UserInfo)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)2 WebResource (com.sun.jersey.api.client.WebResource)2 ArrayList (java.util.ArrayList)2 JAXBContext (javax.xml.bind.JAXBContext)2 ACLEntry (com.emc.storageos.model.auth.ACLEntry)1 AuthnUpdateParam (com.emc.storageos.model.auth.AuthnUpdateParam)1 RoleAssignmentChanges (com.emc.storageos.model.auth.RoleAssignmentChanges)1 RoleAssignmentEntry (com.emc.storageos.model.auth.RoleAssignmentEntry)1 RoleAssignments (com.emc.storageos.model.auth.RoleAssignments)1 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)1