vagrant-winrmcli 1.0.1 → 1.0.3

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: 03ce2652a5fdd9b14445cb4a416243570e7238f6
4
- data.tar.gz: a1c32dd4d6d2f95a79b9436cd500be4dc58f16ee
3
+ metadata.gz: d248c8059cce7cc3df6433945ecea6ac3f97143e
4
+ data.tar.gz: bb9e5cc8e755b4b18cadab89659beafbe5da3043
5
5
  SHA512:
6
- metadata.gz: 598a18c607d5fab7c0d08159796f79c7b79573997fc0f1840ab6639607d2a3d408f26de2f20764d938d1be32399162f75612ebc60321c09c089023e92edb3435
7
- data.tar.gz: 246ecb8efa5638a423056d53205dacd05e3a395aefe9f5a42f95965771cb53682886107b6f308013f1408541c52e4ebe68ab9653680c24384c5333f1a8864029
6
+ metadata.gz: 29f1a29e7e6e38cb8fb61535dff14cb472bac21e87c83491dfa11e2c7104d1b950c9c6a16e568730e062f01160955dc339c7cdc2e2bcc901de51130e2f27b112
7
+ data.tar.gz: 659d03e09287702becf4a78de6fd1b279749e8ad72991af74bffc56175ac66660266f9e6829040bd8a8c3860535c7338e69e4c5958d5bd2711e38240f7fa841b
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "winrm", ">= 1.2.0"
3
+ gem "winrm", ">= 1.1.3"
4
4
 
5
5
  # Specify your gem's dependencies in vagrant-winrm.gemspec
6
6
  group :development do
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Vagrant::Winrm::Cli::Plugin
1
+ # VagrantPlugins::WinrmCli
2
2
 
3
3
  TODO: Write a gem description
4
4
 
@@ -1,4 +1,3 @@
1
- require 'winrm'
2
1
  require 'json'
3
2
 
4
3
  module VagrantPlugins
@@ -9,33 +8,52 @@ module VagrantPlugins
9
8
  'connects to a machine via WinRM'
10
9
  end
11
10
 
11
+ # Sets $VERBOSE to nil for the duration of the block and back to its original
12
+ # value afterwards.
13
+ def silence_warnings()
14
+ old_verbose, $VERBOSE = $VERBOSE, nil
15
+ yield
16
+ ensure
17
+ $VERBOSE = old_verbose
18
+ end
19
+
12
20
  def execute
13
- mode = parse_args
21
+ silence_warnings do
22
+ require "winrm"
23
+ end
14
24
 
15
- endpoint = "https://104.197.0.231:5986/wsman"
16
- username = "tim"
17
- password = "($*rh28HS48!"
25
+ mode = parse_args
18
26
 
19
27
  # Execute the actual SSH
20
28
  with_target_vms(nil, single_target: true) do |vm|
21
- username = vm.config.winrm.username
22
- password = vm.config.winrm.password
23
- port = vm.config.winrm.port
24
- host = vm.ssh_info[:host]
25
- endpoint = 'https://' + host.to_s + ':' + port.to_s + '/wsman'
26
- winrm = WinRM::WinRMWebService.new(endpoint, :ssl, :user => username, :pass => password, :basic_auth_only => true, :no_ssl_peer_verification => true)
27
- while true do
28
- cmd = @env.ui.ask "PS> "
29
- if mode == 'ps'
30
- cmd = 'PowerShell -Command "& {' + cmd.strip.to_json + '}"'
31
- else
32
- cmd = cmd.strip
33
- end
34
- winrm.cmd(cmd) do |stdout, stderr|
35
- STDOUT.print stdout
36
- STDERR.print stderr
37
- end
29
+ username = vm.config.winrm.username
30
+ password = vm.config.winrm.password
31
+ port = vm.config.winrm.port
32
+ host = vm.ssh_info[:host]
33
+ endpoint = 'https://' + host.to_s + ':' + port.to_s + '/wsman'
34
+ winrm = WinRM::WinRMWebService.new(endpoint, :ssl, :user => username, :pass => password, :basic_auth_only => true)
35
+ winrm.instance_variable_get('@xfer').instance_variable_get('@httpcli').ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
36
+
37
+ shell_id = nil
38
+ silence_warnings do
39
+ shell_id = winrm.open_shell()
40
+ end
41
+ while true do
42
+ cmd = @env.ui.ask "PS> "
43
+ cmd = cmd.strip
44
+ if mode == 'ps'
45
+ encoded_script = cmd.encode('UTF-16LE', 'UTF-8')
46
+ script = Base64.strict_encode64(encoded_script)
47
+ cmd = "powershell -encodedCommand #{script}"
48
+ puts cmd
38
49
  end
50
+
51
+ command_id = winrm.run_command(shell_id, cmd)
52
+ winrm.get_command_output(shell_id, command_id) do |stdout, stderr|
53
+ STDOUT.print stdout
54
+ STDERR.print stderr
55
+ end
56
+ end
39
57
  end
40
58
  end
41
59
 
@@ -72,4 +90,4 @@ module VagrantPlugins
72
90
 
73
91
  end # Command
74
92
  end # Exec
75
- end # VagrantPlugins
93
+ end # VagrantPlugins
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module WinrmCli
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-winrmcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Cameron Ryan