Skip to content

Commit

Permalink
config/cassandra: not supported tuples of server/port for cassandra-d…
Browse files Browse the repository at this point in the history
…river < 3.17

Related-Jira-Bug: CEM-10731
Signed-off-by: Sahid Orentino Ferdjaoui <sferdjaoui@juniper.net>
Change-Id: I26112a9fa5032598925bfd09a52353ef5fe2125d
  • Loading branch information
Sahid Orentino Ferdjaoui committed Sep 10, 2020
1 parent a451a45 commit 334ef90
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/config/common/cfgm_common/datastore/drivers/cassandra_cql.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
connector = None


DEFAULT_CQL_PORT = 9042

# Properties passed to the column familly
TABLE_PROPERTIES = {
'gc_grace_seconds': vns_constants.CASSANDRA_DEFAULT_GC_GRACE_SECONDS,
Expand Down Expand Up @@ -338,19 +340,31 @@ def _Init_Cluster(self):
}

# Addresses, ports related options
endpoints = []
endpoints, port = [], None
for address in self._server_list:
try:
server, port = address.split(':', 1)

endpoints.append((server, int(port)))
server, _port = address.split(':', 1)
_port = int(_port)

if port is not None:
if port != _port:
self.options.logger(
"Please consider fixing port for '{}', all "
"servers should have same port. "
"Using '{}'".format(
address, port), level=SandeshLevel.SYS_WARN)
else:
port = _port

endpoints.append(server)
except ValueError:
endpoints.append(address)

connector.ProtocolVersion.SUPPORTED_VERSIONS = self.ProtocolVersions
try:
self._cluster = connector.cluster.Cluster(
endpoints,
port=(port or DEFAULT_CQL_PORT),
ssl_options=ssl_options,
auth_provider=auth_provider,
execution_profiles=profiles,
Expand Down

0 comments on commit 334ef90

Please sign in to comment.