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,46 +1,49 @@
|
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
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 'azure'
|
7
|
+
require 'log4r'
|
8
|
+
|
9
|
+
# FIXME:
|
10
|
+
# This is a required to patch few exception handling which are not done in
|
11
|
+
# Azure Ruby SDK
|
12
|
+
require_relative "vagrant_azure_service"
|
13
|
+
|
14
|
+
module VagrantPlugins
|
15
|
+
module WinAzure
|
16
|
+
module Action
|
17
|
+
class ConnectAzure
|
18
|
+
def initialize(app, env)
|
19
|
+
@app = app
|
20
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::connect_aws')
|
21
|
+
end
|
22
|
+
|
23
|
+
def call (env)
|
24
|
+
if env[:azure_vm_service].nil?
|
25
|
+
config = env[:machine].provider_config
|
26
|
+
|
27
|
+
Azure.configure do |c|
|
28
|
+
c.subscription_id = config.subscription_id
|
29
|
+
c.management_certificate = config.mgmt_certificate
|
30
|
+
c.management_endpoint = config.mgmt_endpoint
|
31
|
+
c.storage_account_name = config.storage_acct_name
|
32
|
+
c.storage_access_key = config.storage_access_key
|
33
|
+
end
|
34
|
+
|
35
|
+
# FIXME:
|
36
|
+
# Defining a new class VagrantAzureService
|
37
|
+
# Here we call the native azure virtual machine management service method
|
38
|
+
# and add some exception handling.
|
39
|
+
# Remove this once the Azure SDK adds the exception handling for the
|
40
|
+
# methods defined in VagrantAzureService
|
41
|
+
env[:azure_vm_service] = VagrantAzureService.new(Azure::VirtualMachineManagementService.new)
|
42
|
+
end
|
43
|
+
|
44
|
+
@app.call(env)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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
|
+
module VagrantPlugins
|
9
|
+
module WinAzure
|
10
|
+
module Action
|
11
|
+
class OSType
|
12
|
+
def initialize(app, env)
|
13
|
+
@app = app
|
14
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::os_type')
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
|
19
|
+
unless env[:machine].config.vm.guest
|
20
|
+
env[:ui].info 'Determining OS Type By Image'
|
21
|
+
guest_os_type = env[:azure_vm_service].send(:get_os_type, env[:machine].provider_config.vm_image)
|
22
|
+
env[:machine].config.vm.guest = guest_os_type && guest_os_type.downcase.to_sym
|
23
|
+
if env[:machine].config.vm.guest == :windows && env[:machine].config.vm.communicator.nil?
|
24
|
+
env[:machine].config.vm.communicator = :winrm
|
25
|
+
end
|
26
|
+
env[:ui].info "OS Type is #{guest_os_type}"
|
27
|
+
end
|
28
|
+
|
29
|
+
@app.call(env)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module WinAzure
|
3
|
+
module Action
|
4
|
+
class PowerShellRun
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::powershell_run_command')
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
|
12
|
+
if env[:machine].communicate.ready?
|
13
|
+
env[:machine].ui.detail("PowerShell Executing: #{env[:powershell_command]}")
|
14
|
+
env[:powershell_command_exit_status] = env[:machine].communicate.execute(env[:powershell_command]) do |type, stream|
|
15
|
+
if type == :stdout
|
16
|
+
env[:machine].ui.success(stream) unless (stream || '').chomp.empty?
|
17
|
+
else
|
18
|
+
env[:machine].ui.error(stream) unless (stream || '').chomp.empty?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
@app.call(env)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,49 +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
|
-
env[:
|
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
|
-
env[:provisioner].provision
|
44
|
-
end
|
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
|
+
|
7
|
+
module VagrantPlugins
|
8
|
+
module WinAzure
|
9
|
+
module Action
|
10
|
+
class Provision < Vagrant::Action::Builtin::Provision
|
11
|
+
# Override the core vagrant method and branch out for windows
|
12
|
+
def run_provisioner(env)
|
13
|
+
env[:machine].id =~ /@/
|
14
|
+
vm = env[:azure_vm_service].get_virtual_machine($`, $')
|
15
|
+
env[:ui].info "VM OS: #{vm.os_type.to_sym}"
|
16
|
+
|
17
|
+
if vm.os_type.to_sym == :Windows
|
18
|
+
env[:ui].info 'Provisioning for Windows'
|
19
|
+
|
20
|
+
case env[:provisioner].class.to_s
|
21
|
+
when 'VagrantPlugins::Shell::Provisioner'
|
22
|
+
env[:provisioner].provision
|
23
|
+
when 'VagrantPlugins::Puppet::Provisioner::Puppet'
|
24
|
+
VagrantPlugins::WinAzure::Provisioner::Puppet.new(
|
25
|
+
env
|
26
|
+
).provision_for_windows
|
27
|
+
when 'VagrantPlugins::Chef::Provisioner::ChefSolo'
|
28
|
+
VagrantPlugins::WinAzure::Provisioner::ChefSolo.new(
|
29
|
+
env
|
30
|
+
).provision_for_windows
|
31
|
+
else
|
32
|
+
env[:provisioner].provision
|
33
|
+
end
|
34
|
+
else
|
35
|
+
env[:ui].info 'Provisioning using SSH'
|
36
|
+
env[:provisioner].provision
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -1,62 +1,63 @@
|
|
1
|
-
#--------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved.
|
4
|
-
|
5
|
-
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require 'vagrant/util/
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
'
|
49
|
-
'
|
50
|
-
'
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
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 'pathname'
|
8
|
+
require 'vagrant/util/subprocess'
|
9
|
+
require 'vagrant/util/platform'
|
10
|
+
|
11
|
+
module VagrantPlugins
|
12
|
+
module WinAzure
|
13
|
+
module Action
|
14
|
+
class Rdp
|
15
|
+
def initialize(app, env)
|
16
|
+
@app = app
|
17
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::rdp')
|
18
|
+
@rdp_file = 'machine.rdp'
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(env)
|
22
|
+
if Vagrant::Util::Platform.windows?
|
23
|
+
generate_rdp_file env[:machine]
|
24
|
+
command = ['mstsc', @rdp_file]
|
25
|
+
Vagrant::Util::Subprocess.execute(*command)
|
26
|
+
elsif Vagrant::Util::Platform.darwin?
|
27
|
+
generate_rdp_file env[:machine]
|
28
|
+
command = ['open', @rdp_file]
|
29
|
+
result = Vagrant::Util::Subprocess.execute(*command)
|
30
|
+
|
31
|
+
if result.exit_code == 1
|
32
|
+
raise result.stderr
|
33
|
+
end
|
34
|
+
else
|
35
|
+
# TODO: Add support for RDP on *Nix systems
|
36
|
+
raise 'Unsupported operating system for RDP operation.'
|
37
|
+
end
|
38
|
+
|
39
|
+
@app.call(env)
|
40
|
+
end
|
41
|
+
|
42
|
+
def generate_rdp_file(machine)
|
43
|
+
File.delete(@rdp_file) if File.exists?(@rdp_file)
|
44
|
+
|
45
|
+
info = machine.provider.rdp_info
|
46
|
+
|
47
|
+
rdp_options = {
|
48
|
+
'drivestoredirect:s' => '*',
|
49
|
+
'username:s' => machine.provider_config.vm_user,
|
50
|
+
'prompt for credentials:i' => '1',
|
51
|
+
'full address:s' => "#{info[:host]}:#{info[:port]}"
|
52
|
+
}
|
53
|
+
|
54
|
+
file = File.open(@rdp_file, 'w')
|
55
|
+
rdp_options.each do |key, value|
|
56
|
+
file.puts "#{key}:#{value}"
|
57
|
+
end
|
58
|
+
file.close
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,51 +1,54 @@
|
|
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
|
-
env[:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
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
|
+
module VagrantPlugins
|
9
|
+
module WinAzure
|
10
|
+
module Action
|
11
|
+
class ReadSSHInfo
|
12
|
+
def initialize(app, env, port = 22)
|
13
|
+
@app = app
|
14
|
+
@port = port
|
15
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::read_ssh_info')
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
env[:ui].info "Looking for local port #{@port}"
|
20
|
+
|
21
|
+
env[:machine_ssh_info] = read_ssh_info(
|
22
|
+
env[:azure_vm_service],
|
23
|
+
env[:machine]
|
24
|
+
)
|
25
|
+
|
26
|
+
env[:ui].info "Found port mapping #{env[:machine_ssh_info][:port]} --> #{@port}"
|
27
|
+
|
28
|
+
@app.call(env)
|
29
|
+
end
|
30
|
+
|
31
|
+
def read_ssh_info(azure, machine)
|
32
|
+
return nil if machine.id.nil?
|
33
|
+
machine.id =~ /@/
|
34
|
+
vm = azure.get_virtual_machine($`, $')
|
35
|
+
|
36
|
+
if vm.nil? || !vm.instance_of?(Azure::VirtualMachineManagement::VirtualMachine)
|
37
|
+
# Machine cannot be found
|
38
|
+
@logger.info 'Machine not found. Assuming it was destroyed'
|
39
|
+
machine.id = nil
|
40
|
+
return nil
|
41
|
+
end
|
42
|
+
|
43
|
+
vm.tcp_endpoints.each do |endpoint|
|
44
|
+
if endpoint[:local_port] == "#{@port}"
|
45
|
+
return { :host => "#{vm.cloud_service_name}.cloudapp.net", :port => endpoint[:public_port] }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
return nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|