class TungstenAPI::ReplicatorAPICall
ReplicatorAPICall
is a class that handles API Calls through Tungsten Replicator tools
It uses the same interface as APICall
, but it is initialized differently
Public instance methods:
-
initialize (name, tools_path, tool, command, help, rmi_port=10000)
-
get (service)
Attributes
command[RW]
Public Class Methods
dashes()
click to toggle source
override ancestor’s dashes
# File lib/tungsten/api.rb, line 315 def self.dashes return sprintf(@@template, '----', '----', '-------', '----') end
header()
click to toggle source
override ancestor’s header
# File lib/tungsten/api.rb, line 308 def self.header return sprintf(@@template, :name.to_s, :tool.to_s, :command.to_s, :help.to_s) end
new(name, tools_path, tool, command, help, rmi_port=10000)
click to toggle source
Initializes a ReplicatorAPICall
object
name : how to identify the API call tool : which tool we are calling tools_path : where to find the tool rmi_port : which port should trepctl use help : a brief description of the API call
# File lib/tungsten/api.rb, line 272 def initialize (name, tools_path, tool, command, help, rmi_port=10000) @name = name @tool = tool @command = command @tools_path = tools_path @rmi_port = rmi_port @help = help end
Public Instance Methods
get(service, host, more_options)
click to toggle source
Get a JSON
object from the output of a command, such as ‘trepctl status -json’ If ‘service’ and host are given, the command is called with -service #{service} and -host #{host}
# File lib/tungsten/api.rb, line 285 def get(service, host, more_options) service_clause='' host_clause='' port_clause='' more_options = '' unless more_options if service service_clause = "-service #{service}" end if host host_clause = "-host #{host}" end if @rmi_port port_clause= "-port #{@rmi_port}" end full_command = "#{@tools_path}/#{@tool} #{port_clause} #{host_clause} #{service_clause} #{command} #{more_options}" puts full_command if ENV["SHOW_INTERNALS"] json_text = %x(#{full_command}) return JSON.parse(json_text) end
to_hash()
click to toggle source
# File lib/tungsten/api.rb, line 323 def to_hash return { :name.to_s => @name, :tool.to_s => @tool, :command.to_s => @command , :help.to_s => @help } end
to_s()
click to toggle source
# File lib/tungsten/api.rb, line 319 def to_s return sprintf(@@template, @name, @tool, @command, @help) end