module PortAuthority::Mechanism::FloatingIP
Attributes
_icmp[RW]
Public Instance Methods
arp_del!()
click to toggle source
# File lib/port-authority/mechanism/floating_ip.rb, line 43 def arp_del! return true if shellcmd Config.commands[:arp], '-d', Config.lbaas[:floating_ip], '>/dev/null 2>&1' false end
arp_update!()
click to toggle source
send gratuitous ARP to the network
# File lib/port-authority/mechanism/floating_ip.rb, line 25 def arp_update! # return true if shellcmd Config.commands[:arping], '-U', '-q', '-c', Config.lbaas[:arping_count], '-I', Config.lbaas[:floating_iface], Config.lbaas[:floating_ip] return true if shellcmd Config.commands[:arping], '-U', '-q', '-c', Config.lbaas[:arping_count], '-I', Config.lbaas[:floating_iface], Config.lbaas[:floating_ip] false end
duplicate?()
click to toggle source
check whether the IP is registered anywhere
# File lib/port-authority/mechanism/floating_ip.rb, line 49 def duplicate? return false if shellcmd Config.commands[:arping], '-D', '-q', '-c', Config.lbaas[:arping_count], '-w', Config.lbaas[:arping_wait], '-I', Config.lbaas[:floating_iface], Config.lbaas[:floating_ip] true end
handle!(leader)
click to toggle source
add or remove VIP on interface
# File lib/port-authority/mechanism/floating_ip.rb, line 19 def handle!(leader) return true if shellcmd Config.commands[:iproute], 'address', leader ? 'add' : 'delete', "#{Config.lbaas[:floating_ip]}/32", 'dev', Config.lbaas[:floating_iface], '>/dev/null 2>&1' false end
init!()
click to toggle source
# File lib/port-authority/mechanism/floating_ip.rb, line 13 def init! @_icmp = Net::Ping::ICMP.new(Config.lbaas[:floating_ip]) Logger.debug(Config.lbaas.to_yaml) end
reachable?()
click to toggle source
check reachability of VIP by ICMP echo
# File lib/port-authority/mechanism/floating_ip.rb, line 38 def reachable? (1..Config.lbaas[:icmp_count]).each { return true if @_icmp.ping } false end
up?()
click to toggle source
check whether VIP is assigned to me
# File lib/port-authority/mechanism/floating_ip.rb, line 33 def up? Socket.ip_address_list.map(&:ip_address).member?(Config.lbaas[:floating_ip]) end
Private Instance Methods
shellcmd(*args)
click to toggle source
# File lib/port-authority/mechanism/floating_ip.rb, line 55 def shellcmd(*args) cmd = args.join(' ').to_s cksum = Digest::SHA256.hexdigest(args.join.to_s)[0..15] Logger.debug "Executing shellcommand #{cksum} - #{cmd}" ret = system cmd Logger.debug "Shellcommand #{cksum} returned #{ret.to_s}" end