class F5::Cli::Subcommand

Private Instance Methods

client() click to toggle source
# File lib/f5/cli/application.rb, line 26
def client
  return @client if @client
  config = YAML.load_file(options[:config])
  if config.key?('username') && options[:lb] == 'default'
    puts "Warning: credentials in #{options[:config]} should be put under a named load balancer."
    configure_lb_as(config)
  else
    configure_lb_as config[options[:lb]]
  end
  F5::Icontrol::API.new
end
configure_lb_as(config) click to toggle source
# File lib/f5/cli/application.rb, line 38
def configure_lb_as(config)
  F5::Icontrol.configure do |f5|
    f5.host = config['host']
    f5.username = config['username']
    f5.password = config['password']
  end
end
extract_items(response, opts = nil) click to toggle source
# File lib/f5/cli/application.rb, line 9
def extract_items(response, opts = nil)
  items = response[:item]

  if items.nil?
    return opts == :as_array ? [] : nil
  end

  if items.is_a?(Hash) && items.has_key?(:item)
    items = items[:item]
  end
  if opts == :as_array && items.is_a?(Hash)
    [ items ]
  else
    items
  end
end
itemize(option) click to toggle source
# File lib/f5/cli/application.rb, line 46
def itemize(option)
  {
    item: [ option ]
  }
end