Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,950 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: consular | ||
user: ubuntu | ||
buildscript: sideloader/deploy.sh | ||
postinstall: sideloader/postinstall.sh | ||
virtualenv_prefix: consular | ||
pip: [] | ||
dependencies: | ||
- libssl-dev | ||
- libffi-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.egg-info | ||
*.pyc | ||
.coverage | ||
_trial_temp/ | ||
/docs/_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "pypy" | ||
cache: | ||
directories: | ||
- $HOME/.cache/pip | ||
install: | ||
- pip install coveralls | ||
- pip install --upgrade pip | ||
- pip install flake8 | ||
- pip install -r requirements-dev.txt | ||
- pip install -e . | ||
script: | ||
- flake8 consular | ||
- py.test consular --cov consular | ||
after_success: | ||
- coveralls | ||
deploy: | ||
provider: pypi | ||
user: smn | ||
password: | ||
secure: "J2nhv8v9jd9uTtXVV6UR55XZCw2cqdik7AvXfHN+gueBNYat6p66Cwv0q1f686UErkuVexJzKUiEkW2fAdV45rVPlYQpZk2gF2nySWmDhvaAetUAI0VOTD80tqIC84kD3tz1MyPX+nNfDa5KD8hmOGM0jRfzibUb6hsgUzc3jxQ1H88mXiWXLwJVvKmntdMNlA+2XiW1YiRguFNHZSHWP0taiCVwp3/53PJyXztfuIO6/HsTi2uCd1zhyae60kx5WfeohanyvW7Fdeo3uNyaqO7je6pjKCZP1NGzMes8ul/YCQ3k+hL32PV/z+CINMjxiiwFH7mJnztevaLkdcXFehX31ir9nxhMUqhrK5lVVwuokbtZ+WUkBy5w3n67oHAIlfXPk9GPoB3wRukae3nfqQMn55ukLXb1PaEwPEbHzTQ4xDjk12b5wAsArWwTORliBuy1yuCpAl1D+1C9k8QlC1cMa8r2+pMaY4nST0WPAtRCfGwogcIqxj7lEfVA0RajCEea24BYmv67OWbNr3ANcoOyg8x9wfEaJfW3ptingPp01dgK7jpc1ze8Ch/iy0mXc/BDz1Tgq4wO02sFKj+KTiVjwNh5bHF9Rzn9n7CS5lBbAjMJCnnqaAFxuaXTCPPBDPnNKn24l3heP+brGnOqVlszvEslj539XItoEqtT4Ug=" | ||
on: | ||
tags: true | ||
all_branches: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Copyright (c) 2014, Simon de Haan | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include VERSION | ||
include LICENSE | ||
include README.rst | ||
include requirements.txt | ||
recursive-include consular * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Consular | ||
======== | ||
|
||
Receive events from Marathon_, update Consul_ with the relevant information | ||
about services & tasks. | ||
|
||
.. image:: https://travis-ci.org/universalcore/consular.svg?branch=develop | ||
:target: https://travis-ci.org/universalcore/consular | ||
:alt: Continuous Integration | ||
|
||
.. image:: https://coveralls.io/repos/universalcore/consular/badge.png?branch=develop | ||
:target: https://coveralls.io/r/universalcore/consular?branch=develop | ||
:alt: Code Coverage | ||
|
||
.. image:: https://readthedocs.org/projects/consular/badge/?version=latest | ||
:target: https://consular.readthedocs.org | ||
:alt: Consular Documentation | ||
|
||
.. image:: https://badge.fury.io/py/consular.svg | ||
:target: https://pypi.python.org/pypi/consular | ||
:alt: Pypi Package | ||
|
||
Usage | ||
~~~~~ | ||
|
||
:: | ||
|
||
$ pip install consular | ||
$ consular --help | ||
|
||
|
||
.. _Marathon: http://mesosphere.github.io/marathon/ | ||
.. _Consul: http://consul.io/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.1 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import click | ||
import sys | ||
|
||
from urllib import urlencode | ||
|
||
|
||
@click.command() | ||
@click.option('--scheme', default='http', | ||
help='The scheme to use. (HTTP/HTTPS)') | ||
@click.option('--host', default='localhost', | ||
help='The host to bind to.') | ||
@click.option('--port', default='7000', type=int, | ||
help='The port to listen to.') | ||
@click.option('--consul', default='http://localhost:8500', | ||
help='The Consul HTTP API') | ||
@click.option('--marathon', default='http://localhost:8080', | ||
help='The Marathon HTTP API') | ||
@click.option('--registration-id', | ||
help=('Auto register for Marathon event callbacks with the ' | ||
'registration-id. Must be unique for each consular ' | ||
'process.'), type=str) | ||
@click.option('--sync-interval', | ||
help=('Automatically sync the apps in Marathon with what\'s ' | ||
'in Consul every _n_ seconds. Defaults to 0 (disabled).'), | ||
type=int) | ||
@click.option('--purge/--no-purge', | ||
help=('Automatically purge dead services from Consul if they ' | ||
'are not known in Marathon ' | ||
'(needs sync-interval enabled).'), | ||
default=False) | ||
@click.option('--logfile', | ||
help='Where to log output to', | ||
type=click.File('a'), | ||
default=sys.stdout) | ||
@click.option('--debug/--no-debug', | ||
help='Log debug output or not', | ||
default=False) | ||
@click.option('--timeout', | ||
help='HTTP API client timeout', | ||
default=5, type=int) | ||
@click.option('--fallback/--no-fallback', | ||
help=('Fallback to the default Consul agent for service ' | ||
'registration if the host running the mesos tasks ' | ||
'is not running a consul agent. ' | ||
'ONLY USE IF YOU KNOW WHAT YOU ARE DOING.'), | ||
default=False) | ||
@click.option('--fallback-timeout', | ||
help=('How long to wait until assuming there is no consul ' | ||
'agent running on a mesos-slave machine'), | ||
default=2, type=int) | ||
def main(scheme, host, port, | ||
consul, marathon, registration_id, | ||
sync_interval, purge, logfile, debug, timeout, | ||
fallback, fallback_timeout): # pragma: no cover | ||
from consular.main import Consular | ||
from twisted.internet.task import LoopingCall | ||
from twisted.internet import reactor | ||
from twisted.python import log | ||
|
||
log.startLogging(logfile) | ||
|
||
consular = Consular(consul, marathon, fallback) | ||
consular.debug = debug | ||
consular.timeout = timeout | ||
consular.fallback_timeout = fallback_timeout | ||
if registration_id: | ||
events_url = "%s://%s:%s/events?%s" % ( | ||
scheme, host, port, | ||
urlencode({ | ||
'registration': registration_id, | ||
})) | ||
consular.register_marathon_event_callback(events_url) | ||
|
||
if sync_interval > 0: | ||
lc = LoopingCall(consular.sync_apps, purge) | ||
lc.start(sync_interval, now=True) | ||
|
||
consular.run(host, port) | ||
reactor.run() |
Oops, something went wrong.