Module: PortAuthority::Mechanism::FloatingIP
- Extended by:
- FloatingIP
- Included in:
- FloatingIP
- Defined in:
- lib/port-authority/mechanism/floating_ip.rb
Instance Attribute Summary collapse
-
#_icmp ⇒ Object
Returns the value of attribute _icmp.
Instance Method Summary collapse
- #arp_del! ⇒ Object
-
#arp_update! ⇒ Object
send gratuitous ARP to the network.
-
#duplicate? ⇒ Boolean
check whether the IP is registered anywhere.
-
#handle!(leader) ⇒ Object
add or remove VIP on interface.
- #init! ⇒ Object
-
#reachable? ⇒ Boolean
check reachability of VIP by ICMP echo.
-
#up? ⇒ Boolean
check whether VIP is assigned to me.
Instance Attribute Details
#_icmp ⇒ Object
Returns the value of attribute _icmp.
11 12 13 |
# File 'lib/port-authority/mechanism/floating_ip.rb', line 11 def _icmp @_icmp end |
Instance Method Details
#arp_del! ⇒ Object
43 44 45 46 |
# 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! ⇒ Object
send gratuitous ARP to the network
25 26 27 28 29 30 |
# 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? ⇒ Boolean
check whether the IP is registered anywhere
49 50 51 52 |
# 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) ⇒ Object
add or remove VIP on interface
19 20 21 22 |
# 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! ⇒ Object
13 14 15 16 |
# 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? ⇒ Boolean
check reachability of VIP by ICMP echo
38 39 40 41 |
# 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? ⇒ Boolean
check whether VIP is assigned to me
33 34 35 |
# 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 |