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 +4 -4
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/lib/vagrant-winrmcli/command.rb +41 -23
- data/lib/vagrant-winrmcli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d248c8059cce7cc3df6433945ecea6ac3f97143e
|
4
|
+
data.tar.gz: bb9e5cc8e755b4b18cadab89659beafbe5da3043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29f1a29e7e6e38cb8fb61535dff14cb472bac21e87c83491dfa11e2c7104d1b950c9c6a16e568730e062f01160955dc339c7cdc2e2bcc901de51130e2f27b112
|
7
|
+
data.tar.gz: 659d03e09287702becf4a78de6fd1b279749e8ad72991af74bffc56175ac66660266f9e6829040bd8a8c3860535c7338e69e4c5958d5bd2711e38240f7fa841b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -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
|
-
|
21
|
+
silence_warnings do
|
22
|
+
require "winrm"
|
23
|
+
end
|
14
24
|
|
15
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|