in ccmlib/node.py [0:0]
def _update_yaml(self):
conf_file = self.get_conf_file()
with open(conf_file, 'r') as f:
data = yaml.safe_load(f)
with open(conf_file, 'r') as f:
yaml_text = f.read()
data['cluster_name'] = self.cluster.name
data['auto_bootstrap'] = self.auto_bootstrap
data['initial_token'] = self.initial_token
if not self.cluster.use_vnodes and self.get_base_cassandra_version() >= 1.2:
data['num_tokens'] = 1
if 'seeds' in data:
# cassandra 0.7
data['seeds'] = self.cluster.get_seeds()
else:
# cassandra 0.8
data['seed_provider'][0]['parameters'][0]['seeds'] = ','.join(self.cluster.get_seeds())
data['listen_address'], data['storage_port'] = self.network_interfaces['storage']
if self.network_interfaces['thrift'] is not None and self.get_base_cassandra_version() < 4:
data['rpc_address'], data['rpc_port'] = self.network_interfaces['thrift']
if self.network_interfaces['binary'] is not None and self.get_base_cassandra_version() >= 1.2:
data['rpc_address'], data['native_transport_port'] = self.network_interfaces['binary']
data['data_file_directories'] = [os.path.join(self.get_path(), 'data{0}'.format(x)) for x in xrange(0, self.cluster.data_dir_count)]
data['commitlog_directory'] = os.path.join(self.get_path(), 'commitlogs')
data['saved_caches_directory'] = os.path.join(self.get_path(), 'saved_caches')
if 'metadata_directory' in data:
data['metadata_directory'] = os.path.join(self.get_path(), 'metadata')
if self.get_cassandra_version() > '3.0' and 'hints_directory' in yaml_text:
data['hints_directory'] = os.path.join(self.get_path(), 'hints')
if self.get_cassandra_version() >= '3.8':
data['cdc_raw_directory'] = os.path.join(self.get_path(), 'cdc_raw')
if self.cluster.partitioner:
data['partitioner'] = self.cluster.partitioner
# Get a map of combined cluster and node configuration with the node
# configuration taking precedence.
full_options = common.merge_configuration(
self.cluster._config_options,
self.__config_options, delete_empty=False)
if 'endpoint_snitch' in full_options and full_options['endpoint_snitch'] == 'org.apache.cassandra.locator.PropertyFileSnitch':
# multi dc cluster, needs to read cassandra-topology.properties - if cassandra.yaml is modern, we use TFLP and unset the endpoint_snitch
if 'initial_location_provider' in data:
data['initial_location_provider'] = 'org.apache.cassandra.locator.TopologyFileLocationProvider'
full_options.pop('endpoint_snitch', None)
else:
# test might set endpoint_snitch: GPFS for example, in this case we need to keep that and unset ILP (or other way round)
if 'initial_location_provider' in full_options:
data.pop('endpoint_snitch', None)
elif 'endpoint_snitch' in full_options:
data.pop('initial_location_provider', None)
data.pop('node_proximity', None)
# Merge options with original yaml data.
data = common.merge_configuration(data, full_options)
conf_dest = os.path.join(self.get_conf_dir(), common.CASSANDRA_CONF)
with open(conf_dest, 'w') as f:
yaml.safe_dump(data, f, default_flow_style=False, sort_keys=False)