Skip to content

Commit

Permalink
Get region value from provider.region, fix for a12ccea
Browse files Browse the repository at this point in the history
Commit a12ccea added code to persist the region associated with an
instance to use it later on when searching for the instance on AWS.
The modification added a function in the provider that returns the
region either from this saved state or from the default configuration.
This fix updates the code at various points to use this function rather
then rely on the default configuration for the region value.
  • Loading branch information
Nour Sharabash committed Oct 4, 2017
1 parent 00ca219 commit 712c1c9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/vagrant-aws/action/package_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def call(env)
env[:metrics]["instance_ready_time"] = Util::Timer.time do

# Get the config, to set the ami burn timeout
region = env[:machine].provider_config.region
region = env[:machine].provider.region
region_config = env[:machine].provider_config.get_region_config(region)
tries = region_config.instance_package_timeout / 2

Expand Down Expand Up @@ -128,7 +128,7 @@ def clean_temp_dir
def create_vagrantfile env
File.open(File.join(env["export.temp_dir"], "Vagrantfile"), "w") do |f|
f.write(TemplateRenderer.render("vagrant-aws_package_Vagrantfile", {
region: env[:machine].provider_config.region,
region: env[:machine].provider.region,
ami: @ami_id,
template_root: template_root
}))
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-aws/action/read_ssh_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def read_ssh_info(aws, machine)

# read attribute override
ssh_host_attribute = machine.provider_config.
get_region_config(machine.provider_config.region).ssh_host_attribute
get_region_config(machine.provider.region).ssh_host_attribute
# default host attributes to try. NOTE: Order matters!
ssh_attrs = [:dns_name, :public_ip_address, :private_ip_address]
ssh_attrs = (Array(ssh_host_attribute) + ssh_attrs).uniq if ssh_host_attribute
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-aws/action/run_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def call(env)
env[:metrics] ||= {}

# Get the region we're going to booting up in
region = env[:machine].provider_config.region
region = env[:machine].provider.region

# Get the configs
region_config = env[:machine].provider_config.get_region_config(region)
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-aws/action/terminate_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(app, env)

def call(env)
server = env[:aws_compute].servers.get(env[:machine].id)
region = env[:machine].provider_config.region
region = env[:machine].provider.region
region_config = env[:machine].provider_config.get_region_config(region)

elastic_ip = region_config.elastic_ip
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-aws/util/elb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def adjust_availability_zones(env, elb)
instances = env[:aws_compute].servers.all("instance-id" => elb.instances)

azs = if instances.empty?
["#{env[:machine].provider_config.region}a"]
["#{env[:machine].provider.region}a"]
else
instances.map(&:availability_zone).uniq
end
Expand Down

0 comments on commit 712c1c9

Please sign in to comment.