1
1
require 'fileutils'
2
2
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
-
22
3
module VagrantAWS
23
- class Action
4
+ module Action
24
5
class CreateImage
25
6
include Vagrant ::Util
26
7
@@ -50,10 +31,11 @@ def call(env)
50
31
raise VagrantAWS ::Errors ::EBSDeviceRequired , :command => "box_create" if @env [ "image.register" ] and @env [ "vm" ] . vm . root_device_type != "ebs"
51
32
52
33
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" )
54
35
@image = @env [ "vm" ] . connection . create_image ( @env [ "vm" ] . vm . id , @env [ 'image.name' ] , @env [ 'image.desc' ] )
36
+
55
37
@image = @env [ "vm" ] . connection . images . new ( { :id => @image . body [ 'imageId' ] } )
56
- @image . wait_for { state == "available" }
38
+ @image . wait_for { ready? }
57
39
else
58
40
@image = @env [ "vm" ] . connection . images . get ( @env [ "vm" ] . vm . image_id )
59
41
end
@@ -68,7 +50,7 @@ def call(env)
68
50
69
51
def recover ( env )
70
52
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 )
72
54
@image . deregister ( !@image . root_device_name . nil? ) # Don't try to delete backing snapshot if it was not created
73
55
end
74
56
cleanup_temp_dir
@@ -81,8 +63,8 @@ def cleanup_temp_dir
81
63
end
82
64
83
65
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 )
86
68
FileUtils . mkpath ( @env [ "export.temp_dir" ] )
87
69
end
88
70
@@ -91,7 +73,7 @@ def export
91
73
File . open ( File . join ( @env [ "export.temp_dir" ] , 'Vagrantfile' ) , "w" ) do |f |
92
74
f . write ( TemplateRenderer . render_string ( PACKAGE_VAGRANTFILE , {
93
75
:image => @image . id ,
94
- :region => @env [ "config" ] . aws . region
76
+ :region => @env [ "vm" ] . config . aws . region
95
77
} ) )
96
78
end
97
79
File . open ( File . join ( @env [ "export.temp_dir" ] , 'image.json' ) , "w" ) do |f |
0 commit comments