use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class TenantUtils method getUserSubTenantOptions.
public static List<StringOption> getUserSubTenantOptions() {
List<StringOption> options = Lists.newArrayList();
if (Security.hasAnyRole(Security.SECURITY_ADMIN, Security.RESTRICTED_SECURITY_ADMIN, Security.HOME_TENANT_ADMIN)) {
TenantOrgRestRep userTenant = getViprClient().tenants().get(uri(Security.getUserInfo().getTenant()));
options.add(createTenantOption(userTenant));
}
for (TenantOrgRestRep tenant : getViprClient().tenants().getByIds(Security.getUserInfo().getSubTenants())) {
options.add(createTenantOption(tenant));
}
return options;
}
use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class TenantUtils method getSubTenantOptions.
public static List<StringOption> getSubTenantOptions() {
List<StringOption> options = Lists.newArrayList();
TenantOrgRestRep userTenant = getViprClient().tenants().get(uri(Security.getUserInfo().getTenant()));
options.add(createTenantOption(userTenant));
for (TenantOrgRestRep tenant : getViprClient().tenants().getAllSubtenants(uri(Security.getUserInfo().getTenant()))) {
options.add(createTenantOption(tenant));
}
Collections.sort(options);
return options;
}
use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class OpenStackSynchronizationTaskTest method testCreateTenant.
@Test
public void testCreateTenant() {
URI tenantId = URIUtil.createId(TenantOrg.class);
TenantOrgRestRep tenant = new TenantOrgRestRep();
tenant.setId(tenantId);
when(_keystoneUtils.prepareTenantParam(any())).thenReturn(new TenantCreateParam());
when(_internalTenantsService.createTenant(any())).thenReturn(tenant);
URI result = _synchronizationTask.createTenant(keystoneTenant);
verify(_internalTenantsService).createTenant(any());
assertNotNull(result);
assertEquals(tenantId, result);
}
use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class GeoTest method createSubTenant.
private void createSubTenant() {
TenantResponse tenantResp = rSys.path("/tenant").get(TenantResponse.class);
rootTenantId = tenantResp.getTenant();
/*
* CREATE subtenant
*/
String subtenant_url = "/tenants/" + rootTenantId.toString() + "/subtenants";
TenantCreateParam tenantParam = new TenantCreateParam();
String subtenant1_label = "subtenant1";
tenantParam.setLabel(subtenant1_label);
tenantParam.setDescription("first subtenant");
tenantParam.setUserMappings(new ArrayList<UserMappingParam>());
UserMappingParam tenantMapping = new UserMappingParam();
tenantMapping = new UserMappingParam();
tenantMapping.setDomain("sanity.LOCAL");
// Add an attribute scope to the mapping
UserMappingAttributeParam tenantAttr = new UserMappingAttributeParam();
Date now = new Date();
tenantAttr.setKey("departMent" + now);
tenantAttr.setValues(Collections.singletonList(SUBTENANT1_ATTR));
tenantMapping.setAttributes(Collections.singletonList(tenantAttr));
tenantParam.getUserMappings().add(tenantMapping);
// Add the mappings
TenantOrgRestRep subtenant1 = rSys.path(subtenant_url).post(TenantOrgRestRep.class, tenantParam);
Assert.assertTrue(subtenant1.getName().equals(subtenant1_label));
Assert.assertEquals(1, subtenant1.getUserMappings().size());
subtenant1Id = subtenant1.getId();
}
use of com.emc.storageos.model.tenant.TenantOrgRestRep in project coprhd-controller by CoprHD.
the class SystemHealth method download.
/**
* Download logs capability really creates the old support package.
*/
public static void download(String nodeId, String[] service, Integer severity, String searchMessage, String startTime, String endTime, String orderTypes) {
SupportPackageCreator creator = new SupportPackageCreator(request, BourneUtil.getSysClient(), Models.currentTenant(), BourneUtil.getCatalogClient());
if (StringUtils.isNotEmpty(nodeId)) {
creator.setNodeIds(Lists.newArrayList(nodeId));
}
if (service != null && service.length > 0) {
List<String> logNames = getLogNames(service);
creator.setLogNames(logNames);
}
if (StringUtils.isNotEmpty(searchMessage)) {
creator.setMsgRegex("(?i).*" + searchMessage + ".*");
}
if (StringUtils.isNotEmpty(startTime)) {
creator.setStartTimeWithRestriction(startTime);
}
if (StringUtils.isNotEmpty(endTime)) {
creator.setEndTime(endTime);
}
if (severity != null && severity > 0) {
creator.setLogSeverity(severity);
}
if (DisasterRecoveryUtils.isActiveSite()) {
if (StringUtils.equalsIgnoreCase(orderTypes, OrderTypes.ALL.name())) {
creator.setOrderTypes(OrderTypes.ALL);
} else if (StringUtils.equals(orderTypes, OrderTypes.ERROR.name())) {
creator.setOrderTypes(OrderTypes.ERROR);
}
}
if (Security.isSystemAdmin()) {
List<URI> tenantIds = Lists.newArrayList();
for (TenantOrgRestRep tenant : TenantUtils.getAllTenants()) {
tenantIds.add(tenant.getId());
}
creator.setTenantIds(tenantIds);
}
renderSupportPackage(creator);
}
Aggregations