Skip to content

Commit 2862078

Browse files
committed
Merge pull request #1 from ggoodale/master
Can I have your changes
2 parents aad7ea9 + 1677ae3 commit 2862078

39 files changed

+613
-349
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
Gemfile.lock
44
pkg/*
55
.rvmrc
6+
test/tmp
7+
test/tmp/*

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ require 'rake/testtask'
44
task :default => :test
55

66
Rake::TestTask.new do |t|
7+
ENV['VAGRANT_HOME'] = File.join(File.dirname(__FILE__), 'test', 'tmp', 'home')
8+
79
t.libs << "test"
810
t.pattern = 'test/**/*_test.rb'
911
end

lib/vagrant-aws.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
require 'vagrant-aws/config'
77
require 'vagrant-aws/middleware'
88
require 'vagrant-aws/command'
9-
require 'vagrant-aws/system'
109
require 'vagrant-aws/box'
11-
require 'vagrant-aws/box_collection'
1210

1311
# Add our custom translations to the load path
1412
I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
13+
14+
module VagrantAWS
15+
# The source root is the path to the root directory of
16+
# the Vagrant gem.
17+
def self.source_root
18+
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
19+
end
20+
end
21+

lib/vagrant-aws/action/create.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
module VagrantAWS
2-
class Action
2+
module Action
33
class Create
44
def initialize(app, env)
55
@app = app
66
end
77

88
def call(env)
9-
raise Errors::KeyNameNotSpecified if env["config"].aws.key_name.nil?
9+
raise Errors::KeyNameNotSpecified if env["vm"].config.aws.key_name.nil?
1010

11-
env.ui.info I18n.t("vagrant.plugins.aws.actions.create.creating")
11+
env["ui"].info I18n.t("vagrant.plugins.aws.actions.create.creating")
1212

13-
server_def = server_definition(env["config"])
13+
server_def = server_definition(env["vm"].config)
1414

1515
# Verify AMI is valid (and in the future enable options specific to EBS-based AMIs)
1616
image = env["vm"].connection.images.get(server_def[:image_id])
@@ -19,12 +19,12 @@ def call(env)
1919
env["vm"].vm = env["vm"].connection.servers.create(server_def)
2020
raise VagrantAWS::Errors::VMCreateFailure if env["vm"].vm.nil? || env["vm"].vm.id.nil?
2121

22-
env.ui.info I18n.t("vagrant.plugins.aws.actions.create.created", :id => env["vm"].vm.id)
22+
env["ui"].info I18n.t("vagrant.plugins.aws.actions.create.created", :id => env["vm"].vm.id)
2323

2424
env["vm"].vm.wait_for { ready? }
2525
env["vm"].connection.create_tags(env["vm"].vm.id, { "name" => env["vm"].name })
2626

27-
env.ui.info I18n.t("vagrant.plugins.aws.actions.create.available", :dns => env["vm"].vm.dns_name)
27+
env["ui"].info I18n.t("vagrant.plugins.aws.actions.create.available", :dns => env["vm"].vm.dns_name)
2828

2929
@app.call(env)
3030
end

lib/vagrant-aws/action/create_image.rb

+8-26
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
11
require 'fileutils'
22

3-
# Path vagrant to not delete pre-existing package file (pull request submitted upstream)
4-
5-
module Vagrant
6-
class Action
7-
module General
8-
9-
class Package
10-
def recover(env)
11-
unless env["vagrant.error"].is_a?(Errors::PackageOutputExists)
12-
# Cleanup any packaged files if the packaging failed at some point.
13-
File.delete(tar_path) if File.exist?(tar_path)
14-
end
15-
end
16-
end
17-
18-
end
19-
end
20-
end
21-
223
module VagrantAWS
23-
class Action
4+
module Action
245
class CreateImage
256
include Vagrant::Util
267

@@ -50,10 +31,11 @@ def call(env)
5031
raise VagrantAWS::Errors::EBSDeviceRequired, :command => "box_create" if @env["image.register"] and @env["vm"].vm.root_device_type != "ebs"
5132

5233
if @env["image.register"]
53-
@env.ui.info I18n.t("vagrant.plugins.aws.actions.create_image.creating")
34+
@env["ui"].info I18n.t("vagrant.plugins.aws.actions.create_image.creating")
5435
@image = @env["vm"].connection.create_image(@env["vm"].vm.id, @env['image.name'], @env['image.desc'])
36+
5537
@image = @env["vm"].connection.images.new({ :id => @image.body['imageId'] })
56-
@image.wait_for { state == "available" }
38+
@image.wait_for { ready? }
5739
else
5840
@image = @env["vm"].connection.images.get(@env["vm"].vm.image_id)
5941
end
@@ -68,7 +50,7 @@ def call(env)
6850

6951
def recover(env)
7052
if env["image.register"]
71-
env.ui.info I18n.t("vagrant.plugins.aws.actions.deregister_image.deregistering", :image => @image.id)
53+
env["ui"].info I18n.t("vagrant.plugins.aws.actions.deregister_image.deregistering", :image => @image.id)
7254
@image.deregister(!@image.root_device_name.nil?) # Don't try to delete backing snapshot if it was not created
7355
end
7456
cleanup_temp_dir
@@ -81,8 +63,8 @@ def cleanup_temp_dir
8163
end
8264

8365
def setup_temp_dir
84-
@env.ui.info I18n.t("vagrant.actions.vm.export.create_dir")
85-
@temp_dir = @env["export.temp_dir"] = @env.env.tmp_path.join(Time.now.to_i.to_s)
66+
@env["ui"].info I18n.t("vagrant.actions.vm.export.create_dir")
67+
@temp_dir = @env["export.temp_dir"] = @env["vm"].env.tmp_path.join(Time.now.to_i.to_s)
8668
FileUtils.mkpath(@env["export.temp_dir"])
8769
end
8870

@@ -91,7 +73,7 @@ def export
9173
File.open(File.join(@env["export.temp_dir"], 'Vagrantfile'), "w") do |f|
9274
f.write(TemplateRenderer.render_string(PACKAGE_VAGRANTFILE, {
9375
:image => @image.id,
94-
:region => @env["config"].aws.region
76+
:region => @env["vm"].config.aws.region
9577
}))
9678
end
9779
File.open(File.join(@env["export.temp_dir"], 'image.json'), "w") do |f|

lib/vagrant-aws/action/create_sshkey.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'Macaddr'
22

33
module VagrantAWS
4-
class Action
4+
module Action
55
class CreateSSHKey
66
def initialize(app, env)
77
@app = app
@@ -10,25 +10,25 @@ def initialize(app, env)
1010
def call(env)
1111
@env = env
1212

13-
if @env["config"].aws.key_name.nil?
13+
if @env["vm"].config.aws.key_name.nil?
1414
# Do we have a previously created key available on AWS?
15-
key = @env["vm"].connection.key_pairs.all('key-name' => @env.env.ssh_keys).first
15+
key = @env["vm"].connection.key_pairs.all('key-name' => @env["vm"].env.ssh_keys).first
1616
if key.nil?
1717
# Create and save key
1818
key = @env["vm"].connection.key_pairs.create(:name => "vagrantaws_#{Mac.addr.gsub(':','')}")
19-
env.ui.info I18n.t("vagrant.plugins.aws.actions.create_ssh_key.created", :name => key.name)
19+
env["ui"].info I18n.t("vagrant.plugins.aws.actions.create_ssh_key.created", :name => key.name)
2020
File.open(local_key_path(key.name), File::WRONLY|File::TRUNC|File::CREAT, 0600) { |f| f.write(key.private_key) }
2121
end
2222

23-
@env["config"].aws.key_name = key.name
24-
@env["config"].aws.private_key_path = local_key_path(key.name)
23+
@env["vm"].config.aws.key_name = key.name
24+
@env["vm"].config.aws.private_key_path = local_key_path(key.name)
2525
end
2626

2727
@app.call(env)
2828
end
2929

3030
def local_key_path(name)
31-
@env.env.ssh_keys_path.join(name)
31+
@env["vm"].env.ssh_keys_path.join(name)
3232
end
3333

3434
end

lib/vagrant-aws/action/deregister_image.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module VagrantAWS
2-
class Action
2+
module Action
33
class DeregisterImage
44
def initialize(app, env)
55
@app = app

lib/vagrant-aws/action/populate_ssh.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module VagrantAWS
2-
class Action
2+
module Action
33
class PopulateSSH
44
def initialize(app, env)
55
@app = app

lib/vagrant-aws/action/prepare_provisioners.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'archive/tar/minitar'
22

33
module VagrantAWS
4-
class Action
4+
module Action
55
class PrepareProvisioners
66
def initialize(app, env)
77
@app = app

lib/vagrant-aws/action/resume.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module VagrantAWS
2-
class Action
2+
module Action
33
class Resume
44
def initialize(app, env)
55
@app = app

lib/vagrant-aws/action/suspend.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module VagrantAWS
2-
class Action
2+
module Action
33
class Suspend
44
def initialize(app, env)
55
@app = app

lib/vagrant-aws/action/terminate.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module VagrantAWS
2-
class Action
2+
module Action
33
class Terminate
44
def initialize(app, env)
55
@app = app
66
end
77

88
def call(env)
9-
env.ui.info I18n.t("vagrant.actions.vm.destroy.destroying")
9+
env["ui"].info I18n.t("vagrant.actions.vm.destroy.destroying")
1010

1111
env["vm"].vm.destroy
1212
env["vm"].vm = nil

lib/vagrant-aws/box.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module VagrantAWS
22

33
class Box < Vagrant::Box
44

5-
%w{ ovf_file repackage destroy }.each do |method|
5+
%w{ repackage destroy }.each do |method|
66
undef_method(method)
77
end
88

lib/vagrant-aws/box_collection.rb

-15
This file was deleted.

0 commit comments

Comments
 (0)