Class: CommandQueryHandler

Inherits:
Object show all
Defined in:
lib/proto/command_query_handler.rb

Class Method Summary collapse

Class Method Details

.run_query(on_cloud, command, args, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/proto/command_query_handler.rb', line 2

def self.run_query(on_cloud, command, args, opts={})
  port = opts[:port] || 11223
  host = opts[:host] || "localhost"

  transport = Thrift::BufferedTransport.new(Thrift::Socket.new(host, port))
  protocol = Thrift::BinaryProtocol.new(transport)

  client = CloudThrift::CommandInterface::Client.new(protocol)
  transport.open()

  cld = CloudThrift::CloudQuery.new
  cld.name = on_cloud.name
  
  ddputs("Running command: #{command} on #{cld.name} at #{host}:#{port}")
  resp = client.run_command(cld, command, args)
  resp.response
end