vagrant-unbundled 2.1.4.0 → 2.2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +58 -1
  3. data/Gemfile.lock +9 -5
  4. data/contrib/bash/completion.sh +16 -2
  5. data/contrib/sudoers/osx +1 -1
  6. data/lib/vagrant/environment.rb +16 -21
  7. data/lib/vagrant/errors.rb +28 -0
  8. data/lib/vagrant/machine.rb +1 -1
  9. data/lib/vagrant/plugin/manager.rb +35 -1
  10. data/lib/vagrant/plugin/v2/trigger.rb +23 -0
  11. data/lib/vagrant/util/curl_helper.rb +96 -0
  12. data/lib/vagrant/util/downloader.rb +2 -79
  13. data/lib/vagrant/util/guest_inspection.rb +18 -5
  14. data/lib/vagrant/util/platform.rb +33 -8
  15. data/lib/vagrant/util/uploader.rb +103 -0
  16. data/lib/vagrant/vagrantfile.rb +5 -1
  17. data/lib/vagrant.rb +39 -13
  18. data/plugins/commands/cloud/auth/login.rb +90 -0
  19. data/plugins/commands/cloud/auth/logout.rb +42 -0
  20. data/plugins/commands/cloud/auth/plugin.rb +20 -0
  21. data/plugins/commands/cloud/auth/root.rb +73 -0
  22. data/plugins/commands/cloud/auth/whoami.rb +62 -0
  23. data/plugins/commands/cloud/box/create.rb +75 -0
  24. data/plugins/commands/cloud/box/delete.rb +65 -0
  25. data/plugins/commands/cloud/box/plugin.rb +19 -0
  26. data/plugins/commands/cloud/box/root.rb +77 -0
  27. data/plugins/commands/cloud/box/show.rb +74 -0
  28. data/plugins/commands/cloud/box/update.rb +71 -0
  29. data/plugins/commands/cloud/client/client.rb +264 -0
  30. data/plugins/commands/cloud/errors.rb +28 -0
  31. data/plugins/commands/cloud/list.rb +52 -0
  32. data/plugins/commands/cloud/locales/en.yml +159 -0
  33. data/plugins/commands/cloud/plugin.rb +30 -0
  34. data/plugins/commands/cloud/provider/create.rb +73 -0
  35. data/plugins/commands/cloud/provider/delete.rb +70 -0
  36. data/plugins/commands/cloud/provider/plugin.rb +19 -0
  37. data/plugins/commands/cloud/provider/root.rb +77 -0
  38. data/plugins/commands/cloud/provider/update.rb +73 -0
  39. data/plugins/commands/cloud/provider/upload.rb +75 -0
  40. data/plugins/commands/cloud/publish.rb +165 -0
  41. data/plugins/commands/cloud/root.rb +104 -0
  42. data/plugins/commands/cloud/search.rb +83 -0
  43. data/plugins/commands/cloud/util.rb +206 -0
  44. data/plugins/commands/cloud/version/create.rb +69 -0
  45. data/plugins/commands/cloud/version/delete.rb +68 -0
  46. data/plugins/commands/cloud/version/plugin.rb +19 -0
  47. data/plugins/commands/cloud/version/release.rb +69 -0
  48. data/plugins/commands/cloud/version/revoke.rb +69 -0
  49. data/plugins/commands/cloud/version/root.rb +81 -0
  50. data/plugins/commands/cloud/version/update.rb +69 -0
  51. data/plugins/commands/init/command.rb +1 -1
  52. data/plugins/commands/login/plugin.rb +4 -3
  53. data/plugins/commands/powershell/command.rb +3 -0
  54. data/plugins/commands/powershell/plugin.rb +1 -0
  55. data/plugins/commands/upload/command.rb +236 -0
  56. data/plugins/commands/upload/plugin.rb +17 -0
  57. data/plugins/commands/winrm/command.rb +69 -0
  58. data/plugins/commands/winrm/plugin.rb +17 -0
  59. data/plugins/commands/winrm_config/command.rb +125 -0
  60. data/plugins/commands/winrm_config/plugin.rb +17 -0
  61. data/plugins/guests/bsd/cap/file_system.rb +77 -0
  62. data/plugins/guests/bsd/plugin.rb +15 -0
  63. data/plugins/guests/linux/cap/file_system.rb +79 -0
  64. data/plugins/guests/linux/cap/network_interfaces.rb +13 -2
  65. data/plugins/guests/linux/plugin.rb +15 -0
  66. data/plugins/guests/redhat/cap/change_host_name.rb +21 -13
  67. data/plugins/guests/solaris/cap/file_system.rb +77 -0
  68. data/plugins/guests/solaris/plugin.rb +15 -0
  69. data/plugins/guests/windows/cap/file_system.rb +65 -0
  70. data/plugins/guests/windows/cap/mount_shared_folder.rb +1 -1
  71. data/plugins/guests/windows/plugin.rb +10 -0
  72. data/plugins/kernel_v2/config/vm.rb +3 -0
  73. data/plugins/kernel_v2/config/vm_trigger.rb +49 -1
  74. data/plugins/providers/docker/action/build.rb +23 -8
  75. data/plugins/providers/docker/action/is_build.rb +1 -1
  76. data/plugins/providers/docker/config.rb +50 -10
  77. data/plugins/providers/hyperv/scripts/configure_vm.ps1 +16 -2
  78. data/plugins/providers/virtualbox/action/match_mac_address.rb +8 -5
  79. data/plugins/providers/virtualbox/driver/version_5_0.rb +1 -0
  80. data/plugins/provisioners/ansible/provisioner/guest.rb +2 -8
  81. data/plugins/provisioners/puppet/provisioner/puppet.rb +4 -2
  82. data/plugins/provisioners/salt/bootstrap-salt.sh +1 -1
  83. data/plugins/provisioners/salt/provisioner.rb +19 -4
  84. data/plugins/synced_folders/rsync/helper.rb +2 -1
  85. data/templates/commands/ssh_config/config.erb +1 -1
  86. data/templates/commands/winrm_config/config.erb +11 -0
  87. data/templates/guests/openbsd/network_static6.erb +1 -0
  88. data/templates/locales/en.yml +60 -1
  89. data/templates/locales/providers_docker.yml +11 -3
  90. data/vagrant.gemspec +3 -1
  91. data/vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-spec-94a9d31ba18b/vagrant-spec.gemspec +1 -1
  92. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/LICENSE +22 -0
  93. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/README.md +67 -0
  94. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/bin/vagrant_cloud +5 -0
  95. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/account.rb +190 -0
  96. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/box.rb +185 -0
  97. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/client.rb +73 -0
  98. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/errors.rb +25 -0
  99. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/provider.rb +149 -0
  100. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/search.rb +31 -0
  101. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/version.rb +188 -0
  102. data/vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud.rb +11 -0
  103. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/.gitignore +10 -0
  104. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/.rubocop.yml +38 -0
  105. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/.travis.yml +10 -0
  106. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/Gemfile +2 -0
  107. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/LICENSE +202 -0
  108. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/README.md +276 -0
  109. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/Rakefile +33 -0
  110. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/Vagrantfile +6 -0
  111. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/WinrmAppveyor.psm1 +32 -0
  112. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/appveyor.yml +50 -0
  113. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/bin/rwinrm +90 -0
  114. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/changelog.md +133 -0
  115. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/connection.rb +84 -0
  116. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/connection_opts.rb +90 -0
  117. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/exceptions.rb +88 -0
  118. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/http/response_handler.rb +127 -0
  119. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/http/transport.rb +462 -0
  120. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/http/transport_factory.rb +64 -0
  121. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/output.rb +58 -0
  122. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/create_pipeline.xml.erb +167 -0
  123. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/fragment.rb +68 -0
  124. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/init_runspace_pool.xml.erb +224 -0
  125. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message.rb +128 -0
  126. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_data/base.rb +47 -0
  127. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_data/error_record.rb +66 -0
  128. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_data/pipeline_host_call.rb +30 -0
  129. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_data/pipeline_output.rb +48 -0
  130. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_data/pipeline_state.rb +38 -0
  131. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_data/runspacepool_host_call.rb +30 -0
  132. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_data/runspacepool_state.rb +37 -0
  133. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_data/session_capability.rb +34 -0
  134. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_data.rb +40 -0
  135. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_defragmenter.rb +62 -0
  136. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_factory.rb +74 -0
  137. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/message_fragmenter.rb +58 -0
  138. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/powershell_output_decoder.rb +142 -0
  139. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/receive_response_reader.rb +95 -0
  140. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/session_capability.xml.erb +7 -0
  141. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/psrp/uuid.rb +39 -0
  142. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/shells/base.rb +187 -0
  143. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/shells/cmd.rb +63 -0
  144. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/shells/power_shell.rb +207 -0
  145. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/shells/retryable.rb +44 -0
  146. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/shells/shell_factory.rb +56 -0
  147. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/version.rb +5 -0
  148. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/base.rb +57 -0
  149. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/cleanup_command.rb +60 -0
  150. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/close_shell.rb +49 -0
  151. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/command.rb +100 -0
  152. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/command_output.rb +75 -0
  153. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/command_output_decoder.rb +54 -0
  154. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/configuration.rb +44 -0
  155. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/create_pipeline.rb +64 -0
  156. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/create_shell.rb +115 -0
  157. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/header.rb +213 -0
  158. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/init_runspace_pool.rb +96 -0
  159. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/iso8601_duration.rb +58 -0
  160. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/keep_alive.rb +66 -0
  161. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/receive_response_reader.rb +128 -0
  162. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/send_data.rb +66 -0
  163. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/soap.rb +49 -0
  164. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/wql_pull.rb +54 -0
  165. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/wql_query.rb +98 -0
  166. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm/wsmv/write_stdin.rb +86 -0
  167. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/lib/winrm.rb +37 -0
  168. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/preamble +17 -0
  169. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/integration/auth_timeout_spec.rb +17 -0
  170. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/integration/cmd_spec.rb +130 -0
  171. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/integration/config-example.yml +16 -0
  172. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/integration/issue_59_spec.rb +25 -0
  173. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/integration/powershell_spec.rb +164 -0
  174. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/integration/spec_helper.rb +62 -0
  175. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/integration/transport_spec.rb +98 -0
  176. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/integration/wql_spec.rb +33 -0
  177. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/matchers.rb +59 -0
  178. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/configuration_spec.rb +183 -0
  179. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/connection_spec.rb +37 -0
  180. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/exception_spec.rb +49 -0
  181. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/http/transport_factory_spec.rb +66 -0
  182. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/http/transport_spec.rb +43 -0
  183. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/output_spec.rb +128 -0
  184. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/fragment_spec.rb +60 -0
  185. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_data/base_spec.rb +11 -0
  186. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_data/error_record_spec.rb +39 -0
  187. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_data/pipeline_host_call_spec.rb +23 -0
  188. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_data/pipeline_output_spec.rb +30 -0
  189. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_data/pipeline_state_spec.rb +38 -0
  190. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_data/runspace_pool_host_call_spec.rb +23 -0
  191. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_data/runspacepool_state_spec.rb +14 -0
  192. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_data/session_capability_spec.rb +28 -0
  193. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_data_spec.rb +33 -0
  194. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_defragmenter_spec.rb +45 -0
  195. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/message_fragmenter_spec.rb +103 -0
  196. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/powershell_output_decoder_spec.rb +98 -0
  197. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/psrp_message_spec.rb +73 -0
  198. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/recieve_response_reader_spec.rb +170 -0
  199. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/psrp/uuid_spec.rb +28 -0
  200. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/response_handler_spec.rb +69 -0
  201. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/shells/base_spec.rb +227 -0
  202. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/shells/cmd_spec.rb +75 -0
  203. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/shells/powershell_spec.rb +221 -0
  204. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/spec_helper.rb +46 -0
  205. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/clixml/error_record.xml.erb +84 -0
  206. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/clixml/pipeline_state.xml.erb +88 -0
  207. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/get_command_output_response.xml.erb +13 -0
  208. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/get_command_output_response_not_done.xml.erb +10 -0
  209. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/get_omi_command_output_response.xml.erb +23 -0
  210. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/get_omi_command_output_response_not_done.xml.erb +24 -0
  211. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/get_omi_config_response.xml +45 -0
  212. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/get_omi_powershell_keepalive_response.xml.erb +33 -0
  213. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/get_powershell_keepalive_response.xml.erb +10 -0
  214. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/get_powershell_output_response.xml.erb +12 -0
  215. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/get_powershell_output_response_not_done.xml.erb +9 -0
  216. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/open_shell_omi.xml +43 -0
  217. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/open_shell_v1.xml +19 -0
  218. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/open_shell_v2.xml +20 -0
  219. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/soap_fault_omi.xml +31 -0
  220. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/soap_fault_v1.xml +36 -0
  221. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/soap_fault_v2.xml +42 -0
  222. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/stubs/responses/wmi_error_v2.xml +41 -0
  223. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/cleanup_command_spec.rb +20 -0
  224. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/close_shell_spec.rb +15 -0
  225. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/command_output_decoder_spec.rb +35 -0
  226. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/command_output_spec.rb +43 -0
  227. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/command_spec.rb +17 -0
  228. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/configuration_spec.rb +15 -0
  229. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/create_pipeline_spec.rb +30 -0
  230. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/create_shell_spec.rb +39 -0
  231. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/init_runspace_pool_spec.rb +38 -0
  232. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/keep_alive_spec.rb +21 -0
  233. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/receive_response_reader_spec.rb +124 -0
  234. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/send_data_spec.rb +30 -0
  235. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/wql_query_spec.rb +11 -0
  236. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/tests/spec/wsmv/write_stdin_spec.rb +20 -0
  237. data/vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/winrm.gemspec +46 -0
  238. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/.gitignore +11 -0
  239. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/.rspec +2 -0
  240. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/.rubocop.yml +17 -0
  241. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/.rubocop_todo.yml +65 -0
  242. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/.travis.yml +10 -0
  243. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/Gemfile +4 -0
  244. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/LICENSE +202 -0
  245. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/README.md +82 -0
  246. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/Rakefile +27 -0
  247. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/VERSION +1 -0
  248. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/Vagrantfile +8 -0
  249. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/appveyor.yml +38 -0
  250. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/bin/rwinrmcp +85 -0
  251. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/changelog.md +74 -0
  252. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/core/file_transporter.rb +566 -0
  253. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/core/tmp_zip.rb +176 -0
  254. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/exceptions.rb +27 -0
  255. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/file_manager.rb +156 -0
  256. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/scripts/check_files.ps1.erb +49 -0
  257. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/scripts/checksum.ps1.erb +13 -0
  258. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/scripts/create_dir.ps1.erb +6 -0
  259. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/scripts/delete.ps1.erb +6 -0
  260. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/scripts/download.ps1.erb +17 -0
  261. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/scripts/exists.ps1.erb +10 -0
  262. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/scripts/extract_files.ps1.erb +52 -0
  263. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs/scripts/scripts.rb +31 -0
  264. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/lib/winrm-fs.rb +27 -0
  265. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/config-example.yml +3 -0
  266. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/integration/file_manager_spec.rb +303 -0
  267. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/integration/tmp_zip_spec.rb +26 -0
  268. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/matchers.rb +57 -0
  269. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/spec_helper.rb +66 -0
  270. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/unit/tmp_zip_spec.rb +78 -0
  271. data/vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/winrm-fs.gemspec +36 -0
  272. data/vendor/bundle/ruby/2.5.0/specifications/vagrant_cloud-2.0.1.gemspec +45 -0
  273. data/vendor/bundle/ruby/2.5.0/specifications/winrm-2.3.0.gemspec +73 -0
  274. data/vendor/bundle/ruby/2.5.0/specifications/winrm-fs-1.3.1.gemspec +57 -0
  275. data/version.txt +1 -1
  276. metadata +268 -4
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2014 Shawn Neal <sneal@sneal.net>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # rubocop:disable all
18
+
19
+ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
20
+
21
+ require 'readline'
22
+ require 'io/console'
23
+ require 'winrm'
24
+
25
+ def help_msg
26
+ puts 'Usage: rwinrm user@host'
27
+ puts ''
28
+ end
29
+
30
+ def parse_options
31
+ options = {}
32
+ fail 'Missing required options' unless ARGV.length == 1
33
+
34
+ m = /^(?<user>[a-z0-9\.\!\$ _-]+)@{1}(?<host>[a-z0-9\.\-]+)(?<port>:[0-9]+)?/i.match(ARGV[0])
35
+ fail "#{ARGV[0]} is an invalid host" unless m
36
+ options[:user] = m[:user]
37
+ options[:endpoint] = "http://#{m[:host]}#{m[:port] || ':5985'}/wsman"
38
+
39
+ # Get the password
40
+ print 'Password: '
41
+ options[:password] = STDIN.noecho(&:gets).chomp
42
+ puts
43
+
44
+ # Set some defaults required by WinRM WS
45
+ options[:transport] = :plaintext
46
+ options[:basic_auth_only] = true
47
+ options[:operation_timeout] = 3600
48
+
49
+ options
50
+ rescue StandardError => e
51
+ puts e.message
52
+ help_msg
53
+ exit 1
54
+ end
55
+
56
+ def repl(options)
57
+ shell = nil
58
+
59
+ client = WinRM::Connection.new(options)
60
+ shell = client.shell(:powershell)
61
+ prompt = "PS #{ARGV[0]}> "
62
+
63
+ while (buf = Readline.readline(prompt, true))
64
+ if buf =~ /^exit/
65
+ shell.close
66
+ shell = nil
67
+ exit 0
68
+ else
69
+ shell.run(buf) do |stdout, stderr|
70
+ $stdout.write stdout
71
+ $stderr.write stderr
72
+ end
73
+ end
74
+ end
75
+ rescue Interrupt
76
+ puts 'exiting'
77
+ # ctrl-c
78
+ rescue WinRM::WinRMAuthorizationError
79
+ puts 'Authentication failed, bad user name or password'
80
+ exit 1
81
+ rescue StandardError => e
82
+ puts e.message
83
+ exit 1
84
+ ensure
85
+ shell.close unless shell.nil?
86
+ end
87
+
88
+ repl(parse_options)
89
+
90
+ # rubocop:enable all
@@ -0,0 +1,133 @@
1
+ # WinRM Gem Changelog
2
+
3
+ # 2.3.0
4
+ - Fixes rwinrm command
5
+ - Use pack('S*') instead of .chr so full utf-16 can be supported
6
+ - Omi Server compatibility fixes
7
+
8
+ # 2.2.3
9
+ - Revert change made in 2.2.2 that retries network errors in Close and cleanup
10
+
11
+ # 2.2.2
12
+ - Update PSRP buffer size
13
+ - Close and cleanup should retry on error and never raise net errors
14
+
15
+ # 2.2.1
16
+ - Ignore error 2150858843 during shell closing
17
+
18
+ # 2.2.0
19
+ - Allow run_wql to accept custom namespace
20
+ - Allow enumeration of WQL result sets
21
+
22
+ # 2.1.3
23
+ - Ignore WSManFault 2150858843 during command cleanup
24
+ - Uns `Integer` in place of `Fixnum` to remove deprecation warnings in ruby 2.4
25
+
26
+ # 2.1.2
27
+ - Fix kerberos transport
28
+
29
+ # 2.1.1
30
+ - Fix rendering of powershell output with non ascii UTF-8 characters emitted from executables
31
+
32
+ # 2.1.0
33
+ - Expose shell options when creating a winrm shell
34
+
35
+ # 2.0.3
36
+ - Do not swallow exit codes from executables
37
+
38
+ # 2.0.2
39
+ - Constrain to rubyntlm `>= 0.6.1` to avoid mutating frozen strings
40
+ - When using certificate authentication, do not validate presense of user and password
41
+ - Handle failed `PIPELINE_STATE` messages so that `throw` errors are not swallowed
42
+
43
+ # 2.0.1
44
+ - Fixed Powershell shell leakage when not explicitly closed
45
+ - Fixed cmd commands with responses that extend beyond one stream
46
+
47
+ # 2.0.0
48
+ - Cleaned up API and implemented Powershell Remoting Protocol (PSRP) for all powershell calls.
49
+
50
+ # 1.8.1
51
+ - Http receive timeout should always be equal to 10 seconds greater than the winrm operation timeout and not default to one hour
52
+
53
+ # 1.8.0
54
+ - Add certificate authentication
55
+
56
+ # 1.7.3
57
+ - Open a new shell if the current shell has been deleted
58
+
59
+ # 1.7.2
60
+ - Fix regression where BOM appears in 2008R2 output and is not stripped
61
+
62
+ # 1.7.1
63
+ - Fix OS version comparisons for Windows 10 using `Gem::Version` instead of strings
64
+
65
+ # 1.7.0
66
+ - Bump rubyntlm gem to 0.6.0 to get channel binding support for HTTPS fixing connections to endoints with `CbtHardeningLevel` set to `Strict`
67
+ - Fix for parsing binary data in command output
68
+
69
+ # 1.6.1
70
+ - Use codepage 437 by default on os versions older than Windows 7 and Windows Server 2008 R2
71
+
72
+ # 1.6.0
73
+ - Adding `:negotiate` transport providing NTLM/Negotiate encryption of WinRM requests and responses
74
+ - Removed dependency on UUIDTools gem
75
+ - Extending accepted error codes for retry behavior to include `Errno::ETIMEDOUT`
76
+ - Correct deprecation warning for WinRMWebService.run_powershell_script
77
+
78
+ # 1.5.0
79
+ - Deprecating `WinRM::WinRMWebService` methods `cmd`, `run_cmd`, `powershell`, and `run_powershell_script` in favor of the `run_cmd` and `run_powershell_script` methods of the `WinRM::CommandExecutor` class. The `CommandExecutor` allows multiple commands to be run from the same WinRM shell providing a significant performance improvement when issuing multiple calls.
80
+ - Added an `:ssl_peer_fingerprint` option to be used instead of `:no_ssl_peer_verification` and allows a specific certificate to be verified.
81
+ - Opening a winrm shell is retriable with configurable delay and retry limit.
82
+ - Logging apends to `stdout` by default and can be replaced with a logger from a consuming application.
83
+
84
+ # 1.4.0
85
+ - Added WinRM::Version so the gem version is available at runtime for consumers.
86
+
87
+ # 1.3.6
88
+ - Remove BOM from response (Issue #159) added by Windows 2008R2
89
+
90
+ # 1.3.5
91
+ - Widen logging version constraints to include 2.0
92
+ - Use codepage 65001 (UTF-8)
93
+
94
+ # 1.3.4
95
+ - Relaxed version pins on dev dependencies
96
+
97
+ # 1.3.3
98
+ - Fixed issue 133, rwinrm allow hostnames with dashes
99
+ - Use duck typing for powershell script read
100
+
101
+ # 1.3.2
102
+ - Add spec.license attribute to gemspec
103
+ - Bump RSpec dependency 3.0 to 3.2
104
+
105
+ # 1.3.1
106
+ - Fixed issue 129, long running commands could cause a stackoverflow exception
107
+ - Fixed use of sub! in run_command results in spurious capture/replacement of \& sequences
108
+ - Fixed issue 124 rwinrm won't take '.' characters in username
109
+
110
+ # 1.3.0
111
+ - Fixed multiple issues with WinRMHTTPTransportError incorrectly being raised
112
+ - Refactored and added more unit and integration tests
113
+ - Added ability to write to stdin
114
+ - Added rwinrm binary to launch remote shell
115
+ - Added WINRM_LOG env var to set log level
116
+ - Retry Kerberos auth once if 401 response is received
117
+ - Remove Savon dependency and use newer versions of underlying dependencies
118
+ - Remove Nokogiri dependency and replace with native Ruby XML
119
+ - Fixed issue 85, ensure WQL response is not nil
120
+ - All WinRM library errors inherit from base class WinRMError
121
+ - Integrations tests should now pass on Windows Server 2008+
122
+ - Bump Ruby NTLM gem version dependency
123
+ - HTTP client receive timeout is now configurable via set_timeout
124
+ - Added backwards compatible Output class to make it easier to collect output
125
+ - Bumped gssapi dependency from 1.0 to 1.2 and fixed issue 54
126
+ - Added Rubocop to build
127
+ - Fixed error when commands contain a newline character
128
+
129
+ # 1.2.0
130
+ - Allow user to disable SSL peer ceritifcate validation #44
131
+ - Allow commands with "'" chars on Ruby 2.x, fixes #69
132
+ - Fixed uninitialized constant Module::Kconv in Ruby 2.x, fixes #65
133
+ - Commands with non-ASCII chars should work, #70
@@ -0,0 +1,84 @@
1
+ # Copyright 2016 Shawn Neal <sneal@sneal.net>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'connection_opts'
16
+ require_relative 'http/transport_factory'
17
+ require_relative 'shells/shell_factory'
18
+ require_relative 'wsmv/wql_query'
19
+ require_relative 'wsmv/wql_pull'
20
+
21
+ module WinRM
22
+ # WinRM connection used to establish a session with the remote WinRM service.
23
+ class Connection
24
+ # Creates a new WinRM connection
25
+ # See the ConnectionOpts class for connection options.
26
+ def initialize(connection_opts)
27
+ configure_connection_opts(connection_opts)
28
+ configure_logger
29
+ end
30
+
31
+ attr_accessor :logger
32
+
33
+ # Creates a new shell on the remote Windows server associated with
34
+ # this connection.
35
+ # @param shell_type [Symbol] The shell type :cmd or :powershell
36
+ # @param shell_opts [Hash] Options targeted for the created shell
37
+ # @return [Shell] PowerShell or Cmd shell instance.
38
+ def shell(shell_type, shell_opts = {})
39
+ shell = shell_factory.create_shell(shell_type, shell_opts)
40
+ if block_given?
41
+ begin
42
+ yield shell
43
+ ensure
44
+ shell.close
45
+ end
46
+ else
47
+ shell
48
+ end
49
+ end
50
+
51
+ # Executes a WQL query against the WinRM connection
52
+ # @param wql [String] The wql query
53
+ # @param namespace [String] namespace for query - default is root/cimv2/*
54
+ # @return [Hash] Hash representation of wql query response (Hash is empty if a block is given)
55
+ # @yeild [type, item] Yields the time name and item for every item
56
+ def run_wql(wql, namespace = 'root/cimv2/*', &block)
57
+ query = WinRM::WSMV::WqlQuery.new(transport, @connection_opts, wql, namespace)
58
+ query.process_response(transport.send_request(query.build), &block)
59
+ end
60
+
61
+ private
62
+
63
+ def configure_connection_opts(connection_opts)
64
+ @connection_opts = ConnectionOpts.create_with_defaults(connection_opts)
65
+ end
66
+
67
+ def configure_logger
68
+ @logger = Logging.logger[self]
69
+ logger.level = :warn
70
+ logger.add_appenders(Logging.appenders.stdout)
71
+ end
72
+
73
+ def shell_factory
74
+ @shell_factory ||= WinRM::Shells::ShellFactory.new(@connection_opts, transport, logger)
75
+ end
76
+
77
+ def transport
78
+ @transport ||= begin
79
+ transport_factory = WinRM::HTTP::TransportFactory.new
80
+ transport_factory.create_transport(@connection_opts)
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,90 @@
1
+ # Copyright 2016 Shawn Neal <sneal@sneal.net>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'securerandom'
16
+
17
+ module WinRM
18
+ # WinRM connection options, provides defaults and validation.
19
+ class ConnectionOpts < Hash
20
+ DEFAULT_OPERATION_TIMEOUT = 60
21
+ DEFAULT_RECEIVE_TIMEOUT = DEFAULT_OPERATION_TIMEOUT + 10
22
+ DEFAULT_MAX_ENV_SIZE = 153600
23
+ DEFAULT_LOCALE = 'en-US'.freeze
24
+ DEFAULT_RETRY_DELAY = 10
25
+ DEFAULT_RETRY_LIMIT = 3
26
+
27
+ class << self
28
+ def create_with_defaults(overrides)
29
+ config = default.merge(overrides)
30
+ config = ensure_receive_timeout_is_greater_than_operation_timeout(config)
31
+ config.validate
32
+ config
33
+ end
34
+
35
+ private
36
+
37
+ def ensure_receive_timeout_is_greater_than_operation_timeout(config)
38
+ if config[:receive_timeout] < config[:operation_timeout]
39
+ config[:receive_timeout] = config[:operation_timeout] + 10
40
+ end
41
+ config
42
+ end
43
+
44
+ def default
45
+ config = ConnectionOpts.new
46
+ config[:session_id] = SecureRandom.uuid.to_s.upcase
47
+ config[:transport] = :negotiate
48
+ config[:locale] = DEFAULT_LOCALE
49
+ config[:max_envelope_size] = DEFAULT_MAX_ENV_SIZE
50
+ config[:operation_timeout] = DEFAULT_OPERATION_TIMEOUT
51
+ config[:receive_timeout] = DEFAULT_RECEIVE_TIMEOUT
52
+ config[:retry_delay] = DEFAULT_RETRY_DELAY
53
+ config[:retry_limit] = DEFAULT_RETRY_LIMIT
54
+ config
55
+ end
56
+ end
57
+
58
+ def validate
59
+ validate_required_fields
60
+ validate_data_types
61
+ end
62
+
63
+ private
64
+
65
+ def validate_required_fields
66
+ raise 'endpoint is a required option' unless self[:endpoint]
67
+
68
+ if self[:client_cert]
69
+ raise 'path to client key is required' unless self[:client_key]
70
+ else
71
+ raise 'user is a required option' unless self[:user]
72
+ raise 'password is a required option' unless self[:password]
73
+ end
74
+ end
75
+
76
+ def validate_data_types
77
+ validate_integer(:retry_limit)
78
+ validate_integer(:retry_delay)
79
+ validate_integer(:max_envelope_size)
80
+ validate_integer(:operation_timeout)
81
+ validate_integer(:receive_timeout, self[:operation_timeout])
82
+ end
83
+
84
+ def validate_integer(key, min = 0)
85
+ value = self[key]
86
+ raise "#{key} must be a Integer" unless value && value.is_a?(Integer)
87
+ raise "#{key} must be greater than #{min}" unless value > min
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,88 @@
1
+ # Copyright 2010 Dan Wanek <dan.wanek@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module WinRM
16
+ # WinRM base class for errors
17
+ class WinRMError < StandardError; end
18
+
19
+ # Authorization Error
20
+ class WinRMAuthorizationError < WinRMError; end
21
+
22
+ # Shell creation error
23
+ class InvalidShellError < WinRMError; end
24
+
25
+ # Exitcode error
26
+ class InvalidExitCode < WinRMError; end
27
+
28
+ # Shell creation error
29
+ class InvalidTransportError < WinRMError
30
+ attr_reader :invalid_transport
31
+
32
+ def initialize(invalid_transport, valid_transports)
33
+ @invalid_transport = invalid_transport
34
+ super(
35
+ "Invalid transport '#{invalid_transport}' specified" \
36
+ ", expected: #{valid_transports.join(', ')}."
37
+ )
38
+ end
39
+ end
40
+
41
+ # A Fault returned in the SOAP response. The XML node is a WSManFault
42
+ class WinRMWSManFault < WinRMError
43
+ attr_reader :fault_code
44
+ attr_reader :fault_description
45
+
46
+ def initialize(fault_description, fault_code)
47
+ @fault_description = fault_description
48
+ @fault_code = fault_code
49
+ super("[WSMAN ERROR CODE: #{fault_code}]: #{fault_description}")
50
+ end
51
+ end
52
+
53
+ # A Fault returned in the SOAP response. The XML node contains Code, SubCode and Reason
54
+ class WinRMSoapFault < WinRMError
55
+ attr_reader :code
56
+ attr_reader :subcode
57
+ attr_reader :reason
58
+
59
+ def initialize(code, subcode, reason)
60
+ @code = code
61
+ @subcode = subcode
62
+ @reason = reason
63
+ super("[SOAP ERROR CODE: #{code} (#{subcode})]: #{reason}")
64
+ end
65
+ end
66
+
67
+ # A Fault returned in the SOAP response. The XML node is a MSFT_WmiError
68
+ class WinRMWMIError < WinRMError
69
+ attr_reader :error_code
70
+ attr_reader :error
71
+
72
+ def initialize(error, error_code)
73
+ @error = error
74
+ @error_code = error_code
75
+ super("[WMI ERROR CODE: #{error_code}]: #{error}")
76
+ end
77
+ end
78
+
79
+ # non-200 response without a SOAP fault
80
+ class WinRMHTTPTransportError < WinRMError
81
+ attr_reader :status_code
82
+
83
+ def initialize(msg, status_code = nil)
84
+ @status_code = status_code
85
+ super(msg + " (#{status_code}).")
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,127 @@
1
+ # Copyright 2014 Shawn Neal <sneal@sneal.net>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'rexml/document'
16
+ require_relative '../wsmv/soap'
17
+
18
+ module WinRM
19
+ # Handles the raw WinRM HTTP response. Returns the body as an XML doc
20
+ # or raises the appropriate WinRM error if the response is an error.
21
+ class ResponseHandler
22
+ # @param [String] The raw unparsed response body, if any
23
+ # @param [Integer] The HTTP response status code
24
+ def initialize(response_body, status_code)
25
+ @response_body = response_body
26
+ @status_code = status_code
27
+ end
28
+
29
+ # Processes the response from the WinRM service and either returns an XML
30
+ # doc or raises an appropriate error.
31
+ #
32
+ # @returns [REXML::Document] The parsed response body
33
+ def parse_to_xml
34
+ raise_if_error
35
+ response_xml
36
+ end
37
+
38
+ private
39
+
40
+ def response_xml
41
+ @response_xml ||= REXML::Document.new(@response_body)
42
+ rescue REXML::ParseException => e
43
+ raise WinRMHTTPTransportError.new(
44
+ "Unable to parse WinRM response: #{e.message}", @status_code
45
+ )
46
+ end
47
+
48
+ def raise_if_error
49
+ return if @status_code == 200
50
+
51
+ raise_if_auth_error
52
+ raise_if_wsman_fault
53
+ raise_if_wmi_error
54
+ raise_if_soap_fault
55
+ raise_transport_error
56
+ end
57
+
58
+ def raise_if_auth_error
59
+ raise WinRMAuthorizationError if @status_code == 401
60
+ end
61
+
62
+ def raise_if_wsman_fault
63
+ soap_errors = REXML::XPath.match(
64
+ response_xml,
65
+ "//*[local-name() = 'Envelope']/*[local-name() = 'Body']/*[local-name() = 'Fault']/*"
66
+ )
67
+ return if soap_errors.empty?
68
+
69
+ fault = REXML::XPath.first(
70
+ soap_errors,
71
+ "//*[local-name() = 'WSManFault']"
72
+ )
73
+ raise WinRMWSManFault.new(fault.to_s, fault.attributes['Code']) unless fault.nil?
74
+ end
75
+
76
+ def raise_if_wmi_error
77
+ soap_errors = REXML::XPath.match(
78
+ response_xml,
79
+ "//*[local-name() = 'Envelope']/*[local-name() = 'Body']/*[local-name() = 'Fault']/*"
80
+ )
81
+ return if soap_errors.empty?
82
+
83
+ error = REXML::XPath.first(
84
+ soap_errors,
85
+ "//*[local-name() = 'MSFT_WmiError']"
86
+ )
87
+ return if error.nil?
88
+
89
+ error_code = REXML::XPath.first(
90
+ error,
91
+ "//*[local-name() = 'error_Code']"
92
+ ).text
93
+ raise WinRMWMIError.new(error.to_s, error_code)
94
+ end
95
+
96
+ def raise_if_soap_fault
97
+ soap_errors = REXML::XPath.match(
98
+ response_xml,
99
+ "//*[local-name() = 'Envelope']/*[local-name() = 'Body']/*[local-name() = 'Fault']/*"
100
+ )
101
+ return if soap_errors.empty?
102
+
103
+ code = REXML::XPath.first(
104
+ soap_errors,
105
+ "//*[local-name() = 'Code']/*[local-name() = 'Value']/text()"
106
+ )
107
+ subcode = REXML::XPath.first(
108
+ soap_errors,
109
+ "//*[local-name() = 'Subcode']/*[local-name() = 'Value']/text()"
110
+ )
111
+ reason = REXML::XPath.first(
112
+ soap_errors,
113
+ "//*[local-name() = 'Reason']/*[local-name() = 'Text']/text()"
114
+ )
115
+
116
+ raise WinRMSoapFault.new(code, subcode, reason) unless
117
+ code.nil? && subcode.nil? && reason.nil?
118
+ end
119
+
120
+ def raise_transport_error
121
+ raise WinRMHTTPTransportError.new(
122
+ "Bad HTTP response returned from server. Body(if present):#{@response_body}",
123
+ @status_code
124
+ )
125
+ end
126
+ end
127
+ end