agent_client/bin/agent_client
# encoding: UTF-8
#!/usr/bin/env ruby
$:.unshift(File.expand_path('../../lib', __FILE__))
require 'agent_client'
require 'optparse'
# Defaults
options = {
'mbus' => 'https://vcap:vcap@localhost:6969',
}
opts = OptionParser.new do |opts|
opts.banner = 'Usage: agent_client [<options>] [ping|state]'
opts.on('-m', '--mbus String', 'mbus (https://user:pass@host:port)') do |opt|
options['mbus'] = opt
end
end
command = ARGV.pop
unless %w[ping state].include?(command)
$stderr.puts opts
exit 1
end
opts.parse!(ARGV.dup)
mbus = URI.parse(options['mbus'])
user, password = mbus.user, mbus.password
mbus.user = mbus.password = nil
api = Bosh::Agent::Client.create(mbus.to_s, 'user' => user, 'password' => password)
puts api.send(command.to_sym)