Module: WinRM::WSMV::Header
- Included in:
- Base, ReceiveResponseReader
- Defined in:
- lib/winrm/wsmv/header.rb
Overview
SOAP header utility mixin
Constant Summary collapse
- RESOURCE_URI_CMD =
WSMan URI of the regular Windows cmd shell
'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd'.freeze
- RESOURCE_URI_POWERSHELL =
WSMan URI for PowerShell
'http://schemas.microsoft.com/powershell/Microsoft.PowerShell'.freeze
Instance Method Summary collapse
- #action_command ⇒ Object
- #action_delete ⇒ Object
- #action_enumerate ⇒ Object
- #action_enumerate_pull ⇒ Object
- #action_get ⇒ Object
- #action_receive ⇒ Object
- #action_send ⇒ Object
- #action_signal ⇒ Object
-
#merge_headers(*headers) ⇒ Object
Merge the various header hashes and make sure we carry all of the attributes through instead of overwriting them.
- #resource_uri_cmd ⇒ Object
-
#resource_uri_shell(shell_uri) ⇒ Object
Helper methods for SOAP Headers.
- #resource_uri_wmi(namespace = 'root/cimv2/*') ⇒ Object
- #selector_shell_id(shell_id) ⇒ Object
- #shared_headers(session_opts) ⇒ Object
Instance Method Details
#action_command ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/winrm/wsmv/header.rb', line 126 def action_command { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_delete ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/winrm/wsmv/header.rb', line 114 def action_delete { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_enumerate ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/winrm/wsmv/header.rb', line 174 def action_enumerate { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_enumerate_pull ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/winrm/wsmv/header.rb', line 186 def action_enumerate_pull { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_get ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/winrm/wsmv/header.rb', line 102 def action_get { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_receive ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/winrm/wsmv/header.rb', line 138 def action_receive { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_send ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/winrm/wsmv/header.rb', line 150 def action_send { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Send', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#action_signal ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/winrm/wsmv/header.rb', line 162 def action_signal { "#{SOAP::NS_ADDRESSING}:Action" => 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Signal', :attributes! => { "#{SOAP::NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end |
#merge_headers(*headers) ⇒ Object
Merge the various header hashes and make sure we carry all of the attributes through instead of overwriting them.
32 33 34 35 36 37 38 39 40 |
# File 'lib/winrm/wsmv/header.rb', line 32 def merge_headers(*headers) hdr = {} headers.each do |h| hdr.merge!(h) do |k, v1, v2| v1.merge!(v2) if k == :attributes! end end hdr end |
#resource_uri_cmd ⇒ Object
86 87 88 |
# File 'lib/winrm/wsmv/header.rb', line 86 def resource_uri_cmd resource_uri_shell(RESOURCE_URI_CMD) end |
#resource_uri_shell(shell_uri) ⇒ Object
Helper methods for SOAP Headers
76 77 78 79 80 81 82 83 84 |
# File 'lib/winrm/wsmv/header.rb', line 76 def resource_uri_shell(shell_uri) { "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => shell_uri, :attributes! => { "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => { 'mustUnderstand' => true } } } end |
#resource_uri_wmi(namespace = 'root/cimv2/*') ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/winrm/wsmv/header.rb', line 90 def resource_uri_wmi(namespace = 'root/cimv2/*') { "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => "http://schemas.microsoft.com/wbem/wsman/1/wmi/#{namespace}", :attributes! => { "#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => { 'mustUnderstand' => true } } } end |
#selector_shell_id(shell_id) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/winrm/wsmv/header.rb', line 198 def selector_shell_id(shell_id) { "#{SOAP::NS_WSMAN_DMTF}:SelectorSet" => { "#{SOAP::NS_WSMAN_DMTF}:Selector" => shell_id, :attributes! => { "#{SOAP::NS_WSMAN_DMTF}:Selector" => { 'Name' => 'ShellId' } } } } end |
#shared_headers(session_opts) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/winrm/wsmv/header.rb', line 42 def shared_headers(session_opts) { "#{SOAP::NS_ADDRESSING}:To" => session_opts[:endpoint], "#{SOAP::NS_ADDRESSING}:ReplyTo" => { "#{SOAP::NS_ADDRESSING}:Address" => 'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous', :attributes! => { "#{SOAP::NS_ADDRESSING}:Address" => { 'mustUnderstand' => true } } }, "#{SOAP::NS_WSMAN_DMTF}:MaxEnvelopeSize" => session_opts[:max_envelope_size], "#{SOAP::NS_ADDRESSING}:MessageID" => "uuid:#{SecureRandom.uuid.to_s.upcase}", "#{SOAP::NS_WSMAN_MSFT}:SessionId" => "uuid:#{session_opts[:session_id]}", "#{SOAP::NS_WSMAN_DMTF}:Locale/" => '', "#{SOAP::NS_WSMAN_MSFT}:DataLocale/" => '', "#{SOAP::NS_WSMAN_DMTF}:OperationTimeout" => Iso8601Duration.sec_to_dur(session_opts[:operation_timeout]), :attributes! => { "#{SOAP::NS_WSMAN_DMTF}:MaxEnvelopeSize" => { 'mustUnderstand' => true }, "#{SOAP::NS_WSMAN_DMTF}:Locale/" => { 'xml:lang' => session_opts[:locale], 'mustUnderstand' => false }, "#{SOAP::NS_WSMAN_MSFT}:DataLocale/" => { 'xml:lang' => session_opts[:locale], 'mustUnderstand' => false }, "#{SOAP::NS_WSMAN_MSFT}:SessionId" => { 'mustUnderstand' => false } } } end |