Skip to content
This repository was archived by the owner on Feb 11, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion lib/vagrant-aws/action/run_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,25 @@ module Action
class RunInstance
include Vagrant::Util::Retryable

@@instances = 0
LIMIT = 10

def self.update_instances
@@instances = @@instances + 1
end

def self.instances
@@instances
end

def initialize(app, env)
RunInstance.update_instances
@app = app
@instance_no = RunInstance.instances
@iteration = 1
@logger = Log4r::Logger.new("vagrant_aws::action::run_instance")
@logger.debug("Instance no - #{@instance_no}")
control_vm_creation
end

def call(env)
Expand Down Expand Up @@ -123,7 +139,7 @@ def call(env)
next if env[:interrupted]

# Wait for the server to be ready
server.wait_for(2) { ready? }
server.wait_for(10) { ready? }
end
rescue Fog::Errors::TimeoutError
# Delete the instance
Expand Down Expand Up @@ -232,6 +248,16 @@ def terminate(env)
destroy_env[:force_confirm_destroy] = true
env[:action_runner].run(Action.action_destroy, destroy_env)
end

private

def control_vm_creation
while @instance_no > (LIMIT * @iteration) do
@iteration = @iteration + 1
@logger.debug("----------------instance_no - #{@instance_no} will wait-----------------")
sleep 30
end
end
end
end
end
Expand Down