Class: EventMachine::WinRM::Server
- Inherits:
-
Object
- Object
- EventMachine::WinRM::Server
- Includes:
- EM::Deferrable
- Defined in:
- lib/em-winrm/server.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#master ⇒ Object
Returns the value of attribute master.
Instance Method Summary collapse
-
#initialize(master, host, options) ⇒ Server
constructor
A new instance of Server.
-
#run_command(data) ⇒ Object
create a shell and run command.
-
#unbind ⇒ Object
Notify upstream master that the backend server is done processing the request.
Constructor Details
#initialize(master, host, options) ⇒ Server
Returns a new instance of Server.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/em-winrm/server.rb', line 28 def initialize(master, host, ) @master = master @host = host @transport = [:transport] || :plaintext = [:user] = .delete(:user) || ENV['USER'] || ENV['USERNAME'] || "unknown" [:pass] = .delete(:password) [:port] = .delete(:port) || 5985 [:basic_auth_only] = true unless defined? [:basic_auth_only] [:no_ssl_peer_verification] = false unless defined? [:no_ssl_peer_verification] end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
26 27 28 |
# File 'lib/em-winrm/server.rb', line 26 def host @host end |
#master ⇒ Object
Returns the value of attribute master.
26 27 28 |
# File 'lib/em-winrm/server.rb', line 26 def master @master end |
Instance Method Details
#run_command(data) ⇒ Object
create a shell and run command
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/em-winrm/server.rb', line 43 def run_command(data) cid = UUIDTools::UUID.random_create.to_s EM.epoll EM.run do EM.defer(proc do WinRM::Log.debug("#{@host} => :run_command") @shell = Shell.new(client, self) @shell.on_output do |out| @master.relay_output_from_backend(@host, out) end @shell.on_error do |error| @master.relay_error_from_backend(@host, error) end @shell.on_close do |result, exit_code| @master.command_complete(@host, cid, exit_code) end @shell.run_command(data) end) end cid end |
#unbind ⇒ Object
Notify upstream master that the backend server is done processing the request
69 70 71 72 |
# File 'lib/em-winrm/server.rb', line 69 def unbind WinRM::Log.debug("#{@host} => :unbind") @master.unbind_backend(@host) end |