From 22571764e7760e4d8aaa55ae28538694cf2d4362 Mon Sep 17 00:00:00 2001 From: Dave Dittrich Date: Wed, 27 Jan 2016 22:04:10 -0800 Subject: [PATCH 1/6] Add --address option to set registered service address --- src/ianitor/args_parser.py | 5 +++++ src/ianitor/script.py | 1 + src/ianitor/service.py | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ianitor/args_parser.py b/src/ianitor/args_parser.py index e0107f4..caaf724 100644 --- a/src/ianitor/args_parser.py +++ b/src/ianitor/args_parser.py @@ -141,6 +141,11 @@ def get_parser(): help="set service id - must be node unique (defaults to service name)" ) + parser.add_argument( + "--address", + help="set service address", + ) + parser.add_argument( "--port", type=int, diff --git a/src/ianitor/script.py b/src/ianitor/script.py index 34ce93f..c6bf995 100644 --- a/src/ianitor/script.py +++ b/src/ianitor/script.py @@ -74,6 +74,7 @@ def main(): service_name=args.service_name, service_id=args.id, tags=args.tags, + address=args.address, port=args.port ) diff --git a/src/ianitor/service.py b/src/ianitor/service.py index 7d1d740..d785878 100644 --- a/src/ianitor/service.py +++ b/src/ianitor/service.py @@ -38,7 +38,7 @@ def ignore_connection_errors(action="unknown"): class Service(object): def __init__(self, command, session, ttl, service_name, - service_id=None, tags=None, port=None): + service_id=None, tags=None, address=None, port=None): self.command = command self.session = session self.process = None @@ -46,6 +46,7 @@ def __init__(self, command, session, ttl, service_name, self.ttl = ttl self.service_name = service_name self.tags = tags or [] + self.address = address self.port = port self.service_id = service_id or service_name @@ -94,6 +95,7 @@ def register(self): self.session.agent.service.register( name=self.service_name, service_id=self.service_id, + address=self.address, port=self.port, tags=self.tags, # format the ttl into XXXs format From d6da5b8d0b5686f334c2b8b18ec71009f7ef023b Mon Sep 17 00:00:00 2001 From: mjaworski Date: Tue, 22 Mar 2016 19:01:01 +0100 Subject: [PATCH 2/6] CI: add passenv to tox.ini in order to fix coveralls integration --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 4adc340..a64322f 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,7 @@ exclude=.git,.tox,dist,doc,*lib/python*,*egg,.idea,docs show-source = True [testenv:coverage] +passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH deps = pytest-cov coveralls {[testenv]deps} From 2ada49dee781b8dd5eb55905974b50fedee2bdfd Mon Sep 17 00:00:00 2001 From: mjaworski Date: Wed, 23 Mar 2016 12:18:31 +0100 Subject: [PATCH 3/6] tests: extend test matrix in tox and CI and add missing trove classifiers --- .travis.yml | 30 ++++++++++++++++++++++++------ setup.py | 5 +++++ tox.ini | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6987683..45242a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,32 @@ language: python install: pip install tox --use-mirrors env: - - TOX_ENV=py27 - - TOX_ENV=py33 - - TOX_ENV=pep8 - - TOX_ENV=coverage + matrix: + # consul 0.4.1 + - TOX_ENV=py27 CONSUL_VERSION=0.4.1 + - TOX_ENV=py33 CONSUL_VERSION=0.4.1 + - TOX_ENV=py34 CONSUL_VERSION=0.4.1 + - TOX_ENV=py35 CONSUL_VERSION=0.4.1 + + # consul 0.5.2 + - TOX_ENV=py27 CONSUL_VERSION=0.5.2 + - TOX_ENV=py33 CONSUL_VERSION=0.5.2 + - TOX_ENV=py34 CONSUL_VERSION=0.5.2 + - TOX_ENV=py35 CONSUL_VERSION=0.5.2 + + # consul 0.6.4 + - TOX_ENV=py27 CONSUL_VERSION=0.6.4 + - TOX_ENV=py33 CONSUL_VERSION=0.6.4 + - TOX_ENV=py34 CONSUL_VERSION=0.6.4 + - TOX_ENV=py35 CONSUL_VERSION=0.6.4 + + # coverage and style checks + - TOX_ENV=pep8 CONSUL_VERSION=0.4.1 + - TOX_ENV=coverage CONSUL_VERSION=0.4.1 before_script: - - wget https://releases.hashicorp.com/consul/0.4.1/consul_0.4.1_linux_amd64.zip - - unzip consul_0.4.1_linux_amd64.zip + - wget https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip + - unzip consul_${CONSUL_VERSION}_linux_amd64.zip - start-stop-daemon --start --background --exec `pwd`/consul -- agent -server -data-dir /tmp/consul -bootstrap-expect=1 script: diff --git a/setup.py b/setup.py index e04e962..926f510 100644 --- a/setup.py +++ b/setup.py @@ -82,7 +82,12 @@ def read_md(f): 'Intended Audience :: Developers', 'Operating System :: OS Independent', 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', 'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)', # noqa ], diff --git a/tox.ini b/tox.ini index a64322f..79f42c8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,pep8 +envlist = py27,py33,py34,py35,pep8 [testenv] deps = -r{toxinidir}/requirements.txt From b7726b830731352f75d7726dfca06675cdddac67 Mon Sep 17 00:00:00 2001 From: mjaworski Date: Wed, 23 Mar 2016 12:29:59 +0100 Subject: [PATCH 4/6] update README.md --- README.md | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 13782a4..f3254fd 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,13 @@ your existing process/service supervision tool like [circus](http://circus.readthedocs.org/en/0.11.1/), [runit](http://smarden.org/runit/) etc. +## Consul/Python versions compatibility + +**ianitor** is compatibile with Python 2.7, 3.3, 3.4, and 3.5 versions. +It is also tested against each latest patch version of every major/minor consul +release starting from 0.4.1 version. + +For details of our test matrix see `travis.yml` file. ## Installation and usage @@ -26,25 +33,27 @@ And you're ready to go with: You can check if service is registered diggin' into consul DNS service: - $ dig @localhost -p 8600 appname.service.consul - ; <<>> DiG 9.9.3-P1 <<>> @localhost -p 8600 appname.service.consul - ; (1 server found) - ;; global options: +cmd - ;; Got answer: - ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25966 - ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 - ;; WARNING: recursion requested but not available - - ;; QUESTION SECTION: - ;appname.service.consul. IN A - - ;; ANSWER SECTION: - appname.service.consul. 0 IN A 10.54.54.214 - - ;; Query time: 44 msec - ;; SERVER: 127.0.0.1#8600(127.0.0.1) - ;; WHEN: Tue Oct 28 13:53:09 CET 2014 - ;; MSG SIZE rcvd: 78 +```console +$ dig @localhost -p 8600 appname.service.consul +; <<>> DiG 9.9.3-P1 <<>> @localhost -p 8600 appname.service.consul +; (1 server found) +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25966 +;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 +;; WARNING: recursion requested but not available + +;; QUESTION SECTION: +;appname.service.consul. IN A + +;; ANSWER SECTION: +appname.service.consul. 0 IN A 10.54.54.214 + +;; Query time: 44 msec +;; SERVER: 127.0.0.1#8600(127.0.0.1) +;; WHEN: Tue Oct 28 13:53:09 CET 2014 +;; MSG SIZE rcvd: 78 +``` Full usage: From 6dd07ac7739335626270f17c346cffb8b4c046df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20=C5=9Amiejczak?= Date: Fri, 7 Jul 2017 11:32:31 +0200 Subject: [PATCH 5/6] Fix travis config. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 45242a8..4b33fcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python -install: pip install tox --use-mirrors +install: pip install tox env: matrix: # consul 0.4.1 From 8141b28d23a3d9984a6d574efdee74e36aeaf7b8 Mon Sep 17 00:00:00 2001 From: Dave Dittrich Date: Wed, 27 Jan 2016 22:04:10 -0800 Subject: [PATCH 6/6] Add --address option to set registered service address --- src/ianitor/args_parser.py | 5 +++++ src/ianitor/script.py | 1 + src/ianitor/service.py | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ianitor/args_parser.py b/src/ianitor/args_parser.py index e0107f4..caaf724 100644 --- a/src/ianitor/args_parser.py +++ b/src/ianitor/args_parser.py @@ -141,6 +141,11 @@ def get_parser(): help="set service id - must be node unique (defaults to service name)" ) + parser.add_argument( + "--address", + help="set service address", + ) + parser.add_argument( "--port", type=int, diff --git a/src/ianitor/script.py b/src/ianitor/script.py index 34ce93f..c6bf995 100644 --- a/src/ianitor/script.py +++ b/src/ianitor/script.py @@ -74,6 +74,7 @@ def main(): service_name=args.service_name, service_id=args.id, tags=args.tags, + address=args.address, port=args.port ) diff --git a/src/ianitor/service.py b/src/ianitor/service.py index 7d1d740..d785878 100644 --- a/src/ianitor/service.py +++ b/src/ianitor/service.py @@ -38,7 +38,7 @@ def ignore_connection_errors(action="unknown"): class Service(object): def __init__(self, command, session, ttl, service_name, - service_id=None, tags=None, port=None): + service_id=None, tags=None, address=None, port=None): self.command = command self.session = session self.process = None @@ -46,6 +46,7 @@ def __init__(self, command, session, ttl, service_name, self.ttl = ttl self.service_name = service_name self.tags = tags or [] + self.address = address self.port = port self.service_id = service_id or service_name @@ -94,6 +95,7 @@ def register(self): self.session.agent.service.register( name=self.service_name, service_id=self.service_id, + address=self.address, port=self.port, tags=self.tags, # format the ttl into XXXs format