Skip to content

Commit f8b3536

Browse files
authored
Change replicate_from to an optional value (#120)
1 parent 79fad51 commit f8b3536

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cterasdk/core/setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,24 @@ def init_application_server(self, ipaddr, secret):
109109
self._init_role(params)
110110
self._portal.startup.wait()
111111

112-
def init_replication_server(self, ipaddr, secret, replicate_from):
112+
def init_replication_server(self, ipaddr, secret, replicate_from=None):
113113
"""
114114
Initialize a CTERA Portal Database Replication Server.
115115
116116
:param str ipaddr: The CTERA Portal master server IP address
117117
:param str secret: A password or a PEM-encoded private key
118-
:param str replicate_from: The name of a CTERA Portal server replication source
118+
:param str replicate_from: The name of a CTERA Portal server to replicate from
119119
"""
120120
self._init_slave(ipaddr, secret)
121121
if self.stage == SetupWizardStage.Replication:
122122
logging.getLogger().info('Initializing a Replication Database Server. %s', {'host': ipaddr, 'replicate_from': replicate_from})
123123
logging.getLogger().debug('Retrieving database replication candidates.')
124124
replication_candidates = {re.search('([^/]+$)', k).group(0): k for k in self.get_replication_candidates()}
125125
if replication_candidates:
126-
server = replication_candidates.get(replicate_from)
126+
if replicate_from is None and len(replication_candidates) == 1:
127+
server = next(iter(replication_candidates.values()))
128+
else:
129+
server = replication_candidates.get(replicate_from)
127130
if server:
128131
logging.getLogger().debug('Found server in replication candidates. %s', {'server': replicate_from})
129132
params = Setup._init_replication_param(server)

0 commit comments

Comments
 (0)