Search in sources :

Example 1 with OpenStackTenantParam

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);
}
Also used : OpenStackTenantParam(com.emc.storageos.model.keystone.OpenStackTenantParam) ArrayList(java.util.ArrayList) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with OpenStackTenantParam

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;
}
Also used : OpenStackTenantParam(com.emc.storageos.model.keystone.OpenStackTenantParam)

Example 3 with OpenStackTenantParam

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();
}
Also used : OpenStackTenantParam(com.emc.storageos.model.keystone.OpenStackTenantParam) OpenStackTenantListParam(com.emc.storageos.model.keystone.OpenStackTenantListParam)

Example 4 with OpenStackTenantParam

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));
}
Also used : OpenStackTenantParam(com.emc.storageos.model.keystone.OpenStackTenantParam) OpenStackTenantsDataTable(models.datatable.OpenStackTenantsDataTable)

Aggregations

OpenStackTenantParam (com.emc.storageos.model.keystone.OpenStackTenantParam)4 OpenStackTenantListParam (com.emc.storageos.model.keystone.OpenStackTenantListParam)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ArrayList (java.util.ArrayList)1 OpenStackTenantsDataTable (models.datatable.OpenStackTenantsDataTable)1