Created
January 28, 2014 22:52
-
-
Save achanda/8678327 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def znode_bind_ip | |
#Needs to load on call so it gets recently written changes | |
site_conf = SC.load | |
result = nil | |
addrs = Socket.ip_address_list | |
mngmt_cidr = NetAddr::CIDR.create(site_conf.management_cidr) | |
addrs.each do |addr| | |
valid_ip = NetAddr.validate_ip_addr(addr.ip_address, :Version => 4) rescue false | |
if valid_ip | |
if mngmt_cidr.matches?(addr.ip_address) | |
result = addr.ip_address | |
end | |
end | |
end | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment