Labs/Weave/Sync/Server-Nodes
Setup
Create an account in mysql to be used.
Create or alter to get the following table:
create table available_nodes ( node varchar(30) not null primary key, cluster varchar(10) not null, db_host varchar(30), db_name varchar(10), db_modulo int, test_username varchar(10), test_password varchar(10), assignments_per_period int, available_assignments int, actives int, max_capacity int not null, quota int, downed tinyint default 0, backoff int default 0 )
Insert a row into this table for each sync node. Cluster on the dev box should be 'dev' (I think the live boxes will probably end up being 'phx1').
Checkout the source from http://hg.mozilla.org/services/server-node-assignment
Edit the admin_uri value in scripts/refresh_nodes.py and syncnodes.wsgi (eventually, these'll be in a config file, but Tarek is teasing out Config into it's own library)
Make sure you have pypi2rpm installed. Then run:
python setup.py --command-packages pypi2rpm.command bdist_rpm2 --spec-file SyncNodes.spec
install the rpm.
the tests in tests/mappertests.py and tests/webtests.py should now run successfully.
Set up an hourly cron running /etc/syncnodes/scripts/refresh_nodes.py
Exposing the API
This API can do a lot of damage. It should be IP and htaccess restricted, I suspect, possibly only available on one of our VPNs.
Edit the apache file to add:
WSGIScriptAlias /<entrypoint> /etc/syncnodes/syncnodes.wsgi
(If we want to move this elsewhere, then we can edit the spec file in the rpm)
at this point, you should get a json response from http://$host/$entrypoint/dev
I'm attaching a very primitive web page that interacts with the API. Install and protect it carefully somewhere. Edit the two constants at the top to point to your api.