This is a Python library for interfacing with Marathon servers via Marathon's REST API.
- marathon-python is currently developed against Marathon 0.6.1 (REST API version 2)
pip install marathon
pip install -e [email protected]:thefactory/marathon-python.git#egg=marathon
git clone [email protected]:thefactory/marathon-python
python marathon-python/setup.py install
Create a MarathonClient()
instance pointing at your Marathon server:
>>> from marathon import MarathonClient
>>> c = MarathonClient("http://localhost:8080")
Then try calling some methods:
>>> c.list_apps()
[MarathonApp::myapp1, MarathonApp::myapp2]
>>> c.create_app(id='myapp3', cmd='sleep 100', mem=16, cpus=1)
True
>>> app = c.get_app('myapp3')
>>> app.ports
[19671]
>>> c.update_app('myapp3', app, mem=32)
True
>>> c.get_app('myapp3').mem
32.0
>>> c.get_app('myapp3').instances
1
>>> c.scale_app('myapp3', 2)
True
>>> c.get_app('myapp3').instances
3
>>> c.scale_app('myapp3', delta=-1)
True
>>> c.get_app('myapp3').instances
2
>>> c.list_tasks('myapp1')
[MarathonTask:myapp1-1398201790254]
>>> c.kill_tasks('myapp1', scale=True)
[MarathonTask:myapp1-1398201790254]
>>> c.list_tasks('myapp1')
[]
API documentation is here.
Or you can build the documentation yourself:
pip install sphinx
pip install sphinx_rtd_theme
cd docs/
make html
The documentation will be in <project-root>/gh-pages/html
:
open gh-pages/html/index.html
Open source under the MIT License. See LICENSE.