module DockDriver::Template::Network
Adds network-related methods to the DockDriver::Template
DSL.
Public Instance Methods
first_ipv4()
click to toggle source
Return the first non-localhost IPv4 address. Example:
<%= first_ipv4 %> => 10.5.4.3
# File lib/dock_driver/template/network.rb, line 44 def first_ipv4 return self.ip_addrs.select { |a| a.ipv4? }.first.ip_address end
first_ipv6()
click to toggle source
Return the first non-localhost IPv6 address.
Example:
<%= first_ipv4 %> => 20a3::2
# File lib/dock_driver/template/network.rb, line 53 def first_ipv6 return self.ip_addrs.select { |a| a.ipv6? }.first.ip_address end
fqdn()
click to toggle source
Returns the current FQDN of this host. Example:
<%= fqdn %> => grumpus.somenet.org
# File lib/dock_driver/template/network.rb, line 12 def fqdn return Socket.gethostbyname(Socket.gethostname).first end
hostname()
click to toggle source
Returns the short hostname of this host. Example:
<%= host %> => grumpus <%= hostname %> => grumpus
# File lib/dock_driver/template/network.rb, line 22 def hostname return Socket.gethostname end
Also aliased as: host
ip_addrs()
click to toggle source
Returns a list of all non-localhost IP addresses. Example:
<%= ip_addrs %> => 10.5.4.3 10.4.3.2 20a3::2
# File lib/dock_driver/template/network.rb, line 33 def ip_addrs return Socket.ip_address_list.reject do |a| a.ip_address.match /^(fe80|127\.|::1)/ end end