module Status

common methods

Public Class Methods

active?() click to toggle source

Are we the active node?

# File lib/whimsy/asf/status.rb, line 12
def do |rs|
    active = rs.getaddress("") # Official hostname as IP
    current = rs.getaddress(Socket.gethostname) rescue nil # local as IP
    return current == active
hostname() click to toggle source

this hostname

# File lib/whimsy/asf/status.rb, line 21
def self.hostname
  `hostname`.chomp # TODO: could be cached?
migrating?() click to toggle source

are we migrating?

# File lib/whimsy/asf/status.rb, line 26
def self.migrating?
  false # Edit as needed
testnode?() click to toggle source

are we a test node?

# File lib/whimsy/asf/status.rb, line 31
def self.testnode?
  # Assume test nodes are not called whimsy...[]
  hostname !~ %r{^whimsy.*(\.apache\.org)?$}
updates_disallowed_reason() click to toggle source

If local updates are not allowed, return reason string, else nil nil if:

  • active node

  • not migrating

  • or testnode

# File lib/whimsy/asf/status.rb, line 41
def self.updates_disallowed_reason
  return nil if testnode?
  return 'Service temporarily unavailable due to migration.' if migrating?
  return 'Service unavailable on this node. Please ensure you have logged in to the correct host.' unless active?