Quaidan is a python wrapper for mod_proxy_balancer's balancer manager.
Quaidan currently has two features:
- Provide the current state of the load balancer.
- Update cluster members.
This package is published on PyPi. You can use pip to install it.
pip install quaidan
The starting point for all interactions is a BalancerManager object.
It is created by specifying the balancer manager's URL.
from quaidan import BalancerManager
balancer_manager = BalancerManager('http://127.0.0.1/balancer-manager')This BalancerManager can be used to read the current state of the load
balancer. The following snippet prints alle infos that are available
from the balancer manager page.
status = balancer_manager.get_status()
print('clusters:')
for cluster in status.clusters:
print(' -')
print(' name: ' + cluster.name)
print(' members:')
for member in cluster.members:
print(' -')
print(' worker_url: "' + member.worker_url + '"')
print(' route: "' + str(member.route) + '"')
print(' route_redirect: "' + str(member.route_redirect) + '"')
print(' load_factor: ' + str(member.load_factor))
print(' lb_set: ' + str(member.lb_set))
print(' ignore_errors: ' + str(member.ignore_errors))
print(' draining_mode: ' + str(member.draining_mode))
print(' enabled: ' + str(member.enabled))
print(' hot_standby: ' + str(member.hot_standby))
print(' elected: ' + str(member.elected))
print(' busy: ' + str(member.busy))
print(' load: ' + str(member.load))
print(' transferred: ' + member.transferred)
print(' read: ' + member.read)The BalancerManager is used for updating members, too. Please import
the UpdateMembercommand first.
from quaidan.command import UpdateMemberNow create an UpdateMember command from a Member tuple.
status = balancer_manager.get_status()
cluster = status.clusters[0]
update_member = UpdateMember(cluster.name, cluster.members[0])Update the attributes that should be changed and send the command to the balancer manager.
update_member.route = 'dummy route'
update_member.route_redirect = 'dummy route redirect'
update_member.load_factor = 1
update_member.lb_set = 1
update_member.ignore_errors = True
update_member.drainig_mode = True
update_member.enabled = True
update_member.hot_standby = True
balancer_manager.send_command(update_member)If you have a feature request, found a bug or want to ask a question about Quaidan then please feel free to
- write an issue.
- create a pull request. (See Understanding the GitHub Flow)
- write a mail to mail@stefan-birkner.de
Please write a test for every change you make. Run all tests and Pylint
python setup.py lint test
in order to ensure that you didn't break an existing feature and your code complies with the Pylint standards.
For this you need Pylint and a running Apache with a
mod_proxy_balancer. The file setup_apache.sh can be used to set up
a well configured Apache server if you're using Ubuntu Linux.
I strongly encourage you to use Vagrant.
Qaidan provides a Vagrantfile that sets up a virtual machine with
all prerequisites. You need three commands only to start the virtual
machine and execute Quaidan's test suite.
vagrant up
vagrant ssh
python setup.py lint test
- Ensure that the version is set in
setup.pyandquaidan/__init.py__. - Create a release tag:
git tag quaidan-x.x.x -m "Release x.x.x". - Push the tag to GitHub:
git push --tags. - Upload to PyPI:
python setup.py sdist upload -r pypi. - Create a release on GitHub.