Skip to content

Commit 1d35a13

Browse files
committed
scylla/cloud.py: support using ip address in server
Align with scylladb/gocql#106, so: When host information was missing, driver used resolved IP address as TLS.ServerName. Instead it should connect to Server specified in ConnectionConfig and use NodeDomain as SNI. Depends: scylladb/scylla-ccm#412 Ref: scylladb/gocql#106
1 parent 5e5919a commit 1d35a13

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

cassandra/scylla/cloud.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,12 @@ def __init__(self, configuration_file, pyopenssl=False, endpoint_factory=None):
8383
if username and password:
8484
self.auth_provider = PlainTextAuthProvider(username, password)
8585

86-
8786
@property
8887
def contact_points(self):
8988
_contact_points = []
9089
for data_center in self.data_centers.values():
91-
address, _, _ = self.get_server(data_center)
92-
_contact_points.append(self.endpoint_factory.create_from_sni(address))
90+
_, _, node_domain = self.get_server(data_center)
91+
_contact_points.append(self.endpoint_factory.create_from_sni(node_domain))
9392
return _contact_points
9493

9594
def get_server(self, data_center):

tests/integration/standard/test_scylla_cloud.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from tests.integration import use_cluster
77
from cassandra.cluster import Cluster, TwistedConnection
8-
from cassandra.connection import SniEndPointFactory
98
from cassandra.io.asyncorereactor import AsyncoreConnection
109
from cassandra.io.libevreactor import LibevConnection
1110
from cassandra.io.geventreactor import GeventConnection
@@ -45,21 +44,17 @@ def start_cluster_with_proxy(self):
4544
ccm_cluster.sni_proxy_listen_port = listen_port
4645
ccm_cluster._update_config()
4746

48-
config_data_yaml, config_path_yaml = create_cloud_config(ccm_cluster.get_path(), listen_port)
49-
50-
endpoint_factory = SniEndPointFactory(listen_address, port=int(listen_port),
51-
node_domain="cluster-id.scylla.com")
52-
53-
return config_data_yaml, config_path_yaml, endpoint_factory
47+
config_data_yaml, config_path_yaml = create_cloud_config(ccm_cluster.get_path(),
48+
port=listen_port, address=listen_address)
49+
return config_data_yaml, config_path_yaml
5450

5551
def test_1_node_cluster(self):
5652
self.ccm_cluster = use_cluster("sni_proxy", [1], start=False)
57-
config_data_yaml, config_path_yaml, endpoint_factory = self.start_cluster_with_proxy()
53+
config_data_yaml, config_path_yaml = self.start_cluster_with_proxy()
5854

5955
for config in [config_path_yaml, config_data_yaml]:
6056
for connection_class in supported_connection_classes:
61-
cluster = Cluster(scylla_cloud=config, connection_class=connection_class,
62-
endpoint_factory=endpoint_factory)
57+
cluster = Cluster(scylla_cloud=config, connection_class=connection_class)
6358
with cluster.connect() as session:
6459
res = session.execute("SELECT * FROM system.local")
6560
assert res.all()
@@ -69,12 +64,11 @@ def test_1_node_cluster(self):
6964

7065
def test_3_node_cluster(self):
7166
self.ccm_cluster = use_cluster("sni_proxy", [3], start=False)
72-
config_data_yaml, config_path_yaml, endpoint_factory = self.start_cluster_with_proxy()
67+
config_data_yaml, config_path_yaml = self.start_cluster_with_proxy()
7368

7469
for config in [config_path_yaml, config_data_yaml]:
7570
for connection_class in supported_connection_classes:
76-
cluster = Cluster(scylla_cloud=config, connection_class=connection_class,
77-
endpoint_factory=endpoint_factory)
71+
cluster = Cluster(scylla_cloud=config, connection_class=connection_class)
7872
with cluster.connect() as session:
7973
res = session.execute("SELECT * FROM system.local")
8074
assert res.all()

0 commit comments

Comments
 (0)