Convert all etcd-specific configs to nested
Change-Id: I1342857d3321e1afec60df068aad4ae69713f93f Depends-On: I3f2a908ebdb185bb92660683dd5606bf06e15a8e
This commit is contained in:
parent
3ef35acd3e
commit
8619ec9bcf
|
@ -41,8 +41,8 @@ class ProcessException(Exception):
|
|||
def retry(f):
|
||||
@functools.wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
attempts = VARIABLES.get('etcd_connection_attempts', 10)
|
||||
delay = VARIABLES.get('etcd_connection_delay', 5)
|
||||
attempts = VARIABLES['etcd']['connection_attempts']
|
||||
delay = VARIABLES['etcd']['connection_delay']
|
||||
while attempts > 1:
|
||||
try:
|
||||
return f(*args, **kwargs)
|
||||
|
@ -250,10 +250,10 @@ def get_etcd_client():
|
|||
if VARIABLES["role_name"] == "etcd":
|
||||
etcd_machines.append(
|
||||
(VARIABLES["network_topology"]["private"]["address"],
|
||||
VARIABLES["etcd_client_port"]))
|
||||
VARIABLES["etcd"]["client_port"]))
|
||||
else:
|
||||
etcd_machines.append(
|
||||
(address('etcd'), VARIABLES["etcd_client_port"])
|
||||
(address('etcd'), VARIABLES["etcd"]["client_port"])
|
||||
)
|
||||
|
||||
etcd_machines_str = " ".join(["%s:%d" % (h, p) for h, p in etcd_machines])
|
||||
|
|
|
@ -104,10 +104,10 @@ class TestGetVariables(base.TestCase):
|
|||
class TestRetry(base.TestCase):
|
||||
def setUp(self):
|
||||
super(TestRetry, self).setUp()
|
||||
start_script.VARIABLES = {
|
||||
'etcd_connection_attempts': 3,
|
||||
'etcd_connection_delay': 0
|
||||
}
|
||||
start_script.VARIABLES = {'etcd': {
|
||||
'connection_attempts': 3,
|
||||
'connection_delay': 0
|
||||
}}
|
||||
|
||||
@start_script.retry
|
||||
def func_test(self):
|
||||
|
@ -132,7 +132,11 @@ class TestGetETCDClient(base.TestCase):
|
|||
def test_get_etcd_local_client(self):
|
||||
start_script.VARIABLES = {
|
||||
"role_name": "etcd",
|
||||
"etcd_client_port": 10042,
|
||||
"etcd": {
|
||||
"client_port": 10042,
|
||||
"connection_attempts": 3,
|
||||
"connection_delay": 0,
|
||||
},
|
||||
"network_topology": {
|
||||
"private": {
|
||||
"address": "192.0.2.1"
|
||||
|
@ -153,7 +157,11 @@ class TestGetETCDClient(base.TestCase):
|
|||
start_script.VARIABLES = {
|
||||
"role_name": "banana",
|
||||
"namespace": "ccp",
|
||||
"etcd_client_port": 1234
|
||||
"etcd": {
|
||||
"client_port": 1234,
|
||||
"connection_attempts": 3,
|
||||
"connection_delay": 0,
|
||||
},
|
||||
}
|
||||
with mock.patch("etcd.Client") as m_etcd:
|
||||
expected_value = object()
|
||||
|
|
Loading…
Reference in New Issue