use of com.emc.storageos.keystone.restapi.model.response.TenantListRestResp in project coprhd-controller by CoprHD.
the class KeystoneService method listOpenstackTenants.
/**
* Get a list of OpenStack Tenants.
* Uses data from Keystone Authentication Provider to connect Keystone and retrieve Tenants information.
*
* @brief Show OpenStack Tenants.
* @return OpenStack Tenants details.
* @see TenantListRestResp
*/
@GET
@Path("/tenants")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN })
public TenantListRestResp listOpenstackTenants() {
_log.debug("Keystone Service - listOpenstackTenants");
StorageOSUser user = getUserFromContext();
if (!_permissionsHelper.userHasGivenRoleInAnyTenant(user, Role.SECURITY_ADMIN, Role.TENANT_ADMIN)) {
throw APIException.forbidden.insufficientPermissionsForUser(user.getName());
}
AuthnProvider keystoneProvider = _keystoneUtils.getKeystoneProvider();
// Get OpenStack Tenants only when Keystone Provider exists.
if (keystoneProvider != null) {
KeystoneApiClient keystoneApiClient = _keystoneUtils.getKeystoneApi(keystoneProvider.getManagerDN(), keystoneProvider.getServerUrls(), keystoneProvider.getManagerPassword());
List<KeystoneTenant> OSTenantList = new ArrayList<>(Arrays.asList(keystoneApiClient.getKeystoneTenants().getTenants()));
TenantListRestResp response = new TenantListRestResp();
response.setOpenstackTenants(OSTenantList);
return response;
}
throw APIException.internalServerErrors.targetIsNullOrEmpty("Keystone Authentication Provider");
}
Aggregations