Skip to content

Commit

Permalink
Merge pull request #326 from bcantoni/fix-updateconf
Browse files Browse the repository at this point in the history
Improvements for updateconf, updatedseconf commands
  • Loading branch information
ptnapoleon committed Jul 6, 2015
2 parents 749a93d + fcad487 commit 014b2f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
13 changes: 2 additions & 11 deletions ccmlib/cmds/cluster_cmds.py
Expand Up @@ -605,7 +605,7 @@ def description(self):
return "Update the cassandra config files for all nodes"

def get_parser(self):
usage = "usage: ccm updateconf [options] [ new_setting | ... ], where new_setting should be a string of the form 'compaction_throughput_mb_per_sec: 32'"
usage = "usage: ccm updateconf [options] [ new_setting | ... ], where new_setting should be a string of the form 'compaction_throughput_mb_per_sec: 32'; nested options can be separated with a period like 'client_encryption_options.enabled: false'"
parser = self._get_default_parser(usage, self.description())
parser.add_option('--no-hh', '--no-hinted-handoff', action="store_false",
dest="hinted_handoff", default=True, help="Disable hinted handoff")
Expand Down Expand Up @@ -643,9 +643,8 @@ def description(self):
return "Update the dse config files for all nodes"

def get_parser(self):
usage = "usage: ccm updatedseconf [options] [ new_setting | ... ], where new_setting should be a string of the form 'max_solr_concurrency_per_core: 2'"
usage = "usage: ccm updatedseconf [options] [ new_setting | ... ], where new_setting should be a string of the form 'max_solr_concurrency_per_core: 2'; nested options can be separated with a period like 'cql_slow_log_options.enabled: true'"
parser = self._get_default_parser(usage, self.description())
parser.add_option('-y', '--yaml', action="store", type="string", dest="yaml_file", help="Path to a yaml file containing options to be copied into each node's dse.yaml. Useful for defining nested structures.", default=None)
return parser

def validate(self, parser, options, args):
Expand All @@ -656,15 +655,7 @@ def validate(self, parser, options, args):
print_(str(e), file=sys.stderr)
exit(1)

if self.options.yaml_file is not None:
if not os.path.exists(self.options.yaml_file):
print_("%s does not appear to be a valid file" % self.options.yaml_file)
exit(1)

def run(self):
if self.options.yaml_file is not None:
self.setting["dse_yaml_file"] = self.options.yaml_file

self.cluster.set_dse_configuration_options(values=self.setting)

#
Expand Down
24 changes: 9 additions & 15 deletions ccmlib/dse_node.py
Expand Up @@ -298,21 +298,15 @@ def __update_yaml(self):

full_options = dict(list(self.cluster._dse_config_options.items()))
for name in full_options:
if not name is 'dse_yaml_file':
value = full_options[name]
if value is None:
try:
del data[name]
except KeyError:
# it is fine to remove a key not there:w
pass
else:
data[name] = full_options[name]

if 'dse_yaml_file' in full_options:
with open(full_options['dse_yaml_file'], 'r') as f:
user_yaml = yaml.load(f)
data = common.yaml_merge(data, user_yaml)
value = full_options[name]
if type(value) is str and (value is None or len(value) == 0):
try:
del data[name]
except KeyError:
# it is fine to remove a key not there
pass
else:
data[name] = full_options[name]

with open(conf_file, 'w') as f:
yaml.safe_dump(data, f, default_flow_style=False)
Expand Down
4 changes: 2 additions & 2 deletions ccmlib/node.py
Expand Up @@ -1128,11 +1128,11 @@ def __update_yaml(self):
full_options = dict(list(self.cluster._config_options.items()) + list(self.__config_options.items())) # last win and we want node options to win
for name in full_options:
value = full_options[name]
if value is None:
if type(value) is str and (value is None or len(value) == 0):
try:
del data[name]
except KeyError:
# it is fine to remove a key not there:w
# it is fine to remove a key not there
pass
else:
try:
Expand Down

0 comments on commit 014b2f7

Please sign in to comment.