vagrant-vmm 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 +8 -8
- data/README.md +29 -0
- data/lib/vagrant-vmm/action/import.rb +7 -1
- data/lib/vagrant-vmm/config.rb +13 -2
- data/lib/vagrant-vmm/driver.rb +4 -2
- data/lib/vagrant-vmm/scripts/import_vm.ps1 +32 -5
- data/lib/vagrant-vmm/scripts/sync_folders.ps1 +86 -83
- data/lib/vagrant-vmm/scripts/utils/manage_trusted_hosts.ps1 +23 -0
- data/lib/vagrant-vmm/scripts/utils/vmm_executor.ps1 +16 -4
- data/lib/vagrant-vmm/synced_folder.rb +1 -1
- data/lib/vagrant-vmm/version.rb +1 -1
- data/locales/en.yml +8 -15
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjI2MDIyNDY4OWIyOGMzMjFkYzUyNDRmZTU2ODY4MjlkMzZmYjNlNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Mzg2OGNhZjQ0ZDMyOWI1YmUzNjE0ZGFiYmFjNzdmYzQyOTI4OGI4NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjQ3MWI2YTViZGRhNzdiMjBiNjQzYzYxMjk0NDA2ZTYzZGJkMTk4ZjVkMWNj
|
10
|
+
OWViOGYyYTRmMzViMmIxOWE2M2ZhMmYwZGM4MDNiMTUzNWM0MTU5ZWZhMzQw
|
11
|
+
NjdmNjZhM2QwMDFhMWZlMjM0MWVkMDE4MjdiYTRiYjE2ZGE3NTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmU3NWYzOGRlMzcxMTAxODdiMjAyZDRkMGEzMWQ1MDBmNmZjMzRiMzMxNzRl
|
14
|
+
MmJmMDkyZjM3YTI0Y2QzMzRjZDIwZTc2N2IyMTFkY2JmZTZiMWEwZmJlNjIw
|
15
|
+
ZGJjNzk4NmZiZDM5ODIwNDE5YjRmZTdjYjYwMDg1YmZjNzhiNTQ=
|
data/README.md
CHANGED
@@ -92,6 +92,35 @@ If your local machine do not have direct access to the machine that hosts VMM, b
|
|
92
92
|
conf.proxy_server_address = 'my-proxy-to-vmm'
|
93
93
|
```
|
94
94
|
|
95
|
+
### Active Directory settings ( optional )
|
96
|
+
|
97
|
+
You can tell the provider to move your VM under some particular OU once it's created.
|
98
|
+
Here are required options you need to specify for that.
|
99
|
+
|
100
|
+
#### ad_server
|
101
|
+
|
102
|
+
URL of AD server. Can be derived by running **echo %LOGONSERVER%** command in CMD of the VM environment.
|
103
|
+
Example:
|
104
|
+
```
|
105
|
+
conf.ad_server = 'my-ad-server.some.domain.local'
|
106
|
+
```
|
107
|
+
|
108
|
+
#### ad_source_path
|
109
|
+
|
110
|
+
Base DN container where VM appears(and it will be moved from) once it's created.
|
111
|
+
Example:
|
112
|
+
```
|
113
|
+
conf.ad_source_path = 'CN=Computers,DC=some,DC=domain,DC=local'
|
114
|
+
```
|
115
|
+
|
116
|
+
#### ad_target_path
|
117
|
+
|
118
|
+
New AD path where VM should be moved to.
|
119
|
+
Example:
|
120
|
+
```
|
121
|
+
conf.ad_target_path = 'OU=Vagrant,OU=Chef-Nodes,DC=some,DC=domain,DC=local'
|
122
|
+
```
|
123
|
+
|
95
124
|
## Troubleshooting
|
96
125
|
|
97
126
|
### Hangs on waiting machine to boot
|
@@ -19,11 +19,17 @@ module VagrantPlugins
|
|
19
19
|
proxy_server_address: env[:machine].provider_config.proxy_server_address,
|
20
20
|
vm_name: env[:machine].config.vm.hostname,
|
21
21
|
vm_template_name: env[:machine].provider_config.vm_template_name,
|
22
|
-
vm_host_group_name: env[:machine].provider_config.vm_host_group_name
|
22
|
+
vm_host_group_name: env[:machine].provider_config.vm_host_group_name,
|
23
|
+
ad_server: env[:machine].provider_config.ad_server,
|
24
|
+
ad_source_path: env[:machine].provider_config.ad_source_path,
|
25
|
+
ad_target_path: env[:machine].provider_config.ad_target_path
|
23
26
|
}
|
24
27
|
|
25
28
|
#
|
26
29
|
env[:ui].detail("Creating and registering VM in the VMM (#{vmm_server_address})...")
|
30
|
+
if options[:ad_server] && options[:ad_source_path] && options[:ad_target_path]
|
31
|
+
env[:ui].detail(" ..and moving it under #{options[:ad_target_path]} after it's created.")
|
32
|
+
end
|
27
33
|
server = env[:machine].provider.driver.import(options)
|
28
34
|
env[:ui].detail("Successfully created the VM with name: #{server['name']}")
|
29
35
|
env[:machine].id = server["id"]
|
data/lib/vagrant-vmm/config.rb
CHANGED
@@ -18,14 +18,25 @@ module VagrantPlugins
|
|
18
18
|
attr_accessor :vm_host_group_name
|
19
19
|
# @return [String]
|
20
20
|
attr_accessor :vm_address
|
21
|
+
# @return [String]
|
22
|
+
attr_accessor :ad_server
|
23
|
+
# @return [String]
|
24
|
+
attr_accessor :ad_source_path
|
25
|
+
# @return [String]
|
26
|
+
attr_accessor :ad_target_path
|
27
|
+
|
28
|
+
|
21
29
|
|
22
30
|
def initialize
|
23
31
|
@ip_address_timeout = UNSET_VALUE
|
24
|
-
@proxy_server_address =
|
32
|
+
@proxy_server_address = nil
|
25
33
|
@vmm_server_address = UNSET_VALUE
|
26
34
|
@vm_template_name = UNSET_VALUE
|
27
35
|
@vm_host_group_name = UNSET_VALUE
|
28
|
-
@vm_address =
|
36
|
+
@vm_address = nil
|
37
|
+
@ad_server = nil
|
38
|
+
@ad_source_path = nil
|
39
|
+
@ad_target_path = nil
|
29
40
|
end
|
30
41
|
|
31
42
|
def finalize!
|
data/lib/vagrant-vmm/driver.rb
CHANGED
@@ -110,8 +110,10 @@ module VagrantPlugins
|
|
110
110
|
options = options || {}
|
111
111
|
ps_options = []
|
112
112
|
options.each do |key, value|
|
113
|
-
|
114
|
-
|
113
|
+
unless value.nil?
|
114
|
+
ps_options << "-#{key}"
|
115
|
+
ps_options << "'#{value}'"
|
116
|
+
end
|
115
117
|
end
|
116
118
|
|
117
119
|
# Always have a stop error action for failures
|
@@ -7,7 +7,10 @@ Param(
|
|
7
7
|
[string]$vm_template_name,
|
8
8
|
[Parameter(Mandatory=$true)]
|
9
9
|
[string]$vm_host_group_name,
|
10
|
-
[string]$proxy_server_address=$null
|
10
|
+
[string]$proxy_server_address=$null,
|
11
|
+
[string]$ad_server=$null,
|
12
|
+
[string]$ad_source_path=$null,
|
13
|
+
[string]$ad_target_path=$null
|
11
14
|
)
|
12
15
|
|
13
16
|
# Include the following modules
|
@@ -20,9 +23,11 @@ $script_block = {
|
|
20
23
|
# external vars
|
21
24
|
$vm_name = $using:vm_name
|
22
25
|
$vm_host_group_name = $using:vm_host_group_name
|
23
|
-
$vmm_credential = $using:vmm_credential
|
24
26
|
$server_address = $using:vmm_server_address
|
25
27
|
$vm_template_name = $using:vm_template_name
|
28
|
+
$ad_server = $using:ad_server
|
29
|
+
$ad_source_path = $using:ad_source_path
|
30
|
+
$ad_target_path = $using:ad_target_path
|
26
31
|
|
27
32
|
$description = "VM created by vagrant for testing purposes"
|
28
33
|
$MinFreeSpaceGB = 300 #
|
@@ -52,7 +57,6 @@ $script_block = {
|
|
52
57
|
DiskSpaceGB=$MinFreeSpaceGB;
|
53
58
|
VMName=$vm_name;
|
54
59
|
VMHostGroup=$VMHostGroup;
|
55
|
-
VMMServer=$vmmServer
|
56
60
|
}
|
57
61
|
|
58
62
|
$VMHost = $null
|
@@ -86,14 +90,37 @@ $script_block = {
|
|
86
90
|
DelayStartSeconds = $(Get-Random -Minimum 20 -Maximum 100)
|
87
91
|
}
|
88
92
|
|
89
|
-
New-SCVirtualMachine @vmCreateParams
|
93
|
+
$vm = New-SCVirtualMachine @vmCreateParams
|
90
94
|
} else {
|
91
95
|
Write-Error "Cannot find suitable host for the VM."
|
92
96
|
}
|
93
97
|
} else {
|
94
98
|
Write-Warning "Machine $vm_name already exists on host $($vm.VMHost.Name)"
|
95
|
-
$vm
|
96
99
|
}
|
100
|
+
# try to move it in AD
|
101
|
+
try
|
102
|
+
{
|
103
|
+
# move it to under AD path if required
|
104
|
+
if ($ad_target_path -ne $null -and $ad_source_path -ne $null -and $ad_server -ne $null)
|
105
|
+
{
|
106
|
+
$cred_param = @{}
|
107
|
+
if ($proxy_credential)
|
108
|
+
{
|
109
|
+
# if proxy used to overcome credssp auth
|
110
|
+
$cred_param["Credential"] = $proxy_credential
|
111
|
+
}
|
112
|
+
$ad_res = Get-ADComputer -Identity:"CN=$vm_name,$ad_source_path" -Server:$ad_server -ErrorAction Ignore @cred_param
|
113
|
+
if ( $ad_res -ne $null )
|
114
|
+
{
|
115
|
+
Move-ADObject -Identity:"CN=$vm_name,$ad_source_path" -TargetPath:$ad_target_path -Server:$ad_server @cred_param
|
116
|
+
}
|
117
|
+
}
|
118
|
+
} catch
|
119
|
+
{
|
120
|
+
Write-Warning "Couldn't move under specified OU: $_"
|
121
|
+
}
|
122
|
+
# return vm object
|
123
|
+
$vm
|
97
124
|
}
|
98
125
|
|
99
126
|
$vm = execute $script_block $vmm_server_address $proxy_server_address
|
@@ -17,6 +17,7 @@ Param(
|
|
17
17
|
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
18
18
|
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
|
19
19
|
. ([System.IO.Path]::Combine($Dir, "utils\manage_credentials.ps1"))
|
20
|
+
. ([System.IO.Path]::Combine($Dir, "utils\manage_trusted_hosts.ps1"))
|
20
21
|
|
21
22
|
# Sync flow:
|
22
23
|
# get list of files to sync, compare hashes with the remote ones
|
@@ -32,13 +33,7 @@ $delimiter = " || "
|
|
32
33
|
$creds_to_vm = Get-Creds $vm_address "Credentials for access to the VM ($vm_address) via WinRM" $winrm_vm_username $winrm_vm_password
|
33
34
|
|
34
35
|
# add to trusted hosts
|
35
|
-
|
36
|
-
if ( !$trusted_hosts.Value.Contains($vm_address) )
|
37
|
-
{
|
38
|
-
Write-host "Adding $vm_address to trusted host list"
|
39
|
-
$new_th_values = "$($trusted_hosts.Value),$vm_address"
|
40
|
-
set-item wsman:\localhost\Client\TrustedHosts $new_th_values -Force
|
41
|
-
}
|
36
|
+
Add-To-Trusted $vm_address
|
42
37
|
|
43
38
|
|
44
39
|
function Get-file-hash($source_paths, $delimiter) {
|
@@ -107,6 +102,7 @@ if (!$destination_files) {
|
|
107
102
|
$destination_files = @{}
|
108
103
|
}
|
109
104
|
|
105
|
+
$sync_required = $false
|
110
106
|
# compare hashes and derive what should be copied over and what removed
|
111
107
|
foreach ( $hst_path in $folder_mappings.Keys )
|
112
108
|
{
|
@@ -117,102 +113,109 @@ foreach ( $hst_path in $folder_mappings.Keys )
|
|
117
113
|
}
|
118
114
|
|
119
115
|
Compare-Object -ReferenceObject $source_files[$hst_path] -DifferenceObject $destination_files[$guest_path] | ForEach-Object {
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
116
|
+
$obj_path = $_.InputObject.Split($delimiter)[0]
|
117
|
+
if ($obj_path -and $obj_path.Trim())
|
118
|
+
{
|
119
|
+
# if not empty
|
120
|
+
if ($_.SideIndicator -eq '=>') {
|
121
|
+
$remove_files[$guest_path] += $obj_path
|
122
|
+
} else {
|
123
|
+
$copy_files[$hst_path] += $obj_path
|
124
|
+
}
|
125
|
+
$sync_required = $true
|
124
126
|
}
|
125
127
|
}
|
126
128
|
}
|
127
129
|
|
128
|
-
|
129
|
-
Invoke-Command -Session $(Get-session) -ScriptBlock {
|
130
|
-
$fileshare_dest = "$($env:SystemDrive)\vagrant-sync"
|
131
|
-
if (Test-path $fileshare_dest)
|
132
|
-
{
|
133
|
-
Remove-item "$fileshare_dest\*" -recurse -force
|
134
|
-
} else {
|
135
|
-
$sync_dir = New-item $fileshare_dest -itemtype directory
|
136
|
-
}
|
137
|
-
$shr = Get-SmbShare -Name "vagrant-sync" -ErrorAction Ignore
|
138
|
-
if ( $shr -eq $null )
|
139
|
-
{
|
140
|
-
Write-host "$(&hostname) :: Creating fileshare on the remote host in $fileshare_dest, granting access to $($env:USERDOMAIN)\$($env:USERNAME)"
|
141
|
-
$shr = New-SmbShare -Name "vagrant-sync" -Temporary -Path $fileshare_dest -FullAccess "$($env:USERDOMAIN)\$($env:USERNAME)"
|
142
|
-
}
|
143
|
-
}
|
144
|
-
|
145
|
-
# get access to the fileshare from the current machine
|
146
|
-
Write-host "Getting access from the current machine to the created fileshare (\\$vm_address\vagrant-sync)"
|
147
|
-
$vagrant_sync_drive = New-PSDrive -Name 'V' -PSProvider 'FileSystem' -Root "\\$vm_address\vagrant-sync" -Credential $creds_to_vm
|
148
|
-
|
149
|
-
Write-host "Syncing files to fileshare..."
|
150
|
-
foreach ( $hst_path in $copy_files.Keys)
|
130
|
+
if ( $sync_required )
|
151
131
|
{
|
152
|
-
|
153
|
-
$
|
154
|
-
|
155
|
-
|
156
|
-
{
|
157
|
-
$current += 1
|
158
|
-
$file_path = $hst_path + $file
|
159
|
-
$guest_path = $folder_mappings[$hst_path]
|
160
|
-
$guest_path = [System.IO.Path]::GetFullPath("$($vagrant_sync_drive.root)\$guest_path")
|
161
|
-
Write-progress -Activity "Syncing $hst_path with $guest_path" -PercentComplete $($current*100/$total) -Status "Copying $file"
|
162
|
-
if (Test-Path $file_path -pathtype container)
|
132
|
+
# create file share on the remote machine
|
133
|
+
Invoke-Command -Session $(Get-session) -ScriptBlock {
|
134
|
+
$fileshare_dest = "$($env:SystemDrive)\vagrant-sync"
|
135
|
+
if (Test-path $fileshare_dest)
|
163
136
|
{
|
164
|
-
|
165
|
-
$out = New-Item $file_path -itemtype directory -ErrorAction Ignore
|
137
|
+
Remove-item "$fileshare_dest\*" -recurse -force
|
166
138
|
} else {
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
139
|
+
$sync_dir = New-item $fileshare_dest -itemtype directory
|
140
|
+
}
|
141
|
+
$shr = Get-SmbShare -Name "vagrant-sync" -ErrorAction Ignore
|
142
|
+
if ( $shr -eq $null )
|
143
|
+
{
|
144
|
+
Write-host "$(&hostname) :: Creating fileshare on the remote host in $fileshare_dest, granting access to $($env:USERDOMAIN)\$($env:USERNAME)"
|
145
|
+
$shr = New-SmbShare -Name "vagrant-sync" -Temporary -Path $fileshare_dest -FullAccess "$($env:USERDOMAIN)\$($env:USERNAME)"
|
171
146
|
}
|
172
147
|
}
|
173
|
-
}
|
174
148
|
|
175
|
-
#
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
# remove files
|
182
|
-
$total = $remove_files.Keys.Count
|
183
|
-
$current = 0
|
184
|
-
foreach ( $g_path in $remove_files.Keys )
|
149
|
+
# get access to the fileshare from the current machine
|
150
|
+
Write-host "Getting access from the current machine to the created fileshare (\\$vm_address\vagrant-sync)"
|
151
|
+
$vagrant_sync_drive = New-PSDrive -Name 'V' -PSProvider 'FileSystem' -Root "\\$vm_address\vagrant-sync" -Credential $creds_to_vm
|
152
|
+
|
153
|
+
Write-host "Syncing files to fileshare..."
|
154
|
+
foreach ( $hst_path in $copy_files.Keys)
|
185
155
|
{
|
186
|
-
$current
|
187
|
-
|
188
|
-
|
156
|
+
$current = 0
|
157
|
+
$total = $copy_files[$hst_path].Count
|
158
|
+
# copy files to the fileshare
|
159
|
+
foreach( $file in $copy_files[$hst_path] )
|
189
160
|
{
|
190
|
-
|
161
|
+
$current += 1
|
162
|
+
$file_path = $hst_path + $file
|
163
|
+
$guest_path = $folder_mappings[$hst_path]
|
164
|
+
$guest_path = [System.IO.Path]::GetFullPath("$($vagrant_sync_drive.root)\$guest_path")
|
165
|
+
Write-progress -Activity "Syncing $hst_path with $guest_path" -PercentComplete $($current*100/$total) -Status "Copying $file"
|
166
|
+
if (Test-Path $file_path -pathtype container)
|
167
|
+
{
|
168
|
+
# folder
|
169
|
+
$out = New-Item $file_path -itemtype directory -ErrorAction Ignore
|
170
|
+
} else {
|
171
|
+
# file
|
172
|
+
$file_dir = split-path $file
|
173
|
+
$out = New-item "$guest_path\$file_dir" -itemtype directory -ErrorAction Ignore
|
174
|
+
Copy-Item $file_path "$guest_path\$file" -recurse
|
175
|
+
}
|
191
176
|
}
|
192
177
|
}
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
$
|
200
|
-
|
201
|
-
|
178
|
+
|
179
|
+
# copy from fileshare to the dest locations on the remote machine
|
180
|
+
# as well as remove files that shouldn't be there
|
181
|
+
Invoke-Command -Session $(Get-session) -ScriptBlock {
|
182
|
+
$remove_files = $using:remove_files
|
183
|
+
$fileshare_dest = "$($env:SystemDrive)\vagrant-sync"
|
184
|
+
write-host "$(&hostname) :: Distributing files from $fileshare_dest..."
|
185
|
+
# remove files
|
186
|
+
$total = $remove_files.Keys.Count
|
187
|
+
$current = 0
|
188
|
+
foreach ( $g_path in $remove_files.Keys )
|
189
|
+
{
|
190
|
+
$current += 1
|
191
|
+
Write-progress -Activity "Cleaning redundant files" -PercentComplete $($current*100/$total) -Status "Cleaning under: $g_path"
|
192
|
+
foreach ($r_file in $remove_files[$g_path])
|
193
|
+
{
|
194
|
+
Remove-Item $($g_path+$r_file) -recurse -force -ErrorAction Ignore
|
195
|
+
}
|
196
|
+
}
|
197
|
+
$root_files_in_share = Get-ChildItem $fileshare_dest -Directory -ErrorAction Ignore
|
198
|
+
$total = $root_files_in_share.Count
|
199
|
+
$current = 0
|
200
|
+
#TODO: remove hard-code to SystemDrive
|
201
|
+
foreach ( $guest_path in $root_files_in_share )
|
202
|
+
{
|
203
|
+
$current += 1
|
204
|
+
Write-progress -Activity "Distributing files on the remote machine" -PercentComplete $($current*100/$total) -Status "Copying: $guest_path"
|
205
|
+
Copy-Item "$fileshare_dest\$guest_path" "$($env:SystemDrive)\" -recurse -force
|
206
|
+
}
|
202
207
|
}
|
208
|
+
} else # if there are something to copy or remove
|
209
|
+
{
|
210
|
+
Write-host "Skipping sync as there are nothing to sync."
|
203
211
|
}
|
204
212
|
|
205
|
-
|
213
|
+
# close session
|
206
214
|
Remove-PSSession -Id $session.Id
|
207
215
|
|
208
216
|
# remove vm_address from trusted hosts
|
209
|
-
|
210
|
-
|
211
|
-
{
|
212
|
-
Write-host "Removing $vm_address from trusted host list"
|
213
|
-
$new_th_values = $trusted_hosts.Value -replace ",?$vm_address", ""
|
214
|
-
set-item wsman:\localhost\Client\TrustedHosts $new_th_values -Force
|
215
|
-
}
|
217
|
+
Remove-From-Trusted $vm_address
|
218
|
+
|
216
219
|
|
217
220
|
$resultHash = $folder_mappings
|
218
221
|
$result = ConvertTo-Json $resultHash
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
# add $address to trusted host list
|
3
|
+
function Add-To-Trusted($address)
|
4
|
+
{
|
5
|
+
$trusted_hosts = get-item wsman:\localhost\Client\TrustedHosts
|
6
|
+
if ( $address -as [ipaddress] -and !$trusted_hosts.Value.Contains($address) )
|
7
|
+
{
|
8
|
+
$new_th_values = "$($trusted_hosts.Value),$address"
|
9
|
+
set-item wsman:\localhost\Client\TrustedHosts $new_th_values -Force
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
# remove $address from trusted host list
|
14
|
+
function Remove-From-Trusted($address)
|
15
|
+
{
|
16
|
+
# remove $address from trusted hosts
|
17
|
+
$trusted_hosts = get-item wsman:\localhost\Client\TrustedHosts
|
18
|
+
if ( $trusted_hosts.Value.Contains($address) )
|
19
|
+
{
|
20
|
+
$new_th_values = $trusted_hosts.Value -replace ",?$address", ""
|
21
|
+
set-item wsman:\localhost\Client\TrustedHosts $new_th_values -Force
|
22
|
+
}
|
23
|
+
}
|
@@ -1,30 +1,42 @@
|
|
1
1
|
#
|
2
2
|
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
3
3
|
. ([System.IO.Path]::Combine($Dir, "manage_credentials.ps1"))
|
4
|
+
. ([System.IO.Path]::Combine($Dir, "manage_trusted_hosts.ps1"))
|
4
5
|
|
5
6
|
# execute script block for VMM
|
6
7
|
function execute($block, $vmm_server_address, $proxy_server_address)
|
7
8
|
{
|
8
9
|
$vmm_credential = Get-Creds $vmm_server_address "Credentials for VMM server: $vmm_server_address"
|
10
|
+
$proxy_credential = $null
|
11
|
+
|
12
|
+
if ($proxy_server_address -ne $null )
|
13
|
+
{
|
14
|
+
$proxy_credential = Get-Creds $proxy_server_address "Credentials for proxy server: $proxy_server_address"
|
15
|
+
}
|
9
16
|
#
|
10
17
|
$init_vmm_block = {
|
11
18
|
try {
|
12
19
|
ipmo 'C:\Program Files\Microsoft System Center 2012 R2\Virtual Machine Manager\bin\psModules\virtualmachinemanager'
|
13
|
-
} catch
|
20
|
+
} catch
|
21
|
+
{
|
14
22
|
write-error 'You need to install Virtual Machine Manager R2 client first.'
|
15
23
|
throw $_.Exception
|
16
24
|
}
|
17
25
|
#
|
18
|
-
$
|
26
|
+
$proxy_credential = $using:proxy_credential # make those available within $block as well
|
27
|
+
$vmm_server = Get-VMMServer -ComputerName $using:vmm_server_address -Credential $using:vmm_credential
|
19
28
|
}
|
29
|
+
# prepend init block to execution block
|
20
30
|
$block_to_run = [ScriptBlock]::Create($init_vmm_block.ToString() + $block.ToString())
|
21
31
|
#
|
22
32
|
if ( $proxy_server_address -eq $null )
|
23
33
|
{
|
24
34
|
$res = $(Start-Job $block_to_run | Wait-Job | Receive-Job)
|
25
|
-
} else
|
26
|
-
|
35
|
+
} else
|
36
|
+
{
|
37
|
+
Add-To-Trusted $proxy_server_address
|
27
38
|
$res = invoke-command -ComputerName $proxy_server_address -Credential $proxy_credential -ScriptBlock $block_to_run
|
39
|
+
Remove-From-Trusted $proxy_server_address
|
28
40
|
}
|
29
41
|
return $res
|
30
42
|
}
|
@@ -57,7 +57,7 @@ module VagrantPlugins
|
|
57
57
|
# escape quotes
|
58
58
|
options[:folders_to_sync] = options[:folders_to_sync].to_json.gsub('"','\\"')
|
59
59
|
res = machine.provider.driver.sync_folders(options)
|
60
|
-
machine.ui.detail("
|
60
|
+
machine.ui.detail("Synced finished.")
|
61
61
|
end
|
62
62
|
|
63
63
|
# This is called to remove the synced folders from a running
|
data/lib/vagrant-vmm/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -9,25 +9,18 @@ en:
|
|
9
9
|
|
10
10
|
errors:
|
11
11
|
admin_required: |-
|
12
|
-
The
|
13
|
-
administrative privileges.
|
14
|
-
Hyper-V requires administrative privileges for management
|
15
|
-
commands. Please restart your console with administrative
|
12
|
+
The VMM provider requires that Vagrant be run with
|
13
|
+
administrative privileges. Please restart your console with administrative
|
16
14
|
privileges and try again.
|
17
15
|
ip_addr_timeout: |-
|
18
|
-
|
16
|
+
VMM failed to determine your machine's IP address within the
|
19
17
|
configured timeout. Please verify the machine properly booted and
|
20
|
-
the network works. To do this, open the
|
18
|
+
the network works. To do this, open the VMM manager, find your
|
21
19
|
virtual machine, and connect to it.
|
22
20
|
|
23
|
-
The most common cause for this error is that the running virtual
|
24
|
-
machine doesn't have the latest Hyper-V integration drivers. Please
|
25
|
-
research for your operating system how to install these in order
|
26
|
-
for the VM to properly communicate its IP address to Hyper-V.
|
27
21
|
powershell_features_disabled: |-
|
28
|
-
The
|
29
|
-
requires these to control
|
30
|
-
"Windows Features" control panel and try again.
|
22
|
+
The VMM cmdlets for PowerShell are not available! Vagrant
|
23
|
+
requires these to control VMM.
|
31
24
|
powershell_error: |-
|
32
25
|
An error occurred while executing a PowerShell script. This error
|
33
26
|
is shown below. Please read the error message and see if this is
|
@@ -39,8 +32,8 @@ en:
|
|
39
32
|
|
40
33
|
%{stderr}
|
41
34
|
powershell_required: |-
|
42
|
-
The Vagrant
|
35
|
+
The Vagrant VMM provider requires PowerShell to be available.
|
43
36
|
Please make sure "powershell.exe" is available on your PATH.
|
44
37
|
windows_required: |-
|
45
|
-
The
|
38
|
+
The VMM provider only works on Windows. Please try to
|
46
39
|
use another provider.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-vmm
|
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
|
- jarig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/vagrant-vmm/scripts/suspend_vm.ps1
|
83
83
|
- lib/vagrant-vmm/scripts/sync_folders.ps1
|
84
84
|
- lib/vagrant-vmm/scripts/utils/manage_credentials.ps1
|
85
|
+
- lib/vagrant-vmm/scripts/utils/manage_trusted_hosts.ps1
|
85
86
|
- lib/vagrant-vmm/scripts/utils/vmm_executor.ps1
|
86
87
|
- lib/vagrant-vmm/scripts/utils/write_messages.ps1
|
87
88
|
- lib/vagrant-vmm/synced_folder.rb
|