winrm-s 0.3.0.dev.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d4d1d4e2a4b4ccc8dd0ad20d284645601ea0e12
4
- data.tar.gz: cb836c96410f6b98edfba92bad359344abeb13b4
3
+ metadata.gz: 0fe95dd37da3da6c1086e54af81ee41a014eee5e
4
+ data.tar.gz: cb34e1952b1e46cb7ed05f06f1a48243792dd295
5
5
  SHA512:
6
- metadata.gz: c94f858518f0cf2b1fb417cf1eb233a188758c37fb7866847860ad0af4d88892e130a8059c1207508319c05728ffd3b03b45f0e015e0611ca27a4aad9f5f0589
7
- data.tar.gz: f7cf4738f2826fb4c9bfed5dfeb94c7c5187da4d7dd7ce0a877d07f4efbe77c5cc82cbb5b1f639db42e6b6f05d568d5bef788edd7db2b77933602bb6c306d26d
6
+ metadata.gz: b2cdbb900ec5b64f22972ccac8d95da645a9018854a2ab239f582e63192298f96705421d92d2b90af2a79242fe20bec05688d900cad067c64bd40df67955d774
7
+ data.tar.gz: 38e93c9eb50579c9fb57dfdce072bf7064f5f226985fd733bd5a288ff612be7f77ed5ff1129143ca84db809a08cd55a3997f7d252bfb84d0a465f5ebdb0df6ab
@@ -1,10 +1,15 @@
1
1
  # winrm-s Change Log
2
2
 
3
- ## Unreleased
4
- None
3
+ Unreleased
4
+ --------------
5
+
6
+ Release: 0.3.0
7
+ --------------
8
+ * [Issue #21](https://github.com/chef/winrm-s/issues/21): Bumps winrm dependency from 1.2 to 1.3.
9
+ * [Issue #25](https://github.com/opscode/winrm-s/pull/25): [Fix for knife-windows issue 218](https://github.com/opscode/knife-windows/issues/218)
5
10
 
6
- Last release: 0.2.4
7
- -------------------
11
+ Release: 0.2.4
12
+ --------------
8
13
  * DOC change only: correct omission from CHANGELOG items in 0.2.3 release
9
14
 
10
15
  Release: 0.2.3
@@ -24,6 +29,3 @@ Release: 0.2.0
24
29
  Release: 0.1.0
25
30
  --------------
26
31
  * Initial implementation
27
-
28
-
29
-
@@ -17,6 +17,6 @@
17
17
  #
18
18
 
19
19
  module WinrmS
20
- VERSION = "0.3.0.dev.0"
20
+ VERSION = "0.3.0"
21
21
  MAJOR, MINOR, TINY = VERSION.split('.')
22
22
  end
@@ -30,5 +30,60 @@ module WinRM
30
30
  @xfer = HTTP::HttpSSL.new(endpoint, opts[:user], opts[:pass], opts[:ca_trust_path], opts)
31
31
  end
32
32
  end
33
+
34
+ # Get the builder obj for output request
35
+ # @param [String] shell_id The shell id on the remote machine. See #open_shell
36
+ # @param [String] command_id The command id on the remote machine. See #run_command
37
+ # @return [Builder::XmlMarkup] Returns a Builder::XmlMarkup for request message
38
+ def get_builder_obj(shell_id, command_id, &block)
39
+ body = { "#{NS_WIN_SHELL}:DesiredStream" => 'stdout stderr',
40
+ :attributes! => {"#{NS_WIN_SHELL}:DesiredStream" => {'CommandId' => command_id}}}
41
+ builder = Builder::XmlMarkup.new
42
+ builder.instruct!(:xml, :encoding => 'UTF-8')
43
+ builder.tag! :env, :Envelope, namespaces do |env|
44
+ env.tag!(:env, :Header) { |h| h << Gyoku.xml(merge_headers(header,resource_uri_cmd,action_receive,selector_shell_id(shell_id))) }
45
+ env.tag!(:env, :Body) do |env_body|
46
+ env_body.tag!("#{NS_WIN_SHELL}:Receive") { |cl| cl << Gyoku.xml(body) }
47
+ end
48
+ end
49
+ builder
50
+ end
51
+
52
+ # Get the Output of the given shell and command
53
+ # @param [String] shell_id The shell id on the remote machine. See #open_shell
54
+ # @param [String] command_id The command id on the remote machine. See #run_command
55
+ # @return [Hash] Returns a Hash with a key :exitcode and :data. Data is an Array of Hashes where the cooresponding key
56
+ # is either :stdout or :stderr. The reason it is in an Array so so we can get the output in the order it ocurrs on
57
+ # the console.
58
+ def get_command_output(shell_id, command_id, &block)
59
+ done_elems = []
60
+ while done_elems.empty?
61
+ resp_doc = nil
62
+ builder = get_builder_obj(shell_id, command_id, &block)
63
+ request_msg = builder.target!
64
+ resp_doc = send_get_output_message(request_msg)
65
+
66
+ output = Output.new
67
+ REXML::XPath.match(resp_doc, "//#{NS_WIN_SHELL}:Stream").each do |n|
68
+ next if n.text.nil? || n.text.empty?
69
+ stream = { n.attributes['Name'].to_sym => Base64.decode64(n.text) }
70
+ output[:data] << stream
71
+ yield stream[:stdout], stream[:stderr] if block_given?
72
+ end
73
+
74
+ # We may need to get additional output if the stream has not finished.
75
+ # The CommandState will change from Running to Done like so:
76
+ # @example
77
+ # from...
78
+ # <rsp:CommandState CommandId="..." State="http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Running"/>
79
+ # to...
80
+ # <rsp:CommandState CommandId="..." State="http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done">
81
+ # <rsp:ExitCode>0</rsp:ExitCode>
82
+ # </rsp:CommandState>
83
+ done_elems = REXML::XPath.match(resp_doc, "//*[@State='http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done']")
84
+ end
85
+ output[:exitcode] = REXML::XPath.first(resp_doc, "//#{NS_WIN_SHELL}:ExitCode").text.to_i
86
+ output
87
+ end
33
88
  end
34
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winrm-s
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.dev.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaustubh Deorukhkar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-03 00:00:00.000000000 Z
11
+ date: 2015-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: winrm
@@ -126,9 +126,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>'
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
- version: 1.3.1
131
+ version: '0'
132
132
  requirements: []
133
133
  rubyforge_project:
134
134
  rubygems_version: 2.0.14