Thanks to @troeder for providing the documentation in the first place!
Check if components are running
service apache2 status service ucs-school-import-http-api status service postgresql status service rabbitmq-server status service ucs-school-import-celery-worker status
Check if components are working
Django, Django REST framework and PostgreSQL
If the join script succeeded, the database already contains a list of OUs. Let’s say we have two OUs in our domain:
$ univention-ldapsearch -LLL objectClass=ucsschoolOrganizationalUnit ou dn: ou=SchoolOne,dc=uni,dc=dtr ou: SchoolOne dn: ou=SchoolTwo,dc=uni,dc=dtr ou: SchoolTwo
Those OUs should already exist as objects in Djangos database:
$ python3 -m ucsschool.http_api.manage shell -c "from ucsschool.http_api.import_api.models import School; print(School.objects.all())"
Apache and Gunicorn
To check if the the backends frontend components work, go to the API root
https://$HOST/api/v1/
. If the page exists, Apache and Gunicorn are working as well. You’ll get a HTTP 403 with {“detail”: “Authentication credentials were not provided.”}. That’s OK - the API cannot be used without authenticating. Use the Log in link in the top right corner and authenticate as Administrator. You’ll now be able to see some links to follow:{ "roles": "https://$HOST/api/v1/roles/", "schools": "https://$HOST/api/v1/schools/", "imports/users": "https://$HOST/api/v1/imports/users/" }
If the lists behind those links are empty, it is because the logged in user does not have the required import permission on any school. That may also be true for the Administrator user. You can log into the UMC and start the UMC schoolimport module. If the module tells you that The permissions to perform a user import are not sufficient enough, then either the user is not part of any security group or you need to restart the UMC server:
service univention-management-console-server restart
Assuming you have a user with import permissions, you can log in with that user and retrieve the list of schools and finished import jobs. The web site
https://$HOST/api/v1/schools/
should list the schools for which the user was given permissions now. Instead of using a browser, the HTTP-API can of course be queried directly through HTTP. Please make sure to replace myteacher and the password univention:$ curl -s -k -H "Content-Type: application/json" -u myteacher:univention https://$(hostname -f)/api/v1/schools/ | python3 -m json.tool
RabbitMQ and Celery
To check if the RabbitMQ and Celery services work, we’ll need to start an import. But to start an import, we’ll need a CSV file and a matching import configuration. You can use the internal tools from /usr/share/ucs-school-import/scripts/ e.g. ucs-school-testuser-import to create a CSV file:
$ ROLE=student $ OU=SchuleEins $ /usr/share/ucs-school-import/scripts/ucs-school-testuser-import \ --httpapi \ --$ROLE 10 \ --classes 2 \ --create-email-addresses \ --csvfile test-http-import.csv \ $OU
A CSV file created by ucs-school-user-import with the –httpapi argument is designed to work with the configuration file ucs-school-testuser-http-import.json. As such, the CSV file can be imported on the command line with:
$ /usr/share/ucs-school-import/scripts/ucs-school-user-import \ --conffile /usr/share/ucs-school-import/configs/ucs-school-testuser-http-import.json \ --user_role $ROLE \ --school $OU \ --infile test-http-import.csv \ --source_uid "$OU-$ROLE" \ --verbose
The ucs-school-testuser-import script will print a help message at the end, with the above instructions that can be copied and pasted to immediately start an import from the command line.
To delete the users imported with the previous command, create a CSV file with just the header line, but without user lines:
$ head -1 test-http-import.csv > delete-all-users.csv
When running the import, make sure to specify the source_uid correctly. The following will delete all students of SchuleEins that were imported using the HTTP-API configuration file:
$ OU=SchuleEins $ ROLE=student $ /usr/share/ucs-school-import/scripts/ucs-school-user-import \ --conffile /usr/share/ucs-school-import/configs/user_import_http-api.json \ --user_role $ROLE \ --school $OU \ --infile delete-all-users.csv \ --source_uid "$OU-$ROLE" \ --verbose