From b928a8f29b40df545ac6a72ead6cb9ed6a36fbda Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 24 Aug 2016 17:37:00 -0700 Subject: leap vm: fixed bug, added more sanity checking. --- lib/leap_cli/config/environment.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/leap_cli/config') diff --git a/lib/leap_cli/config/environment.rb b/lib/leap_cli/config/environment.rb index dadd9eaf..ce570839 100644 --- a/lib/leap_cli/config/environment.rb +++ b/lib/leap_cli/config/environment.rb @@ -121,6 +121,18 @@ module LeapCli; module Config end end + # + # Alters the node's json config file. Unfortunately, doing this will + # strip out all the comments. + # + def update_node_json(node, new_values) + node_json_path = Path.named_path([:node_config, node.name]) + old_data = load_json(node_json_path, Config::Node) + new_data = old_data.merge(new_values) + new_contents = JSON.sorted_generate(new_data) + "\n" + Util::write_file! node_json_path, new_contents + end + private def load_all_json(pattern, object_class, options={}) -- cgit v1.2.3