vagrant-azure 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,38 +1,42 @@
|
|
1
|
-
#--------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
1
|
+
#--------------------------------------------------------------------------
|
2
|
+
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
+
# All Rights Reserved. Licensed under the Apache License, Version 2.0.
|
4
|
+
# See License.txt in the project root for license information.
|
5
|
+
#--------------------------------------------------------------------------
|
6
|
+
require 'log4r'
|
7
|
+
|
8
|
+
# Barebones basic implemenation. This a work in progress in very early stages
|
9
|
+
module VagrantPlugins
|
10
|
+
module WinAzure
|
11
|
+
module Action
|
12
|
+
class StopInstance
|
13
|
+
|
14
|
+
def initialize(app, env)
|
15
|
+
@app = app
|
16
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::stop_instance')
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
if env[:machine].state.id == :StoppedDeallocated
|
21
|
+
env[:ui].info(
|
22
|
+
I18n.t('vagrant_azure.already_status', :status => 'stopped.')
|
23
|
+
)
|
24
|
+
else
|
25
|
+
env[:machine].id =~ /@/
|
26
|
+
VagrantPlugins::WinAzure::CLOUD_SERVICE_SEMAPHORE.synchronize do
|
27
|
+
env[:ui].info(
|
28
|
+
I18n.t(
|
29
|
+
'vagrant_azure.stopping',
|
30
|
+
:vm_name => $`,
|
31
|
+
:cloud_service_name => $'
|
32
|
+
)
|
33
|
+
)
|
34
|
+
env[:azure_vm_service].shutdown_virtual_machine($`, $')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
@app.call(env)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -1,63 +1,64 @@
|
|
1
|
-
# Copyright (c) 2014 Mitchell Hashimoto
|
2
|
-
# Under The MIT License (MIT)
|
3
|
-
#---------------------------------------------------------------------------
|
4
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
5
|
-
# All Rights Reserved.
|
6
|
-
|
7
|
-
|
8
|
-
require "
|
9
|
-
require "vagrant/util/
|
10
|
-
require "vagrant/util/
|
11
|
-
require "
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
env
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
:
|
42
|
-
|
43
|
-
|
44
|
-
if
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
:
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
1
|
+
# Copyright (c) 2014 Mitchell Hashimoto
|
2
|
+
# Under The MIT License (MIT)
|
3
|
+
#---------------------------------------------------------------------------
|
4
|
+
# Copyright (c) Microsoft Open Technologies, Inc.
|
5
|
+
# All Rights Reserved. Licensed under the Apache License, Version 2.0.
|
6
|
+
# See License.txt in the project root for license information.
|
7
|
+
#--------------------------------------------------------------------------
|
8
|
+
require "log4r"
|
9
|
+
require "vagrant/util/subprocess"
|
10
|
+
require "vagrant/util/scoped_hash_override"
|
11
|
+
require "vagrant/util/which"
|
12
|
+
require "#{Vagrant::source_root}/lib/vagrant/action/builtin/synced_folders"
|
13
|
+
|
14
|
+
module VagrantPlugins
|
15
|
+
module WinAzure
|
16
|
+
module Action
|
17
|
+
# This middleware uses `rsync` to sync the folders
|
18
|
+
class SyncFolders < Vagrant::Action::Builtin::SyncedFolders
|
19
|
+
include Vagrant::Util::ScopedHashOverride
|
20
|
+
|
21
|
+
def initialize(app, env)
|
22
|
+
@app = app
|
23
|
+
@logger = Log4r::Logger.new("vagrant_azure::action::sync_folders")
|
24
|
+
end
|
25
|
+
|
26
|
+
def call(env)
|
27
|
+
if env[:machine].config.vm.guest != :windows
|
28
|
+
super
|
29
|
+
else
|
30
|
+
@app.call(env)
|
31
|
+
env[:machine].config.vm.synced_folders.each do |id, data|
|
32
|
+
data = scoped_hash_override(data, :azure)
|
33
|
+
|
34
|
+
# Ignore disabled shared folders
|
35
|
+
next if data[:disabled]
|
36
|
+
|
37
|
+
hostpath = File.expand_path(data[:hostpath], env[:root_path])
|
38
|
+
guestpath = data[:guestpath]
|
39
|
+
|
40
|
+
env[:ui].info(I18n.t("vagrant_azure.copy_folder",
|
41
|
+
:hostpath => hostpath,
|
42
|
+
:guestpath => guestpath))
|
43
|
+
|
44
|
+
# Create the host path if it doesn't exist and option flag is set
|
45
|
+
if data[:create]
|
46
|
+
begin
|
47
|
+
FileUtils::mkdir_p(hostpath)
|
48
|
+
rescue => err
|
49
|
+
raise Errors::MkdirError,
|
50
|
+
:hostpath => hostpath,
|
51
|
+
:err => err
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
env[:machine].communicate.upload(hostpath, guestpath)
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
#--------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved. Licensed under the Apache 2.0 License.
|
4
|
-
#--------------------------------------------------------------------------
|
5
|
-
require 'log4r'
|
6
|
-
|
7
|
-
module VagrantPlugins
|
8
|
-
module WinAzure
|
9
|
-
module Action
|
10
|
-
class TerminateInstance
|
11
|
-
def initialize(app, env)
|
12
|
-
@app = app
|
13
|
-
@logger = Log4r::Logger.new('vagrant_azure::action::terminate_instance')
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(env)
|
17
|
-
env[:machine].id =~ /@/
|
18
|
-
|
19
|
-
vm = env[:azure_vm_service].get_virtual_machine($`, $')
|
20
|
-
|
21
|
-
if vm.nil?
|
22
|
-
# machine not found. assuming it was not created or destroyed
|
23
|
-
env[:ui].info (I18n.t('vagrant_azure.not_created'))
|
24
|
-
else
|
25
|
-
env[:azure_vm_service].delete_virtual_machine($`, $')
|
26
|
-
env[:machine].id = nil
|
27
|
-
end
|
28
|
-
|
29
|
-
@app.call(env)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
#--------------------------------------------------------------------------
|
2
|
+
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
+
# All Rights Reserved. Licensed under the Apache 2.0 License.
|
4
|
+
#--------------------------------------------------------------------------
|
5
|
+
require 'log4r'
|
6
|
+
|
7
|
+
module VagrantPlugins
|
8
|
+
module WinAzure
|
9
|
+
module Action
|
10
|
+
class TerminateInstance
|
11
|
+
def initialize(app, env)
|
12
|
+
@app = app
|
13
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::terminate_instance')
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
env[:machine].id =~ /@/
|
18
|
+
|
19
|
+
vm = env[:azure_vm_service].get_virtual_machine($`, $')
|
20
|
+
|
21
|
+
if vm.nil?
|
22
|
+
# machine not found. assuming it was not created or destroyed
|
23
|
+
env[:ui].info (I18n.t('vagrant_azure.not_created'))
|
24
|
+
else
|
25
|
+
env[:azure_vm_service].delete_virtual_machine($`, $')
|
26
|
+
env[:machine].id = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
@app.call(env)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,43 +1,44 @@
|
|
1
|
-
#---------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved.
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
1
|
+
#---------------------------------------------------------------------------
|
2
|
+
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
+
# All Rights Reserved. Licensed under the Apache License, Version 2.0.
|
4
|
+
# See License.txt in the project root for license information.
|
5
|
+
#--------------------------------------------------------------------------
|
6
|
+
# FIXME:
|
7
|
+
# This is a stop gap arrangement until the azure ruby SDK fixes the exceptions
|
8
|
+
# and gracefully fails.
|
9
|
+
|
10
|
+
module VagrantPlugins
|
11
|
+
module WinAzure
|
12
|
+
module Action
|
13
|
+
class VagrantAzureService
|
14
|
+
attr_reader :azure
|
15
|
+
def initialize(azure)
|
16
|
+
@azure = azure
|
17
|
+
end
|
18
|
+
|
19
|
+
# At times due to network latency the SDK raises SocketError, this can
|
20
|
+
# be rescued and re-try for three attempts.
|
21
|
+
def get_virtual_machine(*args)
|
22
|
+
vm = nil
|
23
|
+
attempt = 0
|
24
|
+
while true
|
25
|
+
begin
|
26
|
+
vm = azure.get_virtual_machine(*args)
|
27
|
+
rescue SocketError
|
28
|
+
attempt = attempt + 1
|
29
|
+
sleep 5
|
30
|
+
next if attempt < 3
|
31
|
+
end
|
32
|
+
break
|
33
|
+
end
|
34
|
+
vm
|
35
|
+
end
|
36
|
+
|
37
|
+
def method_missing(method, *args, &block)
|
38
|
+
azure.send(method, *args, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,38 +1,39 @@
|
|
1
|
-
#--------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved.
|
4
|
-
|
5
|
-
|
6
|
-
require '
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
break if env[:
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
1
|
+
#--------------------------------------------------------------------------
|
2
|
+
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
+
# All Rights Reserved. Licensed under the Apache License, Version 2.0.
|
4
|
+
# See License.txt in the project root for license information.
|
5
|
+
#--------------------------------------------------------------------------
|
6
|
+
require 'log4r'
|
7
|
+
require 'timeout'
|
8
|
+
|
9
|
+
module VagrantPlugins
|
10
|
+
module WinAzure
|
11
|
+
module Action
|
12
|
+
class WaitForCommunicate
|
13
|
+
def initialize(app, env)
|
14
|
+
@app = app
|
15
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::wait_for_communicate')
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
|
20
|
+
if !env[:interrupted]
|
21
|
+
# Wait for SSH to be ready.
|
22
|
+
env[:ui].info(I18n.t('vagrant_azure.waiting_for_comm'))
|
23
|
+
while true
|
24
|
+
# If we're interrupted then just back out
|
25
|
+
break if env[:interrupted]
|
26
|
+
break if env[:machine].communicate.ready?
|
27
|
+
sleep 5
|
28
|
+
end
|
29
|
+
|
30
|
+
# Ready and booted!
|
31
|
+
env[:ui].info(I18n.t('vagrant_azure.comm_ready'))
|
32
|
+
end
|
33
|
+
|
34
|
+
@app.call(env)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,49 +1,50 @@
|
|
1
|
-
#--------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved.
|
4
|
-
|
5
|
-
|
6
|
-
require '
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@
|
15
|
-
@
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
env[:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
1
|
+
#--------------------------------------------------------------------------
|
2
|
+
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
+
# All Rights Reserved. Licensed under the Apache License, Version 2.0.
|
4
|
+
# See License.txt in the project root for license information.
|
5
|
+
#--------------------------------------------------------------------------
|
6
|
+
require 'log4r'
|
7
|
+
require 'timeout'
|
8
|
+
|
9
|
+
module VagrantPlugins
|
10
|
+
module WinAzure
|
11
|
+
module Action
|
12
|
+
class WaitForState
|
13
|
+
def initialize(app, env, state)
|
14
|
+
@app = app
|
15
|
+
@state = state
|
16
|
+
@logger = Log4r::Logger.new("vagrant_azure::action::wait_for_state")
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
env[:result] = true
|
21
|
+
|
22
|
+
if env[:machine].state.id == @state
|
23
|
+
@logger.info(
|
24
|
+
I18n.t('vagrant_azure.already_status', :status => @state)
|
25
|
+
)
|
26
|
+
else
|
27
|
+
timeout = env[:machine].provider_config.state_read_timeout || env[:machine].config.vm.boot_timeout
|
28
|
+
|
29
|
+
env[:ui].info "Waiting for machine to reach state #{@state}"
|
30
|
+
@logger.info("Waiting for machine to reach state #{@state}")
|
31
|
+
|
32
|
+
begin
|
33
|
+
Timeout.timeout(timeout) do
|
34
|
+
until env[:machine].state.id == @state
|
35
|
+
sleep 30
|
36
|
+
end
|
37
|
+
end
|
38
|
+
env[:ui].success "Machine reached state #{@state}"
|
39
|
+
rescue Timeout::Error
|
40
|
+
env[:ui].error "Machine failed to reached state '#{@state}' in '#{timeout}' seconds."
|
41
|
+
env[:result] = false # couldn't reach state in time
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
@app.call(env)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|