Class: WINRM

Inherits:
Object
  • Object
show all
Defined in:
lib/winrm_connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, opts) ⇒ WINRM

Returns a new instance of WINRM.



8
9
10
11
12
# File 'lib/winrm_connection.rb', line 8

def initialize(server, opts)
  @server = server
  @int_hash = {:options => opts, :server => server}
  @winrm = establish_winrm(opts)
end

Instance Attribute Details

#serverObject (readonly) Also known as: xserver

Returns the value of attribute server.



5
6
7
# File 'lib/winrm_connection.rb', line 5

def server
  @server
end

Instance Method Details

#[](key) ⇒ Object



14
15
16
# File 'lib/winrm_connection.rb', line 14

def [](key)
  @int_hash[key.to_sym]
end

#[]=(key, value) ⇒ Object



18
19
20
# File 'lib/winrm_connection.rb', line 18

def []=(key, value)
  @int_hash[key.to_sym] = value
end

#exec(cmd) ⇒ Object



26
27
28
# File 'lib/winrm_connection.rb', line 26

def exec(cmd)
  @ios = @winrm.cmd(cmd)
end

#on_closeObject



42
# File 'lib/winrm_connection.rb', line 42

def on_close; self; end

#on_dataObject



39
# File 'lib/winrm_connection.rb', line 39

def on_data; self; end

#on_extended_dataObject



40
# File 'lib/winrm_connection.rb', line 40

def on_extended_data; self; end

#on_request(req_type) ⇒ Object



41
# File 'lib/winrm_connection.rb', line 41

def on_request(req_type); self; end

#open_channel {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (WINRM)

    the object that the method was called on



22
23
24
# File 'lib/winrm_connection.rb', line 22

def open_channel
  yield self
end

#process_dataObject



30
31
32
33
34
35
36
37
# File 'lib/winrm_connection.rb', line 30

def process_data
  @ios[:data].each do |ds|
    key = ds.keys.first
    stream = (key == :stdout) ? :out : :err
    yield self, stream, ds[key]
  end
  self[:status] = @ios[:exitcode]
end