# File lib/rudy/routines/handlers/rye.rb, line 13
13:      def create_box(hostname, opts={})
14:        ld [:hostname, hostname, opts, caller[0]]
15:        opts = {
16:          :debug => false,
17:          :user => current_machine_user, 
18:          :ostype => current_machine_os || :unix,
19:          :impltype => :linux, 
20:          :info => STDOUT,
21:          :paranoid => false  # doesn't get passed through (Rye bug?)
22:        }.merge opts
23:        
24:        nickname = hostname
25:        if hostname.kind_of? Rudy::Machine
26:          hostname, nickname = hostname.dns_public, hostname.name
27:        end
28:        
29:        box = ::Rye::Box.new hostname, opts
30:        box.nickname = nickname
31:       
32:        local_keys = Rye.keys
33:        box.add_keys local_keys if local_keys.is_a?(Array)
34:        box.add_key user_keypairpath(opts[:user])
35:        
36:        # We define hooks so we can still print each command and its output
37:        # when running the command blocks. NOTE: We only print this in
38:        # verbosity mode. 
39:        if !@@global.parallel && !@@global.quiet
40:          # This block gets called for every command method call.
41:          box.pre_command_hook do |cmd, user, host, nickname|
42:            print_command user, nickname, cmd
43:          end
44:        end
45: 
46:        if @@global.verbose > 0 && !@@global.quiet
47:          box.stdout_hook do |content|
48:            li content
49:          end
50:          # And this one gets called after each command method call.
51:          box.post_command_hook do |ret|
52:            print_response ret
53:          end
54:        end
55: 
56:        box.exception_hook(::Rye::Err, &rbox_exception_handler)
57:        box.exception_hook(Exception, &rbox_exception_handler)
58:        
59:        ## It'd better for unknown commands to be handled elsewhere
60:        ## because it doesn't make sense to retry a method that doesn't exist
61:        ##box.exception_hook(Rye::CommandNotFound, &rbox_exception_handler)
62: 
63:        box
64:      end