vagrant-vmm 1.0.10 → 1.0.11

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzU5Y2Q3OGY4MzYzNzlhNmVhZThkY2FlMzk4MjJiNDMxZjc4YTE1Yw==
4
+ ZjhmNmQ4N2YwMmFjNmQyYjdlOWRlZTQ1MzFlMmRmZDY4MTAxYzViNw==
5
5
  data.tar.gz: !binary |-
6
- MTE2ZmQwZWVjYWM5MTI5NDEzMWZkOTA2M2JlNzUyY2ZkZjcxNDUxYw==
6
+ YWJjNTZmZDZmZjI3YTA1MGMxNmJmYjRkZWQ3NDcwYTQ4YjllMGM1OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzBhM2RlYjVhZjAwMjE2Y2ZmZjNhMjMzYmM4ODFjNGNjMmZiYzQ4MDU4YmIw
10
- N2FhMDc5OGYyYjExMWEyMjcxMmFlZGFlMTYzNzNhMDJmODNmOTYzNzdmYTMz
11
- NjMwNWEwNDNhNTljYzdhZTY3ZGZhNTJjZDk4OWYzYjNlN2EyYWU=
9
+ YWJiYjBlYjhkN2RlZTllMzM3YTNjMzAzMDIzOWZhMDk4NDFjNWE4ZGRhOWU5
10
+ YzcyODBhYTMyMjY3ZjA1MGU2YmExYjQ3MGZjNzk4NjQ4MjBmZGZiNDNlYzA4
11
+ NmRhZGMwMDE2MWMyNzc5MzY0MDk0ZWYwMzQzMGEyZmI3NDcwODU=
12
12
  data.tar.gz: !binary |-
13
- MGMwNWRhMDJjNDgxYWQ3OWUzYmE5YjAxM2UyNzc2ODgyZjFiZDE5MDk0MTJm
14
- YTAzNDI0ZmNlMDUxMmYzMDgyY2VlMTExYjNhOWMxMmRjNDZjMzgzMjFjMDBj
15
- OWViYTJlYmFmYWY4MzBkZDM3YWJiMDNjNWFkMjY0NGM0YWU0NjQ=
13
+ NzY4YzZhMDA2NmFjMTAyYzcxOTQ5N2UxODczMmU5MWEyNGU5MzVjN2E3M2Q4
14
+ OTEzYTkxYTYxZmMxZDhlYmM5ZWVkMmRmMWIwYTVjZDM3ODRlODlmNGYwZWUy
15
+ NGMyMGE5ZmFlMjExNTAxYzdmNjUxNWVhYmYzMGI2NmNmNDdhYzc=
data/README.md CHANGED
@@ -10,7 +10,7 @@ This provider will allow you to create VMs in the remote Virtual Machine Manager
10
10
 
11
11
  ## Installation
12
12
 
13
- Install Vagrant 1.7.1
13
+ Install Vagrant 1.7.4
14
14
  ```
15
15
  http://www.vagrantup.com/downloads.html
16
16
  ```
@@ -47,7 +47,7 @@ win64_config.vm.guest = :windows
47
47
 
48
48
  Set communicator to **:winrm**
49
49
  ```
50
- win64_config.vm.communicator = "winrm"
50
+ win64_config.vm.communicator = :winrm
51
51
  ```
52
52
 
53
53
  Set you provider to :vmm and specify at least *vmm_server_address*, *vm_host_group_name* and *vm_template_name* parameters.
@@ -18,6 +18,7 @@ $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
20
  . ([System.IO.Path]::Combine($Dir, "utils\manage_trusted_hosts.ps1"))
21
+ . ([System.IO.Path]::Combine($Dir, "utils\send_file.ps1"))
21
22
 
22
23
  # Sync flow:
23
24
  # get list of files to sync, compare hashes with the remote ones
@@ -131,7 +132,7 @@ foreach ( $hst_path in $folder_mappings.Keys )
131
132
  if ( $sync_required )
132
133
  {
133
134
  # create file share on the remote machine
134
- Invoke-Command -Session $(Get-session) -ScriptBlock {
135
+ $fileshare_dest = Invoke-Command -Session $(Get-session) -ScriptBlock {
135
136
  $fileshare_dest = "$($env:SystemDrive)\vagrant-sync"
136
137
  if (Test-path $fileshare_dest)
137
138
  {
@@ -139,20 +140,14 @@ if ( $sync_required )
139
140
  } else {
140
141
  $sync_dir = New-item $fileshare_dest -itemtype directory
141
142
  }
142
- $shr = Get-SmbShare -Name "vagrant-sync" -ErrorAction Ignore
143
- if ( $shr -eq $null )
144
- {
145
- Write-host "$(&hostname) :: Creating fileshare on the remote host in $fileshare_dest, granting access to Everyone"
146
- $shr = New-SmbShare -Name "vagrant-sync" -Temporary -Path $fileshare_dest
147
- }
148
- $g_info = Grant-SmbShareAccess -InputObject $shr -AccountName "$($env:USERDOMAIN)\$($env:USERNAME)" -AccessRight Full -Force
143
+ return $fileshare_dest
149
144
  }
150
145
 
151
146
  # get access to the fileshare from the current machine
152
- Write-host "Getting access from the current machine to the created fileshare (\\$vm_address\vagrant-sync)"
153
- $vagrant_sync_drive = New-PSDrive -Name 'V' -PSProvider 'FileSystem' -Root "\\$vm_address\vagrant-sync" -Credential $creds_to_vm
147
+ Write-host "Prepared folder on $vm_address : $fileshare_dest"
154
148
 
155
149
  Write-host "Syncing files to fileshare..."
150
+ $session = $(Get-session)
156
151
  foreach ( $hst_path in $copy_files.Keys )
157
152
  {
158
153
  $current = 0
@@ -163,24 +158,23 @@ if ( $sync_required )
163
158
  $current += 1
164
159
  $file_path = $hst_path + $file
165
160
  $guest_path = Split-Path $folder_mappings[$hst_path] -NoQualifier
166
- $guest_path = [System.IO.Path]::GetFullPath("$($vagrant_sync_drive.root)\$guest_path")
167
- Write-progress -Activity "Syncing $hst_path with $guest_path" -PercentComplete $($current*100/$total) -Status "Copying $file"
161
+ $guest_path = [System.IO.Path]::GetFullPath("$fileshare_dest\$guest_path")
162
+ Write-progress -Activity "Syncing $hst_path with $vm_address :: $guest_path" -PercentComplete $($current*100/$total) -Status "Copying $file"
168
163
  if (Test-Path $file_path -pathtype container)
169
164
  {
170
165
  # folder
171
- $out = New-Item $file_path -itemtype directory -ErrorAction Ignore
166
+ #$out = New-Item $file_path -itemtype directory -ErrorAction Ignore
172
167
  } else {
173
168
  # file
174
169
  $file_dir = split-path $file
175
- $out = New-item "$guest_path\$file_dir" -itemtype directory -ErrorAction Ignore
176
- Copy-Item $file_path "$guest_path\$file" -recurse
170
+ Send-File $file_path "$guest_path\$file_dir" $session
177
171
  }
178
172
  }
179
173
  }
180
174
 
181
175
  # copy from fileshare to the dest locations on the remote machine
182
176
  # as well as remove files that shouldn't be there
183
- Invoke-Command -Session $(Get-session) -ScriptBlock {
177
+ Invoke-Command -Session $session -ScriptBlock {
184
178
  $remove_files = $using:remove_files
185
179
  $fileshare_dest = "$($env:SystemDrive)\vagrant-sync"
186
180
  write-host "$(&hostname) :: Distributing files from $fileshare_dest..."
@@ -0,0 +1,141 @@
1
+ function Send-File
2
+ {
3
+ <#
4
+ .SYNOPSIS
5
+ This function sends a file (or folder of files recursively) to a destination WinRm session. This function was originally
6
+ built by Lee Holmes (http://poshcode.org/2216) but has been modified to recursively send folders of files as well
7
+ as to support UNC paths.
8
+
9
+ .PARAMETER Path
10
+ The local or UNC folder path that you'd like to copy to the session. This also support multiple paths in a comma-delimited format.
11
+ If this is a UNC path, it will be copied locally to accomodate copying. If it's a folder, it will recursively copy
12
+ all files and folders to the destination.
13
+
14
+ .PARAMETER Destination
15
+ The local path on the remote computer where you'd like to copy the folder or file. If the folder does not exist on the remote
16
+ computer it will be created.
17
+
18
+ .PARAMETER Session
19
+ The remote session. Create with New-PSSession.
20
+
21
+ .EXAMPLE
22
+ $session = New-PSSession -ComputerName MYSERVER
23
+ Send-File -Path C:\test.txt -Destination C:\ -Session $session
24
+
25
+ This example will copy the file C:\test.txt to be C:\test.txt on the computer MYSERVER
26
+
27
+ .INPUTS
28
+ None. This function does not accept pipeline input.
29
+
30
+ .OUTPUTS
31
+ System.IO.FileInfo
32
+ #>
33
+ [CmdletBinding()]
34
+ param
35
+ (
36
+ [Parameter(Mandatory)]
37
+ [ValidateNotNullOrEmpty()]
38
+ [string[]]$Path,
39
+
40
+ [Parameter(Mandatory)]
41
+ [ValidateNotNullOrEmpty()]
42
+ [string]$Destination,
43
+
44
+ [Parameter(Mandatory)]
45
+ [System.Management.Automation.Runspaces.PSSession]$Session
46
+ )
47
+ process
48
+ {
49
+ foreach ($p in $Path)
50
+ {
51
+ try
52
+ {
53
+ if ($p.StartsWith('\\'))
54
+ {
55
+ Write-Verbose -Message "[$($p)] is a UNC path. Copying locally first"
56
+ Copy-Item -Path $p -Destination ([environment]::GetEnvironmentVariable('TEMP', 'Machine'))
57
+ $p = "$([environment]::GetEnvironmentVariable('TEMP', 'Machine'))\$($p | Split-Path -Leaf)"
58
+ }
59
+ if (Test-Path -Path $p -PathType Container)
60
+ {
61
+ Write-Verbose -Message "[$($p)] is a folder. Sending all files"
62
+ $files = Get-ChildItem -Path $p -File -Recurse
63
+ $sendFileParamColl = @()
64
+ foreach ($file in $Files)
65
+ {
66
+ $sendParams = @{
67
+ 'Session' = $Session
68
+ 'Path' = $file.FullName
69
+ }
70
+ if ($file.DirectoryName -ne $p) ## It's a subdirectory
71
+ {
72
+ $subdirpath = $file.DirectoryName.Replace("$p\", '')
73
+ $sendParams.Destination = "$Destination\$subDirPath"
74
+ }
75
+ else
76
+ {
77
+ $sendParams.Destination = $Destination
78
+ }
79
+ $sendFileParamColl += $sendParams
80
+ }
81
+ foreach ($paramBlock in $sendFileParamColl)
82
+ {
83
+ Send-File @paramBlock
84
+ }
85
+ }
86
+ else
87
+ {
88
+ Write-Verbose -Message "Starting WinRM copy of [$($p)] to [$($Destination)]"
89
+ # Get the source file, and then get its contents
90
+ $sourceBytes = [System.IO.File]::ReadAllBytes($p);
91
+ $streamChunks = @();
92
+
93
+ # Now break it into chunks to stream.
94
+ $streamSize = 1MB;
95
+ for ($position = 0; $position -lt $sourceBytes.Length; $position += $streamSize)
96
+ {
97
+ $remaining = $sourceBytes.Length - $position
98
+ $remaining = [Math]::Min($remaining, $streamSize)
99
+
100
+ $nextChunk = New-Object byte[] $remaining
101
+ [Array]::Copy($sourcebytes, $position, $nextChunk, 0, $remaining)
102
+ $streamChunks +=, $nextChunk
103
+ }
104
+ $remoteScript = {
105
+ if (-not (Test-Path -Path $using:Destination -PathType Container))
106
+ {
107
+ $null = New-Item -Path $using:Destination -Type Directory -Force
108
+ }
109
+ $fileDest = "$using:Destination\$($using:p | Split-Path -Leaf)"
110
+ ## Create a new array to hold the file content
111
+ $destBytes = New-Object byte[] $using:length
112
+ $position = 0
113
+
114
+ ## Go through the input, and fill in the new array of file content
115
+ foreach ($chunk in $input)
116
+ {
117
+ [GC]::Collect()
118
+ [Array]::Copy($chunk, 0, $destBytes, $position, $chunk.Length)
119
+ $position += $chunk.Length
120
+ }
121
+
122
+ [IO.File]::WriteAllBytes($fileDest, $destBytes)
123
+
124
+ #Get-Item $fileDest
125
+ [GC]::Collect()
126
+ }
127
+
128
+ # Stream the chunks into the remote script.
129
+ $Length = $sourceBytes.Length
130
+ $streamChunks | Invoke-Command -Session $Session -ScriptBlock $remoteScript
131
+ Write-Verbose -Message "WinRM copy of [$($p)] to [$($Destination)] complete"
132
+ }
133
+ }
134
+ catch
135
+ {
136
+ Write-Error $_.Exception.Message
137
+ }
138
+ }
139
+ }
140
+
141
+ }
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VMM
3
- VERSION = "1.0.10"
3
+ VERSION = "1.0.11"
4
4
  end
5
5
  end
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.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - jarig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-05 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,6 +83,7 @@ files:
83
83
  - lib/vagrant-vmm/scripts/sync_folders.ps1
84
84
  - lib/vagrant-vmm/scripts/utils/manage_credentials.ps1
85
85
  - lib/vagrant-vmm/scripts/utils/manage_trusted_hosts.ps1
86
+ - lib/vagrant-vmm/scripts/utils/send_file.ps1
86
87
  - lib/vagrant-vmm/scripts/utils/vmm_executor.ps1
87
88
  - lib/vagrant-vmm/scripts/utils/write_messages.ps1
88
89
  - lib/vagrant-vmm/synced_folder.rb