Skip to content

Instantly share code, notes, and snippets.

@jasonlyles
Created September 11, 2009 01:33
Show Gist options
  • Save jasonlyles/184995 to your computer and use it in GitHub Desktop.
Save jasonlyles/184995 to your computer and use it in GitHub Desktop.
F5 pool dump
#This quickie is for getting a dump of all nodes and whether they're active or not
#from a pool on an F5. Takes one arg, the IP of the F5 in question.
require 'yaml'
require 'openssl'
gem 'soap4r'
require 'xsd/qname'
require 'soap/wsdlDriver'
require 'net/ssh'
require 'net/http'
require 'net/https'
require 'win32/process'
include Windows::Handle
class BIGIP_Connection
attr_accessor :bigip_config, :bigip_driver
def initialize(bigip_address)
config_file = 'config\load_balancers.yml'
begin
configuration = YAML::load_file(config_file)
rescue Exception => yaml_ex
puts "Error loading configuration from '#{config_file}': #{yaml_ex}."
return false
end
@bigip_config = {
:user => configuration[bigip_address]['user'],
:password => configuration[bigip_address]['password'],
:endpoint => configuration[bigip_address]['endpoint'],
:wsdl => configuration[bigip_address]['wsdl']
}
@bigip_driver = SOAP::WSDLDriverFactory.new(@bigip_config[:wsdl]).create_rpc_driver
basic_auth = []
basic_auth << @bigip_config[:endpoint]
basic_auth << @bigip_config[:user]
basic_auth << @bigip_config[:password]
verify_mode = OpenSSL::SSL::VERIFY_NONE
@bigip_driver.options['protocol.http.ssl_config.verify_mode']= verify_mode
@bigip_driver.options['protocol.http.basic_auth'] << basic_auth
#Need this line to override the F5 default endpoint_url
@bigip_driver.endpoint_url = @bigip_config[:endpoint]
end
def pool_dump(pool_name)
nodes = self.bigip_driver.get_object_status(pool_name)
if nodes[0].length == 0
puts "There are no nodes for this pool"
else
nodes[0].each do |x|
port = x.member.port
address = x.member.address
status = x.object_status.enabled_status.match(/_[A-Z]+$/).to_s.sub("_",'')
availability = x.object_status.availability_status.match(/_[A-Z]+$/).to_s.sub("_",'')
puts "#{address}:#{port}?#{status}?#{availability}"
end
end
end
end
@bigip = BIGIP_Connection.new(ARGV[0])
@bigip.pool_dump("SYM_BR_SSL")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment