vagrant-azure 1.0.5 → 1.1.0
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/.gitignore +19 -15
- data/CHANGELOG.md +24 -24
- data/Gemfile +20 -15
- data/LICENSE +4 -4
- data/README.md +189 -125
- data/Rakefile +15 -14
- data/lib/vagrant-azure.rb +31 -33
- data/lib/vagrant-azure/action.rb +267 -243
- data/lib/vagrant-azure/action/connect_azure.rb +49 -46
- data/lib/vagrant-azure/action/os_type.rb +34 -0
- data/lib/vagrant-azure/action/powershell_run.rb +28 -0
- data/lib/vagrant-azure/action/provision.rb +42 -49
- data/lib/vagrant-azure/action/rdp.rb +63 -62
- data/lib/vagrant-azure/action/read_ssh_info.rb +54 -51
- data/lib/vagrant-azure/action/read_state.rb +47 -46
- data/lib/vagrant-azure/action/read_winrm_info.rb +57 -0
- data/lib/vagrant-azure/action/restart_vm.rb +28 -27
- data/lib/vagrant-azure/action/run_instance.rb +123 -115
- data/lib/vagrant-azure/action/start_instance.rb +35 -35
- data/lib/vagrant-azure/action/stop_instance.rb +42 -38
- data/lib/vagrant-azure/action/sync_folders.rb +64 -63
- data/lib/vagrant-azure/action/terminate_instance.rb +34 -34
- data/lib/vagrant-azure/action/vagrant_azure_service.rb +44 -43
- data/lib/vagrant-azure/action/wait_for_communicate.rb +39 -38
- data/lib/vagrant-azure/action/wait_for_state.rb +50 -49
- data/lib/vagrant-azure/capabilities/winrm.rb +12 -0
- data/lib/vagrant-azure/command/powershell.rb +43 -0
- data/lib/vagrant-azure/command/rdp.rb +24 -0
- data/lib/vagrant-azure/config.rb +158 -147
- data/lib/vagrant-azure/driver.rb +48 -84
- data/lib/vagrant-azure/errors.rb +28 -27
- data/lib/vagrant-azure/monkey_patch/azure.rb +46 -0
- data/lib/vagrant-azure/monkey_patch/winrm.rb +77 -0
- data/lib/vagrant-azure/plugin.rb +102 -91
- data/lib/vagrant-azure/provider.rb +74 -70
- data/lib/vagrant-azure/provisioner/chef-solo.rb +178 -177
- data/lib/vagrant-azure/provisioner/puppet.rb +116 -115
- data/lib/vagrant-azure/version.rb +11 -10
- data/locales/en.yml +37 -37
- data/templates/provisioners/chef-solo/solo.erb +51 -51
- data/vagrant-azure.gemspec +59 -58
- metadata +48 -38
- data/lib/vagrant-azure/command/rdp/command.rb +0 -21
- data/lib/vagrant-azure/communication/powershell.rb +0 -41
- data/lib/vagrant-azure/monkey_patch/machine.rb +0 -22
- data/lib/vagrant-azure/provisioner/shell.rb +0 -83
- data/lib/vagrant-azure/scripts/check_winrm.ps1 +0 -47
- data/lib/vagrant-azure/scripts/export_vm.ps1 +0 -31
- data/lib/vagrant-azure/scripts/file_sync.ps1 +0 -145
- data/lib/vagrant-azure/scripts/host_info.ps1 +0 -25
- data/lib/vagrant-azure/scripts/hyperv_manager.ps1 +0 -36
- data/lib/vagrant-azure/scripts/run_in_remote.ps1 +0 -32
- data/lib/vagrant-azure/scripts/upload_file.ps1 +0 -95
- data/lib/vagrant-azure/scripts/utils/create_session.ps1 +0 -34
- data/lib/vagrant-azure/scripts/utils/write_messages.ps1 +0 -18
@@ -1,32 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved. Licensed under the Apache 2.0 License.
|
4
|
-
#--------------------------------------------------------------------------
|
5
|
-
|
6
|
-
param (
|
7
|
-
[string]$guest_ip = $(throw "-guest_ip is required."),
|
8
|
-
[string]$guest_port = $(throw "-guest_port is required."),
|
9
|
-
[string]$username = $(throw "-guest_username is required."),
|
10
|
-
[string]$password = $(throw "-guest_password is required."),
|
11
|
-
[string]$command = ""
|
12
|
-
)
|
13
|
-
|
14
|
-
# Include the following modules
|
15
|
-
$presentDir = Split-Path -parent $PSCommandPath
|
16
|
-
. ([System.IO.Path]::Combine($presentDir, "utils\write_messages.ps1"))
|
17
|
-
. ([System.IO.Path]::Combine($presentDir, "utils\create_session.ps1"))
|
18
|
-
|
19
|
-
try {
|
20
|
-
$response = Create-Remote-Session $guest_ip $guest_port $username $password
|
21
|
-
if (!$response["session"] -and $response["error"]) {
|
22
|
-
Write-Host $response["error"]
|
23
|
-
return
|
24
|
-
}
|
25
|
-
function Remote-Execute($command) {
|
26
|
-
cmd /c $command
|
27
|
-
}
|
28
|
-
Invoke-Command -Session $response["session"] -ScriptBlock ${function:Remote-Execute} -ArgumentList $command -ErrorAction "stop"
|
29
|
-
} catch {
|
30
|
-
Write-Host $_
|
31
|
-
return
|
32
|
-
}
|
@@ -1,95 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved. Licensed under the Apache 2.0 License.
|
4
|
-
#--------------------------------------------------------------------------
|
5
|
-
|
6
|
-
param (
|
7
|
-
[string]$host_path = $(throw "-host_path is required."),
|
8
|
-
[string]$guest_path = $(throw "-guest_path is required."),
|
9
|
-
[string]$guest_ip = $(throw "-guest_ip is required."),
|
10
|
-
[string]$guest_port = $(throw "-guest_port is required."),
|
11
|
-
[string]$username = $(throw "-guest_username is required."),
|
12
|
-
[string]$password = $(throw "-guest_password is required.")
|
13
|
-
)
|
14
|
-
|
15
|
-
# Include the following modules
|
16
|
-
$presentDir = Split-Path -parent $PSCommandPath
|
17
|
-
. ([System.IO.Path]::Combine($presentDir, "utils\write_messages.ps1"))
|
18
|
-
. ([System.IO.Path]::Combine($presentDir, "utils\create_session.ps1"))
|
19
|
-
|
20
|
-
try {
|
21
|
-
function Copy-File-To-VM($path, $content) {
|
22
|
-
if (!(Test-Path $path)) {
|
23
|
-
$folder = Split-Path $path
|
24
|
-
New-Item $folder -type directory -Force
|
25
|
-
}
|
26
|
-
|
27
|
-
[IO.File]::WriteAllBytes($path, $content)
|
28
|
-
}
|
29
|
-
|
30
|
-
function Upload-FIle-To-VM($host_path, $guest_path, $session) {
|
31
|
-
$contents = [IO.File]::ReadAllBytes($host_path)
|
32
|
-
Invoke-Command -Session $session -ScriptBlock ${function:Copy-File-To-VM} -ArgumentList $guest_path,$contents
|
33
|
-
}
|
34
|
-
|
35
|
-
function Prepare-Guest-Folder($session) {
|
36
|
-
# Create the guest folder if not exist
|
37
|
-
$result = Invoke-Command -Session $session -ScriptBlock ${function:Create-Guest-Folder} -ArgumentList $guest_path
|
38
|
-
}
|
39
|
-
|
40
|
-
function Create-Guest-Folder($guest_path) {
|
41
|
-
try {
|
42
|
-
if (Test-Path $guest_path) {
|
43
|
-
# First attempt to remove a Junction drive. The fall back to removing a
|
44
|
-
# folder
|
45
|
-
$junction = Get-Item $guest_path
|
46
|
-
$junction.Delete()
|
47
|
-
}
|
48
|
-
}
|
49
|
-
# Catch any [IOException]
|
50
|
-
catch {
|
51
|
-
Remove-Item "$guest_path" -Force -Recurse
|
52
|
-
}
|
53
|
-
New-Item "$guest_path" -type directory -Force
|
54
|
-
}
|
55
|
-
|
56
|
-
$response = Create-Remote-Session $guest_ip $guest_port $username $password
|
57
|
-
if (!$response["session"] -and $response["error"]) {
|
58
|
-
$errortHash = @{
|
59
|
-
type = "PowerShellError"
|
60
|
-
error = $response["error"]
|
61
|
-
}
|
62
|
-
Write-Error-Message $errortHash
|
63
|
-
return
|
64
|
-
}
|
65
|
-
$session = $response["session"]
|
66
|
-
|
67
|
-
# When Host path is a folder.
|
68
|
-
# Find all files within it and copy to the Guest
|
69
|
-
if (Test-Path $host_path -pathtype container) {
|
70
|
-
# Open a remote PS Session with the guest
|
71
|
-
Prepare-Guest-Folder $session
|
72
|
-
# Copy all files from Host path to Guest Path
|
73
|
-
Get-ChildItem $host_path -rec |
|
74
|
-
Where-Object {$_.PSIsContainer -eq $false} |
|
75
|
-
ForEach-Object -Process {
|
76
|
-
$file_name = $_.Fullname.SubString($host_path.length)
|
77
|
-
$from = $host_path + $file_name
|
78
|
-
$to = $guest_path + $file_name
|
79
|
-
Upload-FIle-To-VM $from $to $session
|
80
|
-
}
|
81
|
-
} elseif (Test-Path $host_path) {
|
82
|
-
Upload-FIle-To-VM $host_path $guest_path $session
|
83
|
-
}
|
84
|
-
$resultHash = @{
|
85
|
-
message = "OK"
|
86
|
-
}
|
87
|
-
Write-Output-Message $resultHash
|
88
|
-
} catch {
|
89
|
-
$errortHash = @{
|
90
|
-
type = "PowerShellError"
|
91
|
-
error ="Failed to copy file $_"
|
92
|
-
}
|
93
|
-
Write-Error-Message $errortHash
|
94
|
-
return
|
95
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved. Licensed under the Apache 2.0 License.
|
4
|
-
#--------------------------------------------------------------------------
|
5
|
-
|
6
|
-
function Get-Remote-Session($guest_ip, $guest_port, $username, $password) {
|
7
|
-
$secstr = convertto-securestring -AsPlainText -Force -String $password
|
8
|
-
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
|
9
|
-
New-PSSession -ComputerName $guest_ip -Port $guest_port -Credential $cred -UseSSL -ErrorAction "stop"
|
10
|
-
}
|
11
|
-
|
12
|
-
function Create-Remote-Session($guest_ip, $guest_port, $username, $password) {
|
13
|
-
$count = 0
|
14
|
-
$session_error = ""
|
15
|
-
$session = ""
|
16
|
-
do {
|
17
|
-
$count++
|
18
|
-
try {
|
19
|
-
$session = Get-Remote-Session $guest_ip $guest_port $username $password
|
20
|
-
$session_error = ""
|
21
|
-
}
|
22
|
-
catch {
|
23
|
-
Start-Sleep -s 1
|
24
|
-
$session_error = $_
|
25
|
-
$session = ""
|
26
|
-
}
|
27
|
-
}
|
28
|
-
while (!$session -and $count -lt 20)
|
29
|
-
|
30
|
-
return @{
|
31
|
-
session = $session
|
32
|
-
error = "$session_error"
|
33
|
-
}
|
34
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved. Licensed under the Apache 2.0 License.
|
4
|
-
#--------------------------------------------------------------------------
|
5
|
-
|
6
|
-
function Write-Error-Message($message) {
|
7
|
-
$result = ConvertTo-Json $message
|
8
|
-
Write-Host "===Begin-Error==="
|
9
|
-
Write-Host $result
|
10
|
-
Write-Host "===End-Error==="
|
11
|
-
}
|
12
|
-
|
13
|
-
function Write-Output-Message($message) {
|
14
|
-
$result = ConvertTo-Json $message
|
15
|
-
Write-Host "===Begin-Output==="
|
16
|
-
Write-Host $result
|
17
|
-
Write-Host "===End-Output==="
|
18
|
-
}
|