Class: Wakame::Runner::AdministratorCommand
- Inherits:
-
Object
- Object
- Wakame::Runner::AdministratorCommand
- Defined in:
- lib/wakame/runner/administrator_command.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args) ⇒ AdministratorCommand
constructor
A new instance of AdministratorCommand.
- #parse(args = @args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ AdministratorCommand
Returns a new instance of AdministratorCommand.
21 22 23 24 25 26 |
# File 'lib/wakame/runner/administrator_command.rb', line 21 def initialize(args) @args = args.dup @options = { :command_server_uri => Wakame.config.drb_command_server_uri } end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'lib/wakame/runner/administrator_command.rb', line 19 def @options end |
Instance Method Details
#parse(args = @args) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wakame/runner/administrator_command.rb', line 28 def parse(args=@args) args = args.dup comm_parser = OptionParser.new { |opts| opts. = "Usage: wakameadm [options] command [options]" opts.separator "" opts.separator "options:" opts.on( "-s", "--server DrbURI", "command server" ) {|str| @options[:command_server_uri] = str } } comm_parser.order!(args) @options.freeze return parse_subcommand(args) end |
#run ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/wakame/runner/administrator_command.rb', line 45 def run subcommand = parse begin cmd_queue = DRbObject.new_with_uri(@options[:command_server_uri]) #res = cmd_queue.send_cmd(Marshal.dump(subcommand)) subcommand = cmd_queue.send_cmd(subcommand) if subcommand.is_a? Exception STDERR.puts subcommand exit 1 end #res = cmd_queue.send(subcommand.class.command_name) rescue => e STDERR.puts e exit 1 end subcommand.print_result end |