Class: IptablesWeb::Model::Node

Inherits:
Base
  • Object
show all
Defined in:
lib/iptables_web/model/node.rb

Class Method Summary collapse

Methods inherited from Base

configure

Class Method Details

.handshakeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/iptables_web/model/node.rb', line 7

def self.handshake
  node = find('current')
  node.ips = []
  ::System.get_ifaddrs.each do |interface, config|
    next if interface.to_s.include?('lo')
    node.ips.push({
      interface: interface,
      ip: config[:inet_addr],
      netmask: config[:netmask]
    })
  end
  node.ips.uniq! { |ip| ip[:ip] }
  node.hostname = `hostname -f`
  if node.save && block_given?
    yield
  end
end