Sha256: 9b2d407203dec165823afde6abe5655b76c1f8e3e3171ef08a78ed7b72d63fe4
Contents?: true
Size: 1.48 KB
Versions: 12
Compression:
Stored size: 1.48 KB
Contents
#!/usr/bin/env ruby require 'infoblox' require 'pp' require 'optparse' def print_host(*hosts) hosts.flatten.each do |h| puts "Host\t#{h.name}" puts "IP \t" + h.ipv4addrs.map{|i| i["ipv4addr"]}.join(",") puts "Ref \t" + h._ref end end options = {} OptionParser.new do |opts| opts.banner = "Usage: #{$0}.rb [options]" opts.on("-u", "--user USER", "username for infoblox") do |u| options[:username] = u end opts.on("-p", "--pass PASSWORD", "password for infoblox") do |p| options[:password] = p end opts.on("-f", "--find SEARCH", "find the specified hosts (fuzzy match) and print info") do |f| options[:find] = f end opts.on("-h", "--host INFOBLOX_HOST", "the hostname of the Infoblox appliance, including protocol") do |h| options[:host] = h end opts.on("-c", "--create HOST_AND_IP", "create the specified host. Supply the host and ip address, separated by a comma (no space).") do |c| options[:create] = c end opts.on("-d", "--delete HOST", "delete the specified host ") do |d| options[:delete] = d end opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| options[:verbose] = v end end.parse! if options[:verbose] options[:logger] = Logger.new(STDOUT) end client = Infoblox::Client.new(options) if options[:find] print_host client.find_host_by_name(options[:find]) end if options[:delete] print_host client.delete_host(options[:delete]) end if options[:create] pp client.create_host(*options[:create].split(',')) end
Version data entries
12 entries across 12 versions & 1 rubygems