Exemple #1
0
    def user_get(self, username):
        """Get user by user name.

        :param username: string user name
        :return role: dict with user description
        """
        user = find_first(self._common.keystone.users.list(),
                          lambda x: x.name == username)
        return user
Exemple #2
0
    def tenants_create(self, tenant_name):
        """Create tenant with given name.

        :param tenant_name: name of tenant
        :return tenant: dict with tenant details
        """
        tenant = find_first(self.tenants_list(),
                            lambda x: x.name == tenant_name)
        if tenant is None:
            tenant = self._common.keystone.tenants.create(
                tenant_name=tenant_name,
                enabled=True)
            logger.info("Created tenant name:'{0}', id:'{1}'".format(
                tenant_name, tenant.id))
        else:
            logger.warning(
                "Tenant already exist, name: '{0}' id: '{1}'".format(
                    tenant_name, tenant.id))
        return tenant