Code Monkey home page Code Monkey logo

chronos-python's Introduction

chronos-python

Build Status

This is a Python client library for the Chronos HTTP Rest API

Installation

From PyPi

pip install chronos-python

From Source

git clone [email protected]/asher/chronos-python
python setup.py install

Usage Examples

Create a ChronosClient

>>> import chronos
>>> client = chronos.connect("chronos.mesos.server.com:8080")
# or specify multilple servers that will be tried in order
>>> client = chronos.connect(["chronos1.mesos.server.com:8080", "chronos2.mesos.server.com:8080"])

List all jobs:

 >>> client.list()
 [{u'softError': False, u'scheduleTimeZone': u'null', u'successCount': 702, u'cpus': 0.25, u'disabled': False, u'ownerName': u'', u'owner': u'noop', u'disk': 256.0, u'errorCount': 0, u'container': {u'image': u'my-docker-registry:443/myimage', u'type': u'docker', u'network': u'BRIDGE', u'volumes': []}, u'errorsSinceLastSuccess': 0, u'highPriority': False, u'dataProcessingJobType': False, u'arguments': [], u'uris': [u'file:///root/.dockercfg'], u'shell': True, u'description': u'', u'schedule': u'R/2015-12-18T10:40:00.000Z/PT10M', u'mem': 1024.0, u'epsilon': u'PT60S', u'retries': 2, u'name': u'my job 1', u'runAsUser': u'root', u'lastSuccess': u'2015-12-18T10:30:09.755Z', u'environmentVariables': [], u'executorFlags': u'', u'command': u'sensu-scheduled-canary.sh', u'executor': u'', u'async': False, u'lastError': u'', u'constraints': []}, {u'softError': False, u'scheduleTimeZone': u'null', u'successCount': 40, u'cpus': 0.25, u'disabled': False, u'ownerName': u'', u'owner': u'noop', u'disk': 256.0, u'errorCount': 0, u'container': {u'image': u'my-docker-regsitry:443/myimage', u'type': u'docker', u'network': u'BRIDGE', u'volumes': [], u'errorsSinceLastSuccess': 0, u'highPriority': False, u'dataProcessingJobType': False, u'arguments': [], u'uris': [u'file:///root/.dockercfg'], u'shell': True, u'description': u'', u'schedule': u'R/2015-12-18T11:00:00.000Z/PT60M', u'mem': 1024.0, u'epsilon': u'PT60S', u'retries': 2, u'name': u'example_service mesosstage_kwabatch gitfb0c7ac5 config95bc9b2f', u'runAsUser': u'root', u'lastSuccess': u'2015-12-18T08:00:12.965Z', u'environmentVariables': [], u'executorFlags': u'', u'command': u'echo "This batch should run once per hour, and take 2 hours" && sleep 2h', u'executor': u'', u'async': False, u'lastError': u'', u'constraints': []}]

Add a new job:

>>> job = { 'async': False, 'command': 'echo 1', 'epsilon': 'PT15M', 'name': 'foo',
'owner': '[email protected]', 'disabled': True, 'schedule': 'R/2014-01-01T00:00:00Z/PT60M'}
>>> client.add(job)

Update an existing job:

>>> job = { 'async': False, 'command': 'echo 1', 'epsilon': 'PT15M', 'name': 'foo',
'owner': '[email protected]', 'disabled': True, 'schedule': 'R/2014-01-01T00:00:00Z/PT60M'}
>>> client.update(job)

Run a job:

>>> client.run("job123")

Delete a job:

>>> client.delete("job123")

Delete all the in flight tasks for a job:

>>> client.delete_tasks("job123")

Included Scripts

  • chronos-sync-jobs.py - Sync chronos jobs from a directory tree containing job.json files. chronos-sync-jobs.py --hostname chronos.server.com:4400 --sync /path/to/job.json/files

  • chronos-nagios.py - Nagios/Icinga style monitor of jobs chronos-nagios.py --hostname chronos.server.com:4400 --crit 3 --prefix etl. --prefix data. chronos-nagios.py --hostname chronos.server.com:4400 --crit 3 --exclude etl.

Testing

chronos-python uses Travis to test against multiple versions of Chronos. You can run the tests locally on any machine with Docker on it.

To run the tests:

make itests

To run against a different version of Chronos:

CHRONOSVERSION=2.4.0 make itests

chronos-python's People

Contributors

asher avatar keshavdv avatar navidurrahman avatar rob-johnson avatar solarkennedy avatar xkrt avatar

Watchers

 avatar  avatar

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.