Make it possible to provide datacenter configuration for Consul (#558)

```yaml
consul:
  url: http://consul.host:8500
  token: long-token-here
  dc: dev1-d1
```
This commit is contained in:
V Aitvaras
2017-11-06 16:44:30 +01:00
committed by Alexander Kukushkin
parent 4daaf2beb0
commit ad7a1b8a16
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -158,7 +158,8 @@ class Consul(AbstractDCS):
if config.get('key') and config.get('cert'):
config['cert'] = (config['cert'], config['key'])
kwargs = {p: config.get(p) for p in ('host', 'port', 'token', 'scheme', 'cert', 'ca_cert') if config.get(p)}
config_keys = ('host', 'port', 'token', 'scheme', 'cert', 'ca_cert', 'dc')
kwargs = {p: config.get(p) for p in config_keys if config.get(p)}
verify = config.get('verify')
if not isinstance(verify, bool):
+1 -1
View File
@@ -74,7 +74,7 @@ class TestConsul(unittest.TestCase):
@patch.object(consul.Consul.KV, 'delete', Mock())
def setUp(self):
Consul({'ttl': 30, 'scope': 't', 'name': 'p', 'url': 'https://l:1', 'retry_timeout': 10,
'verify': 'on', 'key': 'foo', 'cert': 'bar', 'cacert': 'buz', 'token': 'asd'})
'verify': 'on', 'key': 'foo', 'cert': 'bar', 'cacert': 'buz', 'token': 'asd', 'dc': 'dc1'})
Consul({'ttl': 30, 'scope': 't', 'name': 'p', 'url': 'https://l:1', 'retry_timeout': 10,
'verify': 'on', 'cert': 'bar', 'cacert': 'buz'})
self.c = Consul({'ttl': 30, 'scope': 'test', 'name': 'postgresql1', 'host': 'localhost:1', 'retry_timeout': 10})