use of com.emc.storageos.model.tenant.TenantCreateParam in project coprhd-controller by CoprHD.
the class AuthnConfigurationService method createTenantAndProjectForOpenstackTenant.
public void createTenantAndProjectForOpenstackTenant(OSTenant tenant) {
TenantCreateParam param = prepareTenantMappingForOpenstack(tenant);
// Create a tenant.
TenantOrgRestRep tenantOrgRestRep = _tenantsService.createSubTenant(_permissionsHelper.getRootTenant().getId(), param);
// Create a project.
ProjectParam projectParam = new ProjectParam(tenant.getName() + CinderConstants.PROJECT_NAME_SUFFIX);
ProjectElement projectElement = _tenantsService.createProject(tenantOrgRestRep.getId(), projectParam);
_keystoneUtils.tagProjectWithOpenstackId(projectElement.getId(), tenant.getOsId(), tenantOrgRestRep.getId().toString());
}
use of com.emc.storageos.model.tenant.TenantCreateParam in project coprhd-controller by CoprHD.
the class ApiTest method createTenant.
private TenantOrgRestRep createTenant(String label, String domain, String attrKey, String attrValue) throws Exception {
BalancedWebResource rootUser = createHttpsClient(SYSADMIN, SYSADMIN_PASS_WORD, baseUrls);
UserInfo info = rootUser.path("/user/whoami").get(UserInfo.class);
String rootTenantId = info.getTenant();
String rootToken = (String) _savedTokens.get(SYSADMIN);
TenantCreateParam tenantParam = new TenantCreateParam();
tenantParam.setLabel(label);
tenantParam.setDescription("description for " + label);
tenantParam.setUserMappings(new ArrayList<UserMappingParam>());
UserMappingParam tenant2UserMapping = new UserMappingParam();
tenant2UserMapping.setDomain(domain);
UserMappingAttributeParam tenant2Attr = new UserMappingAttributeParam();
tenant2Attr.setKey(attrKey);
tenant2Attr.setValues(Collections.singletonList(attrValue));
tenant2UserMapping.setAttributes(Collections.singletonList(tenant2Attr));
tenantParam.getUserMappings().add(tenant2UserMapping);
String subtenant_url = "/tenants/" + rootTenantId + "/subtenants";
TenantOrgRestRep tenantOrg = rootUser.path(subtenant_url).header(AUTH_TOKEN_HEADER, rootToken).post(TenantOrgRestRep.class, tenantParam);
return tenantOrg;
}
use of com.emc.storageos.model.tenant.TenantCreateParam in project coprhd-controller by CoprHD.
the class ApiTest method authnProviderAddDomainTest.
// quick test to see if the added domain of AP server is converted to all lowercase
public void authnProviderAddDomainTest() throws Exception {
AuthnCreateParam param = new AuthnCreateParam();
param.setLabel("domain test AP server");
param.setDescription("AP server configuration created by ApiTest.java");
param.setDisable(false);
param.getDomains().add("asd.locl");
param.setManagerDn("CN=Manager,DC=root,DC=com");
param.setManagerPassword("secret");
param.setSearchBase("OU=People,DC=root,DC=com");
param.setSearchFilter("mail=%u");
param.setServerUrls(new HashSet<String>());
param.getServerUrls().add("ldaps:\\" + LDAP_SERVER1_IP);
param.setMode("ldap");
AuthnProviderRestRep resp = rSys.path("/vdc/admin/authnproviders").post(AuthnProviderRestRep.class, param);
Assert.assertNotNull(resp);
// update the AP server by adding a domain name with mixed case
AuthnUpdateParam updateParam = new AuthnUpdateParam();
Set<String> toAddSet = new HashSet<String>();
toAddSet.add("sAnItY2.local");
updateParam.getDomainChanges().setAdd(toAddSet);
ClientResponse response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).put(ClientResponse.class, updateParam);
Assert.assertEquals(200, response.getStatus());
// verify the added domain name is converted to lower case
response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).get(ClientResponse.class);
AuthnProviderRestRep responseRestRep = response.getEntity(AuthnProviderRestRep.class);
Assert.assertFalse(responseRestRep.getDomains().contains("sAnItY2.local"));
Assert.assertTrue(responseRestRep.getDomains().contains("sanity2.local"));
// use the added domain to create a subtenant, verify it's successful
TenantCreateParam tenantParam = new TenantCreateParam();
tenantParam.setLabel("sub2");
tenantParam.setDescription("My sub tenant 2");
UserMappingParam tenantMapping1 = new UserMappingParam();
tenantMapping1.setDomain("sAnItY2.local");
UserMappingAttributeParam attriParam = new UserMappingAttributeParam("department", Collections.singletonList("ASD"));
tenantMapping1.getAttributes().add(attriParam);
tenantParam.getUserMappings().add(tenantMapping1);
response = rSys.path("/tenants/" + rootTenantId + "/subtenants").post(ClientResponse.class, tenantParam);
Assert.assertEquals(200, response.getStatus());
}
use of com.emc.storageos.model.tenant.TenantCreateParam in project coprhd-controller by CoprHD.
the class KeystoneUtilsTest method testPrepareTenantParam.
@Test
public void testPrepareTenantParam() {
String expectedTenantName = CinderConstants.TENANT_NAME_PREFIX + " " + TENANT_NAME;
TenantCreateParam param = new TenantCreateParam(expectedTenantName, userMappings);
KeystoneUtils spyKeystoneUtils = spy(_keystoneUtils);
doReturn(userMappings).when(spyKeystoneUtils).prepareUserMappings(TENANT_OS_ID);
doReturn(TENANT_DESCRIPTION).when(spyKeystoneUtils).getProperTenantDescription(TENANT_DESCRIPTION);
TenantCreateParam createdParams = spyKeystoneUtils.prepareTenantParam(keystoneTenant);
assertEquals(param.getUserMappings(), createdParams.getUserMappings());
assertEquals(TENANT_DESCRIPTION, createdParams.getDescription());
assertEquals(param.getLabel(), createdParams.getLabel());
}
use of com.emc.storageos.model.tenant.TenantCreateParam in project coprhd-controller by CoprHD.
the class KeystoneUtils method prepareTenantParam.
/**
* Prepares TenantCreateParam class filled with information from given Tenant.
*
* @param tenant OpenStack Tenant.
* @return TenantCreateParam.
*/
public TenantCreateParam prepareTenantParam(KeystoneTenant tenant) {
TenantCreateParam param = new TenantCreateParam(CinderConstants.TENANT_NAME_PREFIX + " " + tenant.getName(), prepareUserMappings(tenant.getId()));
param.setDescription(getProperTenantDescription(tenant.getDescription()));
return param;
}
Aggregations