vagrant-windows-hyperv 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/README.md +22 -11
- data/lib/vagrant-windows-hyperv.rb +4 -1
- data/lib/vagrant-windows-hyperv/action.rb +0 -19
- data/lib/vagrant-windows-hyperv/communication/powershell.rb +7 -3
- data/lib/vagrant-windows-hyperv/errors.rb +20 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/action.rb +45 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/action/customize.rb +167 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/action/import.rb +72 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/action/provision.rb +5 -1
- data/lib/vagrant-windows-hyperv/monkey_patch/config.rb +51 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/driver.rb +52 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/machine.rb +3 -3
- data/lib/vagrant-windows-hyperv/monkey_patch/plugins/synced_folders/smb/synced_folders.rb +3 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/scripts/add_switch_to_vm.ps1 +38 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/scripts/create_switch.ps1 +75 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/scripts/find_vm_switch_name.ps1 +29 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/scripts/get_adapters.ps1 +17 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/scripts/import_vm.ps1 +136 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/scripts/switch_exist.ps1 +54 -0
- data/lib/vagrant-windows-hyperv/monkey_patch/scripts/utils/write_messages.ps1 +20 -0
- data/lib/vagrant-windows-hyperv/provisioner/puppet.rb +2 -2
- data/lib/vagrant-windows-hyperv/scripts/check_winrm.ps1 +7 -3
- data/lib/vagrant-windows-hyperv/scripts/upload_file.ps1 +29 -3
- data/lib/vagrant-windows-hyperv/scripts/utils/create_session.ps1 +19 -5
- data/lib/vagrant-windows-hyperv/version.rb +1 -1
- data/locales/en.yml +60 -3
- metadata +15 -3
- data/lib/vagrant-windows-hyperv/monkey_patch/util/powershell.rb +0 -37
@@ -0,0 +1,54 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
+
# All Rights Reserved. Licensed under the MIT License.
|
4
|
+
#--------------------------------------------------------------------------
|
5
|
+
|
6
|
+
param (
|
7
|
+
[Parameter(Mandatory=$true)]
|
8
|
+
[string]$type,
|
9
|
+
[Parameter(Mandatory=$true)]
|
10
|
+
[string]$name
|
11
|
+
)
|
12
|
+
|
13
|
+
# Include the following modules
|
14
|
+
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
15
|
+
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
|
16
|
+
|
17
|
+
try {
|
18
|
+
if ($type -eq "external") {
|
19
|
+
$switch_exist = Get-VMSwitch -SwitchType "$type"
|
20
|
+
if ($switch_exist) {
|
21
|
+
$switch_name = $switch_exist.name
|
22
|
+
$resptHash = @{
|
23
|
+
message = "switch exist"
|
24
|
+
switch_name = "$switch_name"
|
25
|
+
}
|
26
|
+
Write-Output-Message $(ConvertTo-JSON $resptHash)
|
27
|
+
return
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
$switch_exist = (Get-VMSwitch -SwitchType "$type" `
|
32
|
+
| Select-Object Name `
|
33
|
+
| Where-Object { $_.name -eq $name })
|
34
|
+
if ($switch_exist) {
|
35
|
+
$switch_name = $switch_exist.name
|
36
|
+
$resptHash = @{
|
37
|
+
message = "switch exist"
|
38
|
+
switch_name = "$switch_name"
|
39
|
+
}
|
40
|
+
} else {
|
41
|
+
$resptHash = @{
|
42
|
+
message = "switch not exist"
|
43
|
+
switch_name = "$name"
|
44
|
+
}
|
45
|
+
}
|
46
|
+
Write-Output-Message $(ConvertTo-JSON $resptHash)
|
47
|
+
return
|
48
|
+
} catch {
|
49
|
+
$errortHash = @{
|
50
|
+
type = "PowerShellError"
|
51
|
+
error = "$_"
|
52
|
+
}
|
53
|
+
Write-Error-Message $(ConvertTo-JSON $errortHash)
|
54
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
+
# All Rights Reserved. Licensed under the MIT License.
|
4
|
+
#--------------------------------------------------------------------------
|
5
|
+
|
6
|
+
function Write-Error-Message($message) {
|
7
|
+
$error_message = @{
|
8
|
+
error = "$message"
|
9
|
+
}
|
10
|
+
Write-Host "===Begin-Error==="
|
11
|
+
$result = ConvertTo-json $error_message
|
12
|
+
Write-Host $result
|
13
|
+
Write-Host "===End-Error==="
|
14
|
+
}
|
15
|
+
|
16
|
+
function Write-Output-Message($message) {
|
17
|
+
Write-Host "===Begin-Output==="
|
18
|
+
Write-Host $message
|
19
|
+
Write-Host "===End-Output==="
|
20
|
+
}
|
@@ -42,7 +42,7 @@ module VagrantPlugins
|
|
42
42
|
module_paths.unshift("/ProgramData/PuppetLabs/puppet/etc/modules")
|
43
43
|
|
44
44
|
# Add the command line switch to add the module path
|
45
|
-
options << "--modulepath \"#{module_paths.join('
|
45
|
+
options << "--modulepath \"#{module_paths.join(';')}\""
|
46
46
|
end
|
47
47
|
|
48
48
|
if @hiera_config_path
|
@@ -64,7 +64,7 @@ module VagrantPlugins
|
|
64
64
|
if !config.facter.empty?
|
65
65
|
facts = []
|
66
66
|
config.facter.each do |key, value|
|
67
|
-
facts << "FACTER_#{key}
|
67
|
+
facts << "FACTER_#{key}=\"#{value}\""
|
68
68
|
end
|
69
69
|
|
70
70
|
facter = "#{facts.join(" ")} "
|
@@ -16,8 +16,12 @@ $presentDir = Split-Path -parent $PSCommandPath
|
|
16
16
|
try {
|
17
17
|
$response = Create-Remote-Session $guest_ip $username $password
|
18
18
|
if (!$response["session"] -and $response["error"]) {
|
19
|
-
|
20
|
-
|
19
|
+
$session_message = $response['error']
|
20
|
+
$resultHash = @{
|
21
|
+
message = "$session_message"
|
22
|
+
}
|
23
|
+
Write-Output-Message $resultHash
|
24
|
+
return
|
21
25
|
}
|
22
26
|
function Remote-Execute() {
|
23
27
|
$winrm_state = ""
|
@@ -34,7 +38,7 @@ try {
|
|
34
38
|
} catch {
|
35
39
|
$errortHash = @{
|
36
40
|
type = "PowerShellError"
|
37
|
-
error ="
|
41
|
+
error ="$_"
|
38
42
|
}
|
39
43
|
Write-Error-Message $errortHash
|
40
44
|
return
|
@@ -20,9 +20,35 @@ $presentDir = Split-Path -parent $PSCommandPath
|
|
20
20
|
try {
|
21
21
|
# Enable Guest Service Interface if they are disabled
|
22
22
|
try {
|
23
|
-
|
23
|
+
$Operational = $null
|
24
|
+
$maxAttempt = 5
|
25
|
+
do {
|
26
|
+
$maxAttempt = $maxAttempt - 1
|
27
|
+
$Operational = Get-VM -Id $vm_id | Get-VMIntegrationService -Name "Guest Service Interface"
|
28
|
+
if (-not $Operational.Enabled) {
|
29
|
+
Get-VM -Id $vm_id | Get-VMIntegrationService -Name "Guest Service Interface" | Enable-VMIntegrationService -Passthru
|
30
|
+
sleep 1
|
31
|
+
}
|
32
|
+
}
|
33
|
+
While ( !$Operational.Enabled -and $maxAttempt -gt 0 )
|
34
|
+
}
|
35
|
+
catch {
|
36
|
+
$errortHash = @{
|
37
|
+
type = "PowerShellError"
|
38
|
+
error = "$_"
|
39
|
+
}
|
40
|
+
Write-Error-Message $errortHash
|
41
|
+
return
|
42
|
+
}
|
43
|
+
|
44
|
+
if (!$Operational -or !$Operational.ENabled) {
|
45
|
+
$errortHash = @{
|
46
|
+
type = "PowerShellError"
|
47
|
+
error = "Could not enable Guest Service Interface."
|
24
48
|
}
|
25
|
-
|
49
|
+
Write-Error-Message $errortHash
|
50
|
+
return
|
51
|
+
}
|
26
52
|
|
27
53
|
function Upload-FIle-To-VM($host_path, $guest_path, $machine) {
|
28
54
|
Write-Host $host_path
|
@@ -35,7 +61,7 @@ try {
|
|
35
61
|
if (!$response["session"] -and $response["error"]) {
|
36
62
|
$errortHash = @{
|
37
63
|
type = "PowerShellError"
|
38
|
-
|
64
|
+
error = $response["error"]
|
39
65
|
}
|
40
66
|
Write-Error-Message $errorResult
|
41
67
|
return
|
@@ -13,6 +13,8 @@ function Create-Remote-Session($guest_ip, $username, $password) {
|
|
13
13
|
$count = 0
|
14
14
|
$session_error = ""
|
15
15
|
$session = ""
|
16
|
+
$max_attempts = 5
|
17
|
+
$sleep_for_sec = 5
|
16
18
|
do {
|
17
19
|
$count++
|
18
20
|
try {
|
@@ -20,15 +22,27 @@ function Create-Remote-Session($guest_ip, $username, $password) {
|
|
20
22
|
$session_error = ""
|
21
23
|
}
|
22
24
|
catch {
|
23
|
-
|
24
|
-
$
|
25
|
-
|
25
|
+
$session_error = $_.Exception.message
|
26
|
+
if ($_.FullyQualifiedErrorID -eq "AccessDenied,PSSessionOpenFailed") {
|
27
|
+
$count = $max_attempts
|
28
|
+
}
|
29
|
+
elseif ($_FullyQualifiedErrorID -eq "CannotUseIPAddress,PSSessionOpenFailed") {
|
30
|
+
$count = $max_attempts
|
31
|
+
}
|
32
|
+
elseif ( $_.FullyQualifiedErrorID -eq "WinRMOperationTimeout,PSSessionOpenFailed") {
|
33
|
+
Start-Sleep -s $sleep_for_sec
|
34
|
+
$session = ""
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
Start-Sleep -s $sleep_for_sec
|
38
|
+
$session = ""
|
39
|
+
}
|
26
40
|
}
|
27
41
|
}
|
28
|
-
while (!$session -and $count -lt
|
42
|
+
while (!$session -and $count -lt $max_attempts)
|
29
43
|
|
30
44
|
return @{
|
31
45
|
session = $session
|
32
|
-
error = $session_error
|
46
|
+
error = "$session_error"
|
33
47
|
}
|
34
48
|
}
|
data/locales/en.yml
CHANGED
@@ -5,11 +5,68 @@ en:
|
|
5
5
|
RDP session and enter the Virtual Machine's password.
|
6
6
|
message_rdp_not_ready: |-
|
7
7
|
Hyper-V machine isn't running. Can't RDP in!
|
8
|
+
choose_adapter: |-
|
9
|
+
Please select a adapter from the available network adapters.
|
10
|
+
choose_switch: |-
|
11
|
+
Please choose a switch to attach to your Hyper-V instance.
|
12
|
+
If none of these are appropriate, please open the Hyper-V manager
|
13
|
+
to create a new virtual switch.
|
14
|
+
virtual_switch_info: |-
|
15
|
+
Vagrant works well with Hyper-V's External Switch. If you are using an Internal switch
|
16
|
+
please make sure that this switch is properly configured for network connection.
|
17
|
+
The virtual machine must be reachable from the host for Vagrant to work.
|
18
|
+
no_private_switch: |-
|
19
|
+
Vagrant cannot work with Hyper-V's private switch, since this configuration
|
20
|
+
will not allow the host to communicate with the VM. Please refer to Hyper-V's
|
21
|
+
virtual switch configuration for more information.
|
22
|
+
external_switch_exists: |-
|
23
|
+
Hyper-V allows to have only one external switch. There is one already available.
|
24
|
+
Please check the Virtual Switch Manager in Hyper-V Manager.
|
25
|
+
Ignoring the customization and moving on.
|
26
|
+
private_switch_not_allowed: |-
|
27
|
+
Vagrant cannot work with Hyper-V's private switch, since this configuration
|
28
|
+
will not allow the host to communicate with the VM. Please refer to Hyper-V's
|
29
|
+
virtual switch configuration for more information.
|
30
|
+
internal_switch_warn: |-
|
31
|
+
Vagrant works best with Hyper-V's External Switch. If you are using an
|
32
|
+
Internal switch please make sure that this switch is properly configured
|
33
|
+
for network connection. The virtual machine must be reachable from the
|
34
|
+
host for Vagrant to work.
|
35
|
+
net_adapter_warn: |-
|
36
|
+
You seems to have provided an invalid adapter, please choose one from
|
37
|
+
the available list of adapters.
|
38
|
+
creating_switch: |-
|
39
|
+
Creating a virtual switch of type "%{type}" with name "%{name}"
|
40
|
+
add_switch_to_vm: |-
|
41
|
+
Setting the VM to use a Virtual switch of type "%{type}" with name "%{name}"
|
42
|
+
|
8
43
|
errors:
|
9
44
|
ssh_not_available: |-
|
10
45
|
SSH is available for non windows guest. Vagrant detected guest to be %{guest}
|
11
46
|
rdp_not_available: |-
|
12
47
|
RDP is available for windows guest. Vagrant detected guest to be %{guest}
|
13
|
-
|
14
|
-
|
15
|
-
|
48
|
+
win_rm_not_available: |-
|
49
|
+
Vagrant failed to communicate to the VM using powershell. The operation failed
|
50
|
+
with the following message.
|
51
|
+
%{message}
|
52
|
+
no_network_adapter: |-
|
53
|
+
No Network adapter is connected to this VM. Please use the HyperV Manage to add a network adapter.
|
54
|
+
no_switches: |-
|
55
|
+
There are no virtual switches created for Hyper-V! Please open
|
56
|
+
the Hyper-V Manager, go to the "Virtual Switch Manager", and create
|
57
|
+
at least one virtual switch.
|
58
|
+
A virtual switch is required for Vagrant to create a Hyper-V
|
59
|
+
machine that is connected to a network so it can access it.
|
60
|
+
You can also use the customize option to add a virtual switch to this VM.
|
61
|
+
For more help, please see the documentation on the Vagrant website
|
62
|
+
for Hyper-V.
|
63
|
+
network_down: |-
|
64
|
+
The host network seems to be down, this generally happens while creating an
|
65
|
+
external network, it looked like Hyper-V manager took a long time to bring back
|
66
|
+
the network. Please check the network connection and try again.
|
67
|
+
switch_not_found: |-
|
68
|
+
A Virtual switch of type "%{type}" and name "%{name}" is not found, please
|
69
|
+
create the same using Hyper-V "Virtual Switch Manager".
|
70
|
+
external_switch_exist: |-
|
71
|
+
Hyper-V allows to have only one external switch. There already exist one
|
72
|
+
with name "%{name}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-windows-hyperv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MSOpenTech
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -100,6 +100,7 @@ executables: []
|
|
100
100
|
extensions: []
|
101
101
|
extra_rdoc_files: []
|
102
102
|
files:
|
103
|
+
- CHANGELOG.md
|
103
104
|
- example_box/metadata.json
|
104
105
|
- Gemfile
|
105
106
|
- lib/vagrant-windows-hyperv/action/export.rb
|
@@ -113,10 +114,21 @@ files:
|
|
113
114
|
- lib/vagrant-windows-hyperv/errors.rb
|
114
115
|
- lib/vagrant-windows-hyperv/guest/cap/halt.rb
|
115
116
|
- lib/vagrant-windows-hyperv/guest/windows.rb
|
117
|
+
- lib/vagrant-windows-hyperv/monkey_patch/action/customize.rb
|
118
|
+
- lib/vagrant-windows-hyperv/monkey_patch/action/import.rb
|
116
119
|
- lib/vagrant-windows-hyperv/monkey_patch/action/provision.rb
|
120
|
+
- lib/vagrant-windows-hyperv/monkey_patch/action.rb
|
121
|
+
- lib/vagrant-windows-hyperv/monkey_patch/config.rb
|
122
|
+
- lib/vagrant-windows-hyperv/monkey_patch/driver.rb
|
117
123
|
- lib/vagrant-windows-hyperv/monkey_patch/machine.rb
|
118
124
|
- lib/vagrant-windows-hyperv/monkey_patch/plugins/synced_folders/smb/synced_folders.rb
|
119
|
-
- lib/vagrant-windows-hyperv/monkey_patch/
|
125
|
+
- lib/vagrant-windows-hyperv/monkey_patch/scripts/add_switch_to_vm.ps1
|
126
|
+
- lib/vagrant-windows-hyperv/monkey_patch/scripts/create_switch.ps1
|
127
|
+
- lib/vagrant-windows-hyperv/monkey_patch/scripts/find_vm_switch_name.ps1
|
128
|
+
- lib/vagrant-windows-hyperv/monkey_patch/scripts/get_adapters.ps1
|
129
|
+
- lib/vagrant-windows-hyperv/monkey_patch/scripts/import_vm.ps1
|
130
|
+
- lib/vagrant-windows-hyperv/monkey_patch/scripts/switch_exist.ps1
|
131
|
+
- lib/vagrant-windows-hyperv/monkey_patch/scripts/utils/write_messages.ps1
|
120
132
|
- lib/vagrant-windows-hyperv/plugin.rb
|
121
133
|
- lib/vagrant-windows-hyperv/provider.rb
|
122
134
|
- lib/vagrant-windows-hyperv/provisioner/chef_solo.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved. Licensed under the Apache 2.0 License.
|
4
|
-
#--------------------------------------------------------------------------
|
5
|
-
|
6
|
-
require "#{Vagrant::source_root}/lib/vagrant/util/which"
|
7
|
-
require "#{Vagrant::source_root}/lib/vagrant/util/subprocess"
|
8
|
-
|
9
|
-
module Vagrant
|
10
|
-
module Util
|
11
|
-
# Executes PowerShell scripts.
|
12
|
-
#
|
13
|
-
# This is primarily a convenience wrapper around Subprocess that
|
14
|
-
# properly sets powershell flags for you.
|
15
|
-
class PowerShell
|
16
|
-
# Monkey patch to fix a bug with Vagrant 1.5.1.
|
17
|
-
# https://github.com/mitchellh/vagrant/issues/3192.
|
18
|
-
# This has been fixed in 1.5.2. by
|
19
|
-
# https://github.com/jyggen/vagrant/commit/d7320399e2497aae9b9c3fa83d94b7210d21bfb5
|
20
|
-
def self.execute(path, *args, **opts, &block)
|
21
|
-
command = [
|
22
|
-
"powershell",
|
23
|
-
"-NoProfile",
|
24
|
-
"-ExecutionPolicy", "Bypass",
|
25
|
-
"&('#{path}')",
|
26
|
-
args
|
27
|
-
].flatten
|
28
|
-
|
29
|
-
# Append on the options hash since Subprocess doesn't use
|
30
|
-
# Ruby 2.0 style options yet.
|
31
|
-
command << opts
|
32
|
-
|
33
|
-
Subprocess.execute(*command, &block)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|