1. Storage account name and access key are now optional elements.

2. The time between state read outs changed to 30 seconds.
3. The time out for 'wait_for_state' is now a configuration value and defaults to 360 seconds.
4. Moved to vagrant version 1.5
This commit is contained in:
DeeJay 2014-03-24 15:44:09 +05:30
Родитель 35472efdd6
Коммит 7202601ece
6 изменённых файлов: 67 добавлений и 28 удалений

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

@ -11,7 +11,7 @@ group :development do
# We depend on Vagrant for development, but we don't add it as a
# gem dependency because we expect to be installed within the
# Vagrant environment itself using `vagrant plugin`.
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => 'v1.4.3'
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
end
group :plugins do

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

@ -54,6 +54,7 @@ module VagrantPlugins
# This action is called when `vagrant provision` is called.
def self.action_provision
Vagrant::Action::Builder.new.tap do |b|
b.use ConnectAzure
b.use ConfigValidate
b.use Call, IsCreated do |env, b2|
if !env[:result]
@ -62,7 +63,7 @@ module VagrantPlugins
end
b2.use Provision
b2.use SyncFolders
# b2.use SyncFolders
end
end
end
@ -146,8 +147,8 @@ module VagrantPlugins
def self.action_prepare_boot
Vagrant::Action::Builder.new.tap do |b|
b.use Provision
b.use SyncFolders
b.use WarnNetworks
# b.use SyncFolders
# b.use WarnNetworks
end
end
@ -161,8 +162,8 @@ module VagrantPlugins
if env1[:result]
b1.use Call, IsStopped do |env2, b2|
if env2[:result]
# b2.use action_prepare_boot
b2.use StartInstance # restart this instance
b2.use action_prepare_boot
b2.use StartInstance # start this instance again
b2.use Call, WaitForState, :ReadyRole, 300 do |env3, b3|
if env3[:result]
b3.use MessageVMStarted
@ -216,6 +217,7 @@ module VagrantPlugins
autoload :MessageRDPNotReady, action_root.join('message_rdp_not_ready')
autoload :MessageVMStarted, action_root.join('message_vm_started')
autoload :MessageWillNotDestroy, action_root.join('message_will_not_destroy')
autoload :Provision, action_root.join('provision')
autoload :Rdp, action_root.join('rdp')
autoload :ReadSSHInfo, action_root.join('read_ssh_info')
autoload :ReadState, action_root.join('read_state')

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

@ -0,0 +1,36 @@
#---------------------------------------------------------------------------
# Copyright (c) Microsoft Open Technologies, Inc.
# All Rights Reserved. Licensed under the Apache 2.0 License.
#--------------------------------------------------------------------------
# Overriding the core vagrant class because of the lack of non-ssh based
# communication infrastructure.
# This will be moved to an 'rdp' communicator when the core supports it.
module VagrantPlugins
module WinAzure
module Action
class Provision < Vagrant::Action::Builtin::Provision
# Override the core vagrant method and branch out for windows
def run_provisioner(env)
env[:ui].info "Provisioner: #{env[:provisioner].class.to_s}"
env[:machine].id =~ /@/
vm = env[:azure_vm_service].get_virtual_machine($`, $')
env[:ui].info "VM OS: #{vm.os_type.to_s}"
if vm.os_type.to_s == :Windows
# Raise an error if we're not on a Windows Host.
# Non-Windows OS will be supported once we move to WinRb/WinRm
raise 'Unsupported OS for Windows Provisioning' unless \
Vagrant::Util::Platform.windows?
env[:ui].info "Provisioning for Windows"
else
env[:ui].info "Provisioning using SSH"
env[:provisioner].provision
end
end
end
end
end
end

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

@ -38,8 +38,7 @@ module VagrantPlugins
end
vm.tcp_endpoints.each do |endpoint|
l_port = endpoint[:local_port]
if l_port == "#{@port}"
if endpoint[:local_port] == "#{@port}"
return { :host => endpoint[:vip], :port => endpoint[:public_port] }
end
end

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

@ -9,10 +9,9 @@ module VagrantPlugins
module WinAzure
module Action
class WaitForState
def initialize(app, env, state, timeout)
def initialize(app, env, state)
@app = app
@state = state
@timeout = timeout
@logger = Log4r::Logger.new("vagrant_azure::action::wait_for_state")
end
@ -24,22 +23,24 @@ module VagrantPlugins
I18n.t('vagrant_azure.already_status', :status => @state)
)
else
timeout = env[:machine].provider_config.state_read_timeout
env[:ui].info "Waiting for machine to reach state #{@state}"
@logger.info("Waiting for machine to reach state #{@state}")
begin
Timeout.timeout(@timeout) do
Timeout.timeout(timeout) do
until env[:machine].state.id == @state
sleep 10
sleep 30
end
end
env[:ui].success "Machine reached state #{@state}"
rescue Timeout::Error
env[:ui].error "Machine failed to reached state '#{@state}' in '#{@timeout}' seconds."
env[:ui].error "Machine failed to reached state '#{@state}' in '#{timeout}' seconds."
env[:result] = false # couldn't reach state in time
end
end
env[:ui].success "Machine reached state #{@state}"
@app.call(env)
end
end

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

@ -7,11 +7,11 @@ require 'vagrant'
module VagrantPlugins
module WinAzure
class Config < Vagrant.plugin('2', :config)
attr_accessor :storage_acct_name
attr_accessor :storage_access_key
attr_accessor :mgmt_certificate
attr_accessor :mgmt_endpoint
attr_accessor :subscription_id
attr_accessor :storage_acct_name
attr_accessor :storage_access_key
attr_accessor :vm_name
attr_accessor :vm_user
@ -31,6 +31,8 @@ module VagrantPlugins
attr_accessor :availability_set_name
attr_accessor :add_role
attr_accessor :state_read_timeout
def initialize
@storage_acct_name = UNSET_VALUE
@storage_access_key = UNSET_VALUE
@ -55,6 +57,7 @@ module VagrantPlugins
@winrm_transport = UNSET_VALUE
@availability_set_name = UNSET_VALUE
@add_role = UNSET_VALUE
@state_read_timeout = UNSET_VALUE
end
def finalize!
@ -70,7 +73,7 @@ module VagrantPlugins
@subscription_id == UNSET_VALUE
@vm_name = nil if @vm_name == UNSET_VALUE
@vm_user = 'vagrantone' if @vm_user == UNSET_VALUE
@vm_user = 'vagrant' if @vm_user == UNSET_VALUE
@vm_password = nil if @vm_password == UNSET_VALUE
@vm_image = nil if @vm_image == UNSET_VALUE
@vm_location = nil if @vm_location == UNSET_VALUE
@ -87,20 +90,22 @@ module VagrantPlugins
@availability_set_name = nil if @availability_set_name == UNSET_VALUE
@add_role = false if @add_role == UNSET_VALUE
@state_read_timeout = 360 if @state_read_timeout == UNSET_VALUE
end
def merge(other)
super.tap do |result|
result.storage_account_name = other.storage_acct_name || \
self.storage_acct_name
result.storage_access_key = other.storage_access_key || \
self.storage_access_key
result.mgmt_certificate = other.mgmt_certificate || \
self.mgmt_certificate
result.mgmt_endpoint = other.mgmt_endpoint || \
self.mgmt_endpoint
result.subscription_id = other.subscription_id || \
self.subscription_id
result.storage_account_name = other.storage_acct_name || \
self.storage_acct_name
result.storage_access_key = other.storage_access_key || \
self.storage_access_key
end
end
@ -108,16 +113,12 @@ module VagrantPlugins
errors = _detected_errors
# Azure connection properties related validation.
errors << "vagrant_azure.subscription_id.requried" if \
errors << "vagrant_azure.subscription_id.required" if \
@subscription_id.nil?
errors << "vagrant_azure.mgmt_certificate.requried" if \
errors << "vagrant_azure.mgmt_certificate.required" if \
@mgmt_certificate.nil?
errors << "vagrant_azaure.mgmt_endpoint.requried" if \
errors << "vagrant_azure.mgmt_endpoint.required" if \
@mgmt_endpoint.nil?
errors << "vagrant_azure.storage_acct_name.requried" if\
@storage_acct_name.nil?
errors << "vagrant_azure.storage_access_key.requried" if\
@storage_access_key.nil?
# Azure Virtual Machine related validation
errors << "vagrant_azure.vm_name.required" if @vm_name.nil?