scripts/agent_controller.rb in right_link-5.9.1 vs scripts/agent_controller.rb in right_link-5.9.2

- old
+ new

@@ -1,7 +1,7 @@ # === Synopsis: -# RightScale Agent Controller (rnac) - (c) 2009-2011 RightScale Inc +# RightScale Agent Controller (rnac) - (c) 2009-2013 RightScale Inc # # rnac is a command line tool for managing a RightLink agent # # === Examples: # Start new agent named AGENT: @@ -77,14 +77,16 @@ require 'rubygems' require 'right_agent/scripts/agent_controller' require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'agent_watcher')) +require File.expand_path(File.join(File.dirname(__FILE__), 'command_helper')) module RightScale class RightLinkAgentController < AgentController + include CommandHelper # Create and run controller # # === Return # true:: Always return true @@ -155,19 +157,12 @@ # command(String):: Command name # # === Return # (Boolean):: true if command executed successfully, otherwise false def run_command(message, command) - options = AgentConfig.agent_options(@options[:agent_name]) - listen_port = options[:listen_port] - unless listen_port - $stderr.puts "Could not retrieve listen port for agent #{@options[:identity]}" - return false - end puts message begin - @client = CommandClient.new(listen_port, options[:cookie]) - @client.send_command({ :name => command }, verbose = false, timeout = 100) { |r| puts r } + send_command({ :name => command }, verbose = false, timeout = 100) { |r| puts r } rescue SystemExit => e raise e rescue Exception => e $stderr.puts Log.format("Failed or else time limit was exceeded, confirm that local instance is still running", e, :trace) return false