aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/leap_cli/commands/node.rb28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/leap_cli/commands/node.rb b/lib/leap_cli/commands/node.rb
index 4c7230c..f34b55a 100644
--- a/lib/leap_cli/commands/node.rb
+++ b/lib/leap_cli/commands/node.rb
@@ -186,9 +186,7 @@ module LeapCli; module Commands
def seed_node_data(node, args)
args.each do |seed|
key, value = seed.split(':')
- if value =~ /,/
- value = value.split(',')
- end
+ value = format_seed_value(value)
assert! key =~ /^[0-9a-z\._]+$/, "illegal characters used in property '#{key}'"
if key =~ /\./
key_parts = key.split('.')
@@ -205,6 +203,30 @@ module LeapCli; module Commands
end
end
+ #
+ # conversations:
+ #
+ # "x,y,z" => ["x","y","z"]
+ #
+ # "22" => 22
+ #
+ # "5.1" => 5.1
+ #
+ def format_seed_value(v)
+ if v =~ /,/
+ v = v.split(',')
+ v.map do |i|
+ i = i.to_i if i.to_i.to_s == i
+ i = i.to_f if i.to_f.to_s == i
+ i
+ end
+ else
+ v = v.to_i if v.to_i.to_s == v
+ v = v.to_f if v.to_f.to_s == v
+ end
+ return v
+ end
+
def validate_ip_address(node)
IPAddr.new(node['ip_address'])
rescue ArgumentError