From: Steve Barber Date: Tue, 1 Jul 2014 20:35:50 +0000 (-0400) Subject: Add parsing for multiple "public network" values. X-Git-Tag: v0.8.0~30^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2f6eb6ff99c2dd0255f44c365aaab3cdff4b8250;p=ceph-cookbooks.git Add parsing for multiple "public network" values. --- diff --git a/libraries/default.rb b/libraries/default.rb index 495a96a..b7b34dc 100644 --- a/libraries/default.rb +++ b/libraries/default.rb @@ -31,19 +31,21 @@ def osd_secret end end -# If public_network is specified -# we need to search for the monitor IP -# in the node environment. -# 1. We look if the network is IPv6 or IPv4 -# 2. We look for a route matching the network -# 3. We grab the IP and return it with the port +# If public_network is specified with one or more networks, we need to +# search for a matching monitor IP in the node environment. +# 1. For each public network specified: +# a. We look if the network is IPv6 or IPv4 +# b. We look for a route matching the network +# c. If we found match, we return the IP with the port def find_node_ip_in_network(network, nodeish = nil) nodeish = node unless nodeish - net = IPAddr.new(network) - nodeish['network']['interfaces'].each do |_iface, addrs| - addresses = addrs['addresses'] || [] - addresses.each do |ip, params| - return ip_address_to_ceph_address(ip, params) if ip_address_in_network?(ip, params, net) + network.split(/\s*,\s*/).each do |n| + net = IPAddr.new(n) + nodeish['network']['interfaces'].each do |_iface, addrs| + addresses = addrs['addresses'] || [] + addresses.each do |ip, params| + return ip_address_to_ceph_address(ip, params) if ip_address_in_network?(ip, params, net) + end end end nil