Code Monkey home page Code Monkey logo

marathon-python's Introduction

marathon-python

Build Status

This is a Python library for interfacing with Marathon servers via Marathon's REST API.

Compatibility

  • For Marathon 1.6.x, use at least 0.10.0
  • For Marathon 1.4.1, use at least 0.8.13
  • For Marathon 1.1.1, use at least 0.8.1
  • For all version changes, please see CHANGELOG.md

If you find a feature that is broken, please submit a PR that adds a test for it so it will be fixed and will continue to stay fixed as Marathon changes over time.

Just because this library is tested against a specific version of Marathon, doesn't necessarily mean that it supports every feature and API Marathon provides.

Installation

From PyPi (recommended)

pip install marathon

From GitHub

pip install -e [email protected]:thefactory/marathon-python.git#egg=marathon

From source

git clone [email protected]:thefactory/marathon-python
python marathon-python/setup.py install

Testing

marathon-python uses Travis to test the code against different versions of Marathon. You can run the tests locally on a Linux machine that has docker on it:

Running The Tests

make itests

Running The Tests Against a Specific Version of Marathon

MARATHONVERSION=1.6.322 make itests

Documentation

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

Basic Usage

Create a MarathonClient() instance pointing at your Marathon server(s):

>>> from marathon import MarathonClient
>>> c = MarathonClient('http://localhost:8080')

>>> # or multiple servers:
>>> c = MarathonClient(['http://host1:8080', 'http://host2:8080'])

Then try calling some methods:

>>> c.list_apps()
[MarathonApp::myapp1, MarathonApp::myapp2]
>>> from marathon.models import MarathonApp
>>> c.create_app('myapp3', MarathonApp(cmd='sleep 100', mem=16, cpus=1))
MarathonApp::myapp3
>>> app = c.get_app('myapp3')
>>> app.ports
[19671]
>>> app.mem = 32
>>> c.update_app('myapp3', app)
{'deploymentId': '83b215a6-4e26-4e44-9333-5c385eda6438', 'version': '2014-08-26T07:37:50.462Z'}
>>> c.get_app('myapp3').mem
32.0
>>> c.get_app('myapp3').instances
1
>>> c.scale_app('myapp3', instances=3)
{'deploymentId': '611b89e3-99f2-4d8a-afe1-ec0b83fdbb88', 'version': '2014-08-26T07:40:20.121Z'}
>>> c.get_app('myapp3').instances
3
>>> c.scale_app('myapp3', delta=-1)
{'deploymentId': '1081a99c-55e8-4404-907b-4a3697059848', 'version': '2014-08-26T07:43:30.232Z'}
>>> 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')
[]

License

Open source under the MIT License. See LICENSE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.