winrm 1.0.0rc3 → 1.0.0rc4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -63,10 +63,14 @@ end
63
63
 
64
64
  CONNECTION TYPES:
65
65
 
66
- BASIC:
66
+ PLAINTEXT:
67
67
  WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass)
68
- BASIC + SSL:
68
+ # Same but force basic authentication
69
+ WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass, :basic_auth_only => true)
70
+ SSL:
69
71
  WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass)
72
+ # Same but force basic authentication
73
+ WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true)
70
74
  KERBEROS:
71
75
  WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => 'MYREALM.COM')
72
76
 
@@ -80,3 +84,7 @@ http://github.com/zenchild/WinRM/issues
80
84
 
81
85
  Cheers!
82
86
  --------------------------------------------------------------------------
87
+
88
+
89
+ Thurs : #9 5:30-6:30
90
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0rc3
1
+ 1.0.0rc4
@@ -39,18 +39,20 @@ module WinRM
39
39
  end
40
40
 
41
41
  class HttpPlaintext < HttpTransport
42
- def initialize(endpoint, user, pass)
42
+ def initialize(endpoint, user, pass, opts)
43
43
  super(endpoint)
44
44
  @httpcli.set_auth(nil, user, pass)
45
+ basic_auth_only! if opts[:basic_auth_only]
45
46
  end
46
47
  end
47
48
 
48
49
  # Uses SSL to secure the transport
49
50
  class HttpSSL < HttpTransport
50
- def initialize(endpoint, user, pass, ca_trust_path = nil)
51
+ def initialize(endpoint, user, pass, ca_trust_path = nil, opts)
51
52
  super(endpoint)
52
53
  @httpcli.set_auth(endpoint, user, pass)
53
54
  @httpcli.ssl_config.set_trust_ca(ca_trust_path) unless ca_trust_path.nil?
55
+ basic_auth_only! if opts[:basic_auth_only]
54
56
  end
55
57
  end
56
58
 
@@ -60,7 +62,7 @@ module WinRM
60
62
  # @param [String] realm the Kerberos realm we are authenticating to
61
63
  # @param [String<optional>] service the service name, default is HTTP
62
64
  # @param [String<optional>] keytab the path to a keytab file if you are using one
63
- def initialize(endpoint, realm, service = nil, keytab = nil)
65
+ def initialize(endpoint, realm, service = nil, keytab = nil, opts)
64
66
  super(endpoint)
65
67
  service ||= 'HTTP'
66
68
  @service = "#{service}/#{@endpoint.host}@#{realm}"
@@ -23,11 +23,11 @@ module WinRM
23
23
  case transport
24
24
  when :kerberos
25
25
  # TODO: check fo keys and throw error if missing
26
- @xfer = HTTP::HttpGSSAPI.new(endpoint, opts[:realm], opts[:service], opts[:keytab])
26
+ @xfer = HTTP::HttpGSSAPI.new(endpoint, opts[:realm], opts[:service], opts[:keytab], opts)
27
27
  when :plaintext
28
- @xfer = HTTP::HttpPlaintext.new(endpoint, opts[:user], opts[:pass])
28
+ @xfer = HTTP::HttpPlaintext.new(endpoint, opts[:user], opts[:pass], opts)
29
29
  when :ssl
30
- @xfer = HTTP::HttpSSL.new(endpoint, opts[:user], opts[:pass], opts[:ca_trust_path])
30
+ @xfer = HTTP::HttpSSL.new(endpoint, opts[:user], opts[:pass], opts[:ca_trust_path], opts)
31
31
  end
32
32
  end
33
33
 
@@ -68,8 +68,9 @@ module WinRM
68
68
  # Run a command on a machine with an open shell
69
69
  # @param [String] shell_id The shell id on the remote machine. See #open_shell
70
70
  # @param [String] command The command to run on the remote machine
71
+ # @param [Array<String>] arguments An array of arguments for this command
71
72
  # @return [String] The CommandId from the SOAP response. This is the ID we need to query in order to get output.
72
- def run_command(shell_id, command)
73
+ def run_command(shell_id, command, arguments = [])
73
74
  s = Savon::SOAP::XML.new
74
75
  s.version = 2
75
76
  s.namespaces.merge!(namespaces)
@@ -79,7 +80,7 @@ module WinRM
79
80
  }
80
81
  s.header.merge!(merge_headers(header,resource_uri_cmd,action_command,h_opts,selector_shell_id(shell_id)))
81
82
  s.input = "#{NS_WIN_SHELL}:CommandLine"
82
- s.body = { "#{NS_WIN_SHELL}:Command" => "\"#{command}\"" }
83
+ s.body = { "#{NS_WIN_SHELL}:Command" => "\"#{command}\"", "#{NS_WIN_SHELL}:Arguments" => arguments}
83
84
 
84
85
  resp = send_message(s.to_xml)
85
86
  (resp/"//#{NS_WIN_SHELL}:CommandId").text
@@ -183,10 +184,11 @@ module WinRM
183
184
 
184
185
  # Run a CMD command
185
186
  # @param [String] command The command to run on the remote system
187
+ # @param [Array <String>] arguments arguments to the command
186
188
  # @return [Hash] :stdout and :stderr
187
- def run_cmd(command, &block)
189
+ def run_cmd(command, arguments = [], &block)
188
190
  shell_id = open_shell
189
- command_id = run_command(shell_id, command)
191
+ command_id = run_command(shell_id, command, arguments)
190
192
  command_output = get_command_output(shell_id, command_id, &block)
191
193
  cleanup_command(shell_id, command_id)
192
194
  close_shell(shell_id)
@@ -222,36 +224,34 @@ module WinRM
222
224
  # Run a WQL Query
223
225
  # @see http://msdn.microsoft.com/en-us/library/aa394606(VS.85).aspx
224
226
  # @param [String] wql The WQL query
225
- # @return [Array<Hash>] Returns an array of Hashes that contain the key/value pairs returned from the query.
227
+ # @return [Hash] Returns a Hash that contain the key/value pairs returned from the query.
226
228
  def run_wql(wql)
227
- header = {}.merge(resource_uri_wmi).merge(action_enumerate)
228
-
229
- begin
230
- resp = invoke("#{NS_ENUM}:Enumerate", {:soap_action => :auto, :http_options => nil, :soap_header => header}) do |enum|
231
- enum.add("#{NS_WSMAN_DMTF}:OptimizeEnumeration")
232
- enum.add("#{NS_WSMAN_DMTF}:MaxElements",'32000')
233
- mattr = nil
234
- enum.add("#{NS_WSMAN_DMTF}:Filter", wql) do |filt|
235
- filt.set_attr('Dialect','http://schemas.microsoft.com/wbem/wsman/1/WQL')
236
- end
237
- end
238
- rescue Handsoap::Fault => e
239
- raise WinRMWebServiceError, e.reason
240
- end
229
+ s = Savon::SOAP::XML.new
230
+ s.version = 2
231
+ s.namespaces.merge!(namespaces)
232
+ s.header.merge!(merge_headers(header,resource_uri_wmi,action_enumerate))
233
+ s.input = "#{NS_ENUM}:Enumerate"
234
+ s.body = { "#{NS_WSMAN_DMTF}:OptimizeEnumeration" => nil,
235
+ "#{NS_WSMAN_DMTF}:MaxElements" => '32000',
236
+ "#{NS_WSMAN_DMTF}:Filter" => wql,
237
+ :attributes! => { "#{NS_WSMAN_DMTF}:Filter" => {'Dialect' => 'http://schemas.microsoft.com/wbem/wsman/1/WQL'}}
238
+ }
241
239
 
242
- query_response = []
243
- (resp/"//#{NS_ENUM}:EnumerateResponse//#{NS_WSMAN_DMTF}:Items/*").each do |i|
244
- qitem = {}
245
- (i/'*').each do |si|
246
- qitem[si.node_name] = si.to_s
240
+ resp = send_message(s.to_xml)
241
+ hresp = Savon::SOAP::XML.to_hash resp.to_xml
242
+ # Normalize items so the type always has an array even if it's just a single item.
243
+ items = {}
244
+ hresp[:enumerate_response][:items].each_pair do |k,v|
245
+ if v.is_a?(Array)
246
+ items[k] = v
247
+ else
248
+ items[k] = [v]
247
249
  end
248
- query_response << qitem
249
250
  end
250
- query_response
251
+ items
251
252
  end
252
253
 
253
254
 
254
-
255
255
  private
256
256
 
257
257
  def namespaces
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: winrm
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 5
5
- version: 1.0.0rc3
5
+ version: 1.0.0rc4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dan Wanek
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-18 00:00:00 -05:00
13
+ date: 2011-03-30 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency