Class: EventMachine::WinRM::Server

Inherits:
Object
  • Object
show all
Includes:
EM::Deferrable
Defined in:
lib/em-winrm/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master, host, options) ⇒ Server

Returns a new instance of Server.



28
29
30
31
32
33
34
35
36
37
# File 'lib/em-winrm/server.rb', line 28

def initialize(master, host, options)
  @master = master
  @host = host
  @transport = options[:transport] || :plaintext
  @options = options
  @options[:user] = @options.delete(:user) || ENV['USER'] || ENV['USERNAME'] || "unknown"
  @options[:pass] = @options.delete(:password)
  @options[:port] = @options.delete(:port) || 5985
  @options[:basic_auth_only] = true unless defined? @options[:basic_auth_only]
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



26
27
28
# File 'lib/em-winrm/server.rb', line 26

def host
  @host
end

#masterObject

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



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/em-winrm/server.rb', line 42

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

#unbindObject

Notify upstream master that the backend server is done processing the request



68
69
70
71
# File 'lib/em-winrm/server.rb', line 68

def unbind
  WinRM::Log.debug("#{@host} => :unbind")
  @master.unbind_backend(@host)
end