Merge branch 'devigned-fix/multibox'

This commit is contained in:
Jeff Mendoza 2014-12-08 11:41:15 -08:00
Родитель 10696f072a d357c82d17
Коммит edd10f9753
1 изменённых файлов: 54 добавлений и 51 удалений

Просмотреть файл

@ -9,6 +9,8 @@ require 'azure'
require 'vagrant/util/retryable'
CLOUD_SERVICE_SEMAPHORE = Mutex.new
module VagrantPlugins
module WinAzure
module Action
@ -39,80 +41,81 @@ module VagrantPlugins
params[:password] = config.vm_password unless config.vm_password.nil?
params[:location] = config.vm_location unless config.vm_location.nil?
params[:affinity_group] = config.vm_affinity_group unless \
config.vm_affinity_group.nil?
config.vm_affinity_group.nil?
options[:storage_account_name] = config.storage_acct_name unless \
config.storage_acct_name.nil?
config.storage_acct_name.nil?
options[:deployment_name] = config.deployment_name unless \
config.deployment_name.nil?
config.deployment_name.nil?
options[:tcp_endpoints] = config.tcp_endpoints unless \
config.tcp_endpoints.nil?
config.tcp_endpoints.nil?
options[:private_key_file] = config.ssh_private_key_file unless \
config.ssh_private_key_file.nil?
config.ssh_private_key_file.nil?
options[:certificate_file] = config.ssh_certificate_file unless \
config.ssh_certificate_file.nil?
config.ssh_certificate_file.nil?
options[:ssh_port] = config.ssh_port unless \
config.ssh_port.nil?
config.ssh_port.nil?
options[:vm_size] = config.vm_size unless \
config.vm_size.nil?
config.vm_size.nil?
options[:winrm_transport] = config.winrm_transport unless \
config.winrm_transport.nil?
config.winrm_transport.nil?
options[:winrm_http_port] = config.winrm_http_port unless \
config.winrm_http_port.nil?
config.winrm_http_port.nil?
options[:winrm_https_port] = config.winrm_https_port unless \
config.winrm_https_port.nil?
config.winrm_https_port.nil?
options[:availability_set_name] = config.availability_set_name unless \
config.availability_set_name.nil?
config.availability_set_name.nil?
add_role = false
env[:ui].info(params.inspect)
env[:ui].info(options.inspect)
# Check if the cloud service exists and if yes, does it contain
# a deployment.
if config.cloud_service_name && !config.cloud_service_name.empty?
begin
cloud_service = ManagementHttpRequest.new(
:get,
"/services/hostedservices/#{config.cloud_service_name}?embed-detail=true"
).call
server = CLOUD_SERVICE_SEMAPHORE.synchronize do
# Check if the cloud service exists and if yes, does it contain
# a deployment.
if config.cloud_service_name && !config.cloud_service_name.empty?
begin
cloud_service = ManagementHttpRequest.new(
:get,
"/services/hostedservices/#{config.cloud_service_name}?embed-detail=true"
).call
deployments = cloud_service.css 'HostedService Deployments Deployment'
deployments = cloud_service.css 'HostedService Deployments Deployment'
# Lets see if any deployments exist. Set add_role = true if yes.
# We're not worried about deployment slots, because the SDK has
# hard coded 'Production' as deployment slot and you can have only
# one deployment per deployment slot.
add_role = deployments.length == 1
rescue Exception => e
add_role = false
# Lets see if any deployments exist. Set add_role = true if yes.
# We're not worried about deployment slots, because the SDK has
# hard coded 'Production' as deployment slot and you can have only
# one deployment per deployment slot.
add_role = deployments.length == 1
rescue Exception => e
add_role = false
end
end
env[:ui].info("Add Role? - #{add_role}")
if add_role
env[:azure_vm_service].add_role(params.clone.merge(cloud_service_name: config.cloud_service_name), options)
else
env[:azure_vm_service].create_virtual_machine(params, options)
end
if server.nil?
raise Errors::CreateVMFailure
end
# The Ruby SDK returns any exception encountered on create virtual
# machine as a string.
if server.instance_of? String
raise Errors::ServerNotCreated, message: server
end
env[:machine].id = "#{server.vm_name}@#{server.cloud_service_name}"
@app.call(env)
end
env[:ui].info("Add Role? - #{add_role}")
if add_role
env[:azure_vm_service].add_role(params.clone.merge(cloud_service_name: config.cloud_service_name), options)
else
env[:azure_vm_service].create_virtual_machine(params, options)
end
if server.nil?
raise Errors::CreateVMFailure
end
# The Ruby SDK returns any exception encountered on create virtual
# machine as a string.
if server.instance_of? String
raise Errors::ServerNotCreated, message: server
end
env[:machine].id = "#{server.vm_name}@#{server.cloud_service_name}"
@app.call(env)
end
end
end
end
end