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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +19 -15
  3. data/CHANGELOG.md +24 -24
  4. data/Gemfile +20 -15
  5. data/LICENSE +4 -4
  6. data/README.md +189 -125
  7. data/Rakefile +15 -14
  8. data/lib/vagrant-azure.rb +31 -33
  9. data/lib/vagrant-azure/action.rb +267 -243
  10. data/lib/vagrant-azure/action/connect_azure.rb +49 -46
  11. data/lib/vagrant-azure/action/os_type.rb +34 -0
  12. data/lib/vagrant-azure/action/powershell_run.rb +28 -0
  13. data/lib/vagrant-azure/action/provision.rb +42 -49
  14. data/lib/vagrant-azure/action/rdp.rb +63 -62
  15. data/lib/vagrant-azure/action/read_ssh_info.rb +54 -51
  16. data/lib/vagrant-azure/action/read_state.rb +47 -46
  17. data/lib/vagrant-azure/action/read_winrm_info.rb +57 -0
  18. data/lib/vagrant-azure/action/restart_vm.rb +28 -27
  19. data/lib/vagrant-azure/action/run_instance.rb +123 -115
  20. data/lib/vagrant-azure/action/start_instance.rb +35 -35
  21. data/lib/vagrant-azure/action/stop_instance.rb +42 -38
  22. data/lib/vagrant-azure/action/sync_folders.rb +64 -63
  23. data/lib/vagrant-azure/action/terminate_instance.rb +34 -34
  24. data/lib/vagrant-azure/action/vagrant_azure_service.rb +44 -43
  25. data/lib/vagrant-azure/action/wait_for_communicate.rb +39 -38
  26. data/lib/vagrant-azure/action/wait_for_state.rb +50 -49
  27. data/lib/vagrant-azure/capabilities/winrm.rb +12 -0
  28. data/lib/vagrant-azure/command/powershell.rb +43 -0
  29. data/lib/vagrant-azure/command/rdp.rb +24 -0
  30. data/lib/vagrant-azure/config.rb +158 -147
  31. data/lib/vagrant-azure/driver.rb +48 -84
  32. data/lib/vagrant-azure/errors.rb +28 -27
  33. data/lib/vagrant-azure/monkey_patch/azure.rb +46 -0
  34. data/lib/vagrant-azure/monkey_patch/winrm.rb +77 -0
  35. data/lib/vagrant-azure/plugin.rb +102 -91
  36. data/lib/vagrant-azure/provider.rb +74 -70
  37. data/lib/vagrant-azure/provisioner/chef-solo.rb +178 -177
  38. data/lib/vagrant-azure/provisioner/puppet.rb +116 -115
  39. data/lib/vagrant-azure/version.rb +11 -10
  40. data/locales/en.yml +37 -37
  41. data/templates/provisioners/chef-solo/solo.erb +51 -51
  42. data/vagrant-azure.gemspec +59 -58
  43. metadata +48 -38
  44. data/lib/vagrant-azure/command/rdp/command.rb +0 -21
  45. data/lib/vagrant-azure/communication/powershell.rb +0 -41
  46. data/lib/vagrant-azure/monkey_patch/machine.rb +0 -22
  47. data/lib/vagrant-azure/provisioner/shell.rb +0 -83
  48. data/lib/vagrant-azure/scripts/check_winrm.ps1 +0 -47
  49. data/lib/vagrant-azure/scripts/export_vm.ps1 +0 -31
  50. data/lib/vagrant-azure/scripts/file_sync.ps1 +0 -145
  51. data/lib/vagrant-azure/scripts/host_info.ps1 +0 -25
  52. data/lib/vagrant-azure/scripts/hyperv_manager.ps1 +0 -36
  53. data/lib/vagrant-azure/scripts/run_in_remote.ps1 +0 -32
  54. data/lib/vagrant-azure/scripts/upload_file.ps1 +0 -95
  55. data/lib/vagrant-azure/scripts/utils/create_session.ps1 +0 -34
  56. 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. Licensed under the Apache 2.0 License.
4
- #--------------------------------------------------------------------------
5
- require 'log4r'
6
-
7
- # Barebones basic implemenation. This a work in progress in very early stages
8
- module VagrantPlugins
9
- module WinAzure
10
- module Action
11
- class StopInstance
12
- def initialize(app, env)
13
- @app = app
14
- @logger = Log4r::Logger.new('vagrant_azure::action::stop_instance')
15
- end
16
-
17
- def call(env)
18
- if env[:machine].state.id == :StoppedDeallocated
19
- env[:ui].info(
20
- I18n.t('vagrant_azure.already_status', :status => 'stopped.')
21
- )
22
- else
23
- env[:machine].id =~ /@/
24
- env[:ui].info(
25
- I18n.t(
26
- 'vagrant_azure.stopping',
27
- :vm_name => $`,
28
- :cloud_service_name => $'
29
- )
30
- )
31
- env[:azure_vm_service].shutdown_virtual_machine($`, $')
32
- end
33
- @app.call(env)
34
- end
35
- end
36
- end
37
- end
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. Licensed under the Apache 2.0 License.
6
- #--------------------------------------------------------------------------
7
- require "log4r"
8
- require "vagrant/util/subprocess"
9
- require "vagrant/util/scoped_hash_override"
10
- require "vagrant/util/which"
11
- require "#{Vagrant::source_root}/lib/vagrant/action/builtin/synced_folders"
12
-
13
- module VagrantPlugins
14
- module WinAzure
15
- module Action
16
- # This middleware uses `rsync` to sync the folders
17
- class SyncFolders < Vagrant::Action::Builtin::SyncedFolders
18
- include Vagrant::Util::ScopedHashOverride
19
-
20
- def initialize(app, env)
21
- @app = app
22
- @logger = Log4r::Logger.new("vagrant_azure::action::sync_folders")
23
- end
24
-
25
- def call(env)
26
- if env[:machine].config.vm.guest != :windows
27
- super
28
- else
29
- @app.call(env)
30
- env[:machine].config.vm.synced_folders.each do |id, data|
31
- data = scoped_hash_override(data, :azure)
32
-
33
- # Ignore disabled shared folders
34
- next if data[:disabled]
35
-
36
- hostpath = File.expand_path(data[:hostpath], env[:root_path])
37
- guestpath = data[:guestpath]
38
-
39
- env[:ui].info(I18n.t("vagrant_azure.copy_folder",
40
- :hostpath => hostpath,
41
- :guestpath => guestpath))
42
-
43
- # Create the host path if it doesn't exist and option flag is set
44
- if data[:create]
45
- begin
46
- FileUtils::mkdir_p(hostpath)
47
- rescue => err
48
- raise Errors::MkdirError,
49
- :hostpath => hostpath,
50
- :err => err
51
- end
52
- end
53
-
54
- env[:machine].provider.driver.upload(hostpath, guestpath)
55
-
56
- end
57
- end
58
- end
59
-
60
- end
61
- end
62
- end
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. Licensed under the Apache 2.0 License.
4
- #--------------------------------------------------------------------------
5
- # FIXME:
6
- # This is a stop gap arrangement until the azure ruby SDK fixes the exceptions
7
- # and gracefully fails.
8
-
9
- module VagrantPlugins
10
- module WinAzure
11
- module Action
12
- class VagrantAzureService
13
- attr_reader :azure
14
- def initialize(azure)
15
- @azure = azure
16
- end
17
-
18
- # At times due to network latency the SDK raises SocketError, this can
19
- # be rescued and re-try for three attempts.
20
- def get_virtual_machine(*args)
21
- vm = nil
22
- attempt = 0
23
- while true
24
- begin
25
- vm = azure.get_virtual_machine(*args)
26
- rescue SocketError
27
- attempt = attempt + 1
28
- sleep 5
29
- next if attempt < 3
30
- end
31
- break
32
- end
33
- vm
34
- end
35
-
36
- def method_missing(method, *args, &block)
37
- azure.send(method, *args, &block)
38
- end
39
-
40
- end
41
- end
42
- end
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. Licensed under the Apache 2.0 License.
4
- #--------------------------------------------------------------------------
5
- require 'log4r'
6
- require 'timeout'
7
-
8
- module VagrantPlugins
9
- module WinAzure
10
- module Action
11
- class WaitForCommunicate
12
- def initialize(app, env)
13
- @app = app
14
- @logger = Log4r::Logger.new("vagrant_azure::action::wait_for_communicate")
15
- end
16
-
17
- def call(env)
18
-
19
- if !env[:interrupted]
20
- # Wait for SSH to be ready.
21
- env[:ui].info(I18n.t("vagrant_azure.waiting_for_ssh"))
22
- while true
23
- # If we're interrupted then just back out
24
- break if env[:interrupted]
25
- break if env[:machine].communicate.ready?
26
- sleep 5
27
- end
28
-
29
- # Ready and booted!
30
- env[:ui].info(I18n.t("vagrant_azure.ssh_ready"))
31
- end
32
-
33
- @app.call(env)
34
- end
35
- end
36
- end
37
- end
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. Licensed under the Apache 2.0 License.
4
- #--------------------------------------------------------------------------
5
- require 'log4r'
6
- require 'timeout'
7
-
8
- module VagrantPlugins
9
- module WinAzure
10
- module Action
11
- class WaitForState
12
- def initialize(app, env, state)
13
- @app = app
14
- @state = state
15
- @logger = Log4r::Logger.new("vagrant_azure::action::wait_for_state")
16
- end
17
-
18
- def call(env)
19
- env[:result] = true
20
-
21
- if env[:machine].state.id == @state
22
- @logger.info(
23
- I18n.t('vagrant_azure.already_status', :status => @state)
24
- )
25
- else
26
- timeout = env[:machine].provider_config.state_read_timeout
27
-
28
- env[:ui].info "Waiting for machine to reach state #{@state}"
29
- @logger.info("Waiting for machine to reach state #{@state}")
30
-
31
- begin
32
- Timeout.timeout(timeout) do
33
- until env[:machine].state.id == @state
34
- sleep 30
35
- end
36
- end
37
- env[:ui].success "Machine reached state #{@state}"
38
- rescue Timeout::Error
39
- env[:ui].error "Machine failed to reached state '#{@state}' in '#{timeout}' seconds."
40
- env[:result] = false # couldn't reach state in time
41
- end
42
- end
43
-
44
- @app.call(env)
45
- end
46
- end
47
- end
48
- end
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