If you would like to contribute to the APEL REST interface.
- Fork us at https://github.com/apel/rest
- Create a feature branch off of
dev
- When ready, submit a pull request.
See here for instructions to run the Docker Images locally using docker-compose
We recommend this for development work ONLY.
-
Install python, pip, mysql, apache, apache modules, trust bundle and other required RPMS for development.
yum -y install python-pip python-devel mysql-server mysql mysql-devel gcc httpd httpd-devel mod_wsgi mod_ssl cronie at ca-policy-egi-core fetch-crl python-iso8601 python-ldap git bash-completion tree
-
Upgrade pip and setuptools
pip install pip --upgrade pip install setuptools --upgrade
-
Clone the repo to `/var/www/html
git clone https://github.com/apel/rest.git /var/www/html
-
Install requirements.txt
pip install -r /var/www/html/requirements.txt
-
Create the database
mysql -u root -e "create user 'apel'@'localhost';" mysql -u root -e "GRANT ALL PRIVILEGES ON apel_rest.* TO 'apel'@'localhost';" mysql -u root -e "FLUSH PRIVILEGES;" mysql -u apel -e "create database apel_rest" mysql -u apel apel_rest < /var/www/html/schemas/10-cloud.sql mysql -u apel apel_rest < /var/www/html/schemas/20-cloud-extra.sql
-
Create a new, self signed, certificate
mkdir /etc/httpd/ssl/ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt
-
Create etc, log, run and spool directories
mkdir /etc/apel mkdir /var/log/cloud mkdir /var/run/cloud mkdir -p /var/spool/apel/cloud/ chown apache -R /var/spool/apel/cloud/
-
Symlink the local config files into the
/etc
directory. Note: these commands will override any existing configurations in those locations.ln -sf /var/www/html/conf/apel_rest_api.conf /etc/httpd/conf.d/apel_rest_api.conf ln -sf /var/www/html/conf/ssl.conf /etc/httpd/conf.d/ssl.conf
-
To allow successful GET requests, you will need to register your APEL REST instance with the Indigo DataCloud IAM and add IAM variables in
/var/www/html/apel_rest/settings.py
. You will also need to register a second service (the querying test service), and authorise it by adding it's ID toALLOWED_FOR_GET
IAM_HOSTNAME_LIST= SERVER_IAM_ID= SERVER_IAM_SECRET= ALLOWED_FOR_GET=
-
To allow successful POST requests, you will need to add the DN of a CA-Signed certificate that you have access to (either a personal certificate or a host certificate) to
ALLOWED_FOR_POST
in/var/www/html/apel_rest/settings.py
-
Run
python /var/www/html/manage.py collectstatic
-
Start Apache with
service httpd start
-
Navigate a web browser to
https://<hostname>/api/v1/cloud/record/summary
Deploying an APEL Server along with the REST interface and database is not necessary, but is useful for allowing data to flow from input via the REST interface to summarised output via the REST interface. For the purposes of developing the APEL Rest interface we treat the APEL Server as a 'black box', so we recommend deploying it as a Docker image.
You will need to install Docker and Docker Compose first, see the README.md for a link to the instructions.
Then:
-
cd into
/var/www/html
-
Follow step 7 in the README.md.
-
Modify
docker/etc/apel/clouddb.cfg
so that the host with the database islocalhost
. -
Run
docker-compose -f yaml/docker-compose.yaml run -v /var/lib/mysql:/var/lib/mysql -d --no-deps apel_server
You should now have a running instance of the Docker-ized APEL Server, capable of talking to your development REST interface and database.