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,46 +1,47 @@
|
|
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
|
-
|
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 'log4r'
|
7
|
+
|
8
|
+
module VagrantPlugins
|
9
|
+
module WinAzure
|
10
|
+
module Action
|
11
|
+
class ReadState
|
12
|
+
def initialize(app, env)
|
13
|
+
@app = app
|
14
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::read_state')
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
env[:machine_state_id] = read_state(env)
|
19
|
+
|
20
|
+
@app.call(env)
|
21
|
+
end
|
22
|
+
|
23
|
+
def read_state(env)
|
24
|
+
env[:machine].id = "#{env[:machine].provider_config.vm_name}@#{env[:machine].provider_config.cloud_service_name}" unless env[:machine].id
|
25
|
+
|
26
|
+
env[:machine].id =~ /@/
|
27
|
+
|
28
|
+
env[:ui].info "Attempting to read state for #{$`} in #{$'}"
|
29
|
+
|
30
|
+
vm = env[:azure_vm_service].get_virtual_machine($`, $')
|
31
|
+
|
32
|
+
if vm.nil? || \
|
33
|
+
!vm.instance_of?(Azure::VirtualMachineManagement::VirtualMachine) || \
|
34
|
+
[ :DeletingVM ].include?(vm.status.to_sym)
|
35
|
+
# Machine can't be found
|
36
|
+
@logger.info 'Machine cannot be found'
|
37
|
+
env[:machine].id = nil
|
38
|
+
return :NotCreated
|
39
|
+
end
|
40
|
+
|
41
|
+
env[:ui].info "VM Status: #{vm.status.to_sym}"
|
42
|
+
return vm.status.to_sym
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,57 @@
|
|
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 ReadWinrmInfo
|
12
|
+
def initialize(app, env)
|
13
|
+
@app = app
|
14
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::read_winrm_info')
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
if env[:machine].config.vm.guest == :windows
|
19
|
+
env[:ui].info 'Looking for WinRM'
|
20
|
+
|
21
|
+
env[:machine_winrm_info] = read_winrm_info(
|
22
|
+
env[:azure_vm_service],
|
23
|
+
env[:machine]
|
24
|
+
)
|
25
|
+
|
26
|
+
env[:ui].info "Found public port #{env[:machine_winrm_info][:port]}"
|
27
|
+
end
|
28
|
+
|
29
|
+
@app.call(env)
|
30
|
+
end
|
31
|
+
|
32
|
+
def read_winrm_info(azure, machine)
|
33
|
+
return nil if machine.id.nil?
|
34
|
+
machine.id =~ /@/
|
35
|
+
vm = azure.get_virtual_machine($`, $')
|
36
|
+
|
37
|
+
if vm.nil? || !vm.instance_of?(Azure::VirtualMachineManagement::VirtualMachine)
|
38
|
+
# Machine cannot be found
|
39
|
+
@logger.info 'Machine not found. Assuming it was destroyed'
|
40
|
+
machine.id = nil
|
41
|
+
return nil
|
42
|
+
end
|
43
|
+
|
44
|
+
vm.tcp_endpoints.each do |endpoint|
|
45
|
+
if endpoint[:name] == 'PowerShell'
|
46
|
+
machine.config.winrm.host = "#{vm.cloud_service_name}.cloudapp.net"
|
47
|
+
machine.config.winrm.port = endpoint[:public_port]
|
48
|
+
return { :host => "#{vm.cloud_service_name}.cloudapp.net", :port => endpoint[:public_port] }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,27 +1,28 @@
|
|
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
|
-
env[:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
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 RestartVM
|
12
|
+
def initialize(app, env)
|
13
|
+
@app = app
|
14
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::restart_vm')
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
env[:machine].id =~ /@/
|
19
|
+
|
20
|
+
env[:ui].info "Restarting #{$`} in #{$'}"
|
21
|
+
env[:azure_vm_service].restart_virtual_machine($`, $')
|
22
|
+
|
23
|
+
@app.call(env)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,115 +1,123 @@
|
|
1
|
-
#---------------------------------------------------------------------------
|
2
|
-
# Copyright (c) Microsoft Open Technologies, Inc.
|
3
|
-
# All Rights Reserved.
|
4
|
-
|
5
|
-
|
6
|
-
require '
|
7
|
-
require '
|
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
|
-
params[:
|
40
|
-
params[:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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 'json'
|
8
|
+
require 'azure'
|
9
|
+
|
10
|
+
require 'vagrant/util/retryable'
|
11
|
+
|
12
|
+
module VagrantPlugins
|
13
|
+
module WinAzure
|
14
|
+
module Action
|
15
|
+
class RunInstance
|
16
|
+
include Vagrant::Util::Retryable
|
17
|
+
|
18
|
+
def initialize(app, env)
|
19
|
+
@app = app
|
20
|
+
@logger = Log4r::Logger.new('vagrant_azure::action::run_instance')
|
21
|
+
end
|
22
|
+
|
23
|
+
def call(env)
|
24
|
+
config = env[:machine].provider_config
|
25
|
+
|
26
|
+
# Add the mandatory parameters and options
|
27
|
+
params = {
|
28
|
+
vm_name: config.vm_name,
|
29
|
+
vm_user: config.vm_user,
|
30
|
+
image: config.vm_image
|
31
|
+
}
|
32
|
+
|
33
|
+
options = {
|
34
|
+
cloud_service_name: config.cloud_service_name
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
# Add the optional parameters and options if not nil
|
39
|
+
params[:password] = config.vm_password unless config.vm_password.nil?
|
40
|
+
params[:location] = config.vm_location unless config.vm_location.nil?
|
41
|
+
params[:affinity_group] = config.vm_affinity_group unless \
|
42
|
+
config.vm_affinity_group.nil?
|
43
|
+
|
44
|
+
options[:storage_account_name] = config.storage_acct_name unless \
|
45
|
+
config.storage_acct_name.nil?
|
46
|
+
options[:deployment_name] = config.deployment_name unless \
|
47
|
+
config.deployment_name.nil?
|
48
|
+
options[:tcp_endpoints] = config.tcp_endpoints unless \
|
49
|
+
config.tcp_endpoints.nil?
|
50
|
+
options[:private_key_file] = config.private_key_file unless \
|
51
|
+
config.private_key_file.nil?
|
52
|
+
options[:certificate_file] = config.certificate_file unless \
|
53
|
+
config.certificate_file.nil?
|
54
|
+
options[:ssh_port] = config.ssh_port unless \
|
55
|
+
config.ssh_port.nil?
|
56
|
+
options[:vm_size] = config.vm_size unless \
|
57
|
+
config.vm_size.nil?
|
58
|
+
options[:winrm_transport] = config.winrm_transport unless \
|
59
|
+
config.winrm_transport.nil?
|
60
|
+
options[:winrm_http_port] = config.winrm_http_port unless \
|
61
|
+
config.winrm_http_port.nil?
|
62
|
+
options[:winrm_https_port] = config.winrm_https_port unless \
|
63
|
+
config.winrm_https_port.nil?
|
64
|
+
options[:availability_set_name] = config.availability_set_name unless \
|
65
|
+
config.availability_set_name.nil?
|
66
|
+
options[:vm_virtual_network_name] = config.vm_virtual_network_name unless \
|
67
|
+
config.vm_virtual_network_name.nil?
|
68
|
+
|
69
|
+
add_role = false
|
70
|
+
|
71
|
+
env[:ui].info(params.inspect)
|
72
|
+
env[:ui].info(options.inspect)
|
73
|
+
|
74
|
+
server = VagrantPlugins::WinAzure::CLOUD_SERVICE_SEMAPHORE.synchronize do
|
75
|
+
# Check if the cloud service exists and if yes, does it contain
|
76
|
+
# a deployment.
|
77
|
+
if config.cloud_service_name && !config.cloud_service_name.empty?
|
78
|
+
begin
|
79
|
+
cloud_service = ManagementHttpRequest.new(
|
80
|
+
:get,
|
81
|
+
"/services/hostedservices/#{config.cloud_service_name}?embed-detail=true"
|
82
|
+
).call
|
83
|
+
|
84
|
+
deployments = cloud_service.css 'HostedService Deployments Deployment'
|
85
|
+
|
86
|
+
# Lets see if any deployments exist. Set add_role = true if yes.
|
87
|
+
# We're not worried about deployment slots, because the SDK has
|
88
|
+
# hard coded 'Production' as deployment slot and you can have only
|
89
|
+
# one deployment per deployment slot.
|
90
|
+
add_role = deployments.length == 1
|
91
|
+
rescue Exception => e
|
92
|
+
add_role = false
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
env[:ui].info("Add Role? - #{add_role}")
|
97
|
+
|
98
|
+
if add_role
|
99
|
+
env[:azure_vm_service].add_role(params.clone.merge(cloud_service_name: config.cloud_service_name), options)
|
100
|
+
else
|
101
|
+
env[:azure_vm_service].create_virtual_machine(params, options)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
if server.nil?
|
106
|
+
raise Errors::CreateVMFailure
|
107
|
+
end
|
108
|
+
|
109
|
+
# The Ruby SDK returns any exception encountered on create virtual
|
110
|
+
# machine as a string.
|
111
|
+
|
112
|
+
if server.instance_of? String
|
113
|
+
raise Errors::ServerNotCreated, message: server
|
114
|
+
end
|
115
|
+
|
116
|
+
env[:machine].id = "#{server.vm_name}@#{server.cloud_service_name}"
|
117
|
+
|
118
|
+
@app.call(env)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -1,35 +1,35 @@
|
|
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
|
-
def initialize(app, env)
|
18
|
-
@app = app
|
19
|
-
@logger = Log4r::Logger.new('vagrant_azure:action::start_instance')
|
20
|
-
end
|
21
|
-
|
22
|
-
def call(env)
|
23
|
-
env[:machine].id = "#{env[:machine].provider_config.vm_name}@#{env[:machine].provider_config.cloud_service_name}" unless env[:machine].id
|
24
|
-
env[:machine].id =~ /@/
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@app.call(env)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
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
|
+
# require 'vagrant/util/retryable'
|
9
|
+
|
10
|
+
# Barebones basic implemenation. This a work in progress in very early stages
|
11
|
+
module VagrantPlugins
|
12
|
+
module WinAzure
|
13
|
+
module Action
|
14
|
+
# This starts a stopped instance
|
15
|
+
class StartInstance
|
16
|
+
|
17
|
+
def initialize(app, env)
|
18
|
+
@app = app
|
19
|
+
@logger = Log4r::Logger.new('vagrant_azure:action::start_instance')
|
20
|
+
end
|
21
|
+
|
22
|
+
def call(env)
|
23
|
+
env[:machine].id = "#{env[:machine].provider_config.vm_name}@#{env[:machine].provider_config.cloud_service_name}" unless env[:machine].id
|
24
|
+
env[:machine].id =~ /@/
|
25
|
+
|
26
|
+
VagrantPlugins::WinAzure::CLOUD_SERVICE_SEMAPHORE.synchronize do
|
27
|
+
env[:ui].info "Attempting to start '#{$`}' in '#{$'}'"
|
28
|
+
env[:azure_vm_service].start_virtual_machine($`, $')
|
29
|
+
end
|
30
|
+
@app.call(env)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|