use of com.emc.storageos.model.keystone.OpenStackTenantParam in project coprhd-controller by CoprHD.
the class KeystoneService method createOpenStackTenants.
/**
* Creates representation of OpenStack Tenants in CoprHD.
*
* @param param OpenStackTenantListParam OpenStack Tenants representation with all necessary elements.
* @brief Creates representation of OpenStack Tenants in CoprHD.
* @return Newly created Tenants.
* @see
*/
@POST
@Path("/tenants")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN })
public OSTenantListRestRep createOpenStackTenants(OpenStackTenantListParam param) {
_log.debug("Keystone Service - createOpenStackTenants");
if (param.getOpenstackTenants() == null || param.getOpenstackTenants().isEmpty()) {
throw APIException.internalServerErrors.targetIsNullOrEmpty("Tenant list param");
}
List<OSTenant> openstackTenants = new ArrayList<>();
for (OpenStackTenantParam openStackTenantParam : param.getOpenstackTenants()) {
openstackTenants.add(prepareOpenstackTenant(openStackTenantParam));
}
if (!openstackTenants.isEmpty()) {
_dbClient.createObject(openstackTenants);
}
AuthnProvider keystoneProvider = _keystoneUtils.getKeystoneProvider();
if (keystoneProvider == null) {
throw APIException.internalServerErrors.targetIsNullOrEmpty("Keystone Authentication Provider");
}
if (keystoneProvider.getAutoRegCoprHDNImportOSProjects()) {
if (_openStackSynchronizationTask.getSynchronizationTask() == null) {
// Do not create Tenants and Projects once synchronization task is running.
_authService.createTenantsAndProjectsForAutomaticKeystoneRegistration();
_openStackSynchronizationTask.startSynchronizationTask(_openStackSynchronizationTask.getTaskInterval(keystoneProvider));
}
}
return map(openstackTenants);
}
use of com.emc.storageos.model.keystone.OpenStackTenantParam in project coprhd-controller by CoprHD.
the class KeystoneService method mapToOpenstackParam.
private OpenStackTenantParam mapToOpenstackParam(KeystoneTenant from) {
OpenStackTenantParam to = new OpenStackTenantParam();
to.setOsId(from.getId());
to.setDescription(from.getDescription());
to.setEnabled(Boolean.parseBoolean(from.getEnabled()));
to.setExcluded(false);
to.setName(from.getName());
return to;
}
use of com.emc.storageos.model.keystone.OpenStackTenantParam in project coprhd-controller by CoprHD.
the class LDAPsources method addTenants.
public static void addTenants(String ldadSourceId, @As(",") String[] ids) {
List<OpenStackTenantParam> tenants = OpenStackTenantsUtils.getOpenStackTenants();
if (ids != null) {
List<String> idList = Arrays.asList(ids);
for (OpenStackTenantParam tenant : tenants) {
if (!idList.contains(tenant.getOsId())) {
tenant.setExcluded(true);
}
}
}
OpenStackTenantListParam params = new OpenStackTenantListParam();
params.setOpenstackTenants(tenants);
OpenStackTenantsUtils.addOpenStackTenants(params);
flash.success(MessagesUtils.get(SAVED, authProviderName));
list();
}
use of com.emc.storageos.model.keystone.OpenStackTenantParam in project coprhd-controller by CoprHD.
the class LDAPsources method tenantsListJson.
/**
* Gets the list of tenants.
*/
public static void tenantsListJson() {
List<OpenStackTenantsDataTable.OpenStackTenant> tenants = Lists.newArrayList();
for (OpenStackTenantParam tenant : OpenStackTenantsUtils.getOpenStackTenants()) {
tenants.add(new OpenStackTenantsDataTable.OpenStackTenant(tenant));
}
renderJSON(DataTablesSupport.createJSON(tenants, params));
}
Aggregations