build-cloud 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/README.md +10 -2
- data/bin/build-cloud +4 -3
- data/build-cloud.gemspec +1 -1
- data/lib/build-cloud.rb +21 -5
- data/lib/build-cloud/ebsvolume.rb +82 -0
- data/lib/build-cloud/instance.rb +91 -11
- data/lib/build-cloud/internetgateway.rb +1 -1
- data/lib/build-cloud/launchconfiguration.rb +35 -2
- data/lib/build-cloud/networkinterface.rb +10 -5
- data/lib/build-cloud/route.rb +14 -14
- data/lib/build-cloud/routetable.rb +4 -1
- data/lib/build-cloud/subnet.rb +12 -8
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZThjZDkyYzRlNjlkOTA5ZDJlOTkyY2RmYTQ3MTI1YzhiMTg3NWFmOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MWM3ZGRjZWUxOTgxM2I5MTdkMjI2Y2ZhZTVjNjBmYjk4OTM0Zjk4MA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
M2IxNDhlN2VhNTQyM2IyNDhlNjk4NzhlM2RkYzVkYjRhYmNkODg1NTQxY2Mz
|
10
|
+
ZTljOWRkNTcxZGZlODExMzg3NzkzMGVlZDYxNzY5YzE1OTkxOTZhY2E2ZTgy
|
11
|
+
NTYzODA5MmZmOTgxZjI2ZmU2MzQzN2MzNWNiYjhkMjNhYTJjNDc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MGQzMTg5YzYyZTA0NWI5NGIzYjAzZmViOGFmOGE5ODlmNTc2NjgzNGUxM2Jl
|
14
|
+
NTFjNjRiMTJhMmUzY2ZmNjY4MDFiYWNhM2JlNDliZDJhYjUzMDBiMGE5MTg1
|
15
|
+
NmI1YjkxYzJjMzk2MjczNjE5MDBjYWE2ODAzMzQ1NTRlYWMwZmY=
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Build::Cloud
|
2
2
|
|
3
|
-
|
3
|
+
Tools for building resources in AWS}
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,15 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
See the command line help for `build-cloud`.
|
22
|
+
|
23
|
+
## Changelog
|
24
|
+
|
25
|
+
2014-09-15 - version 0.0.3 - now accepts multiple files to `--config`. The second and subsequent files are merged into the first YAML file in order, ahead of any files specified in a `:include` list in the first YAML file.
|
26
|
+
|
27
|
+
2014-06-23 - version 0.0.2 - now accepts an array of files in the `:include` key in the given YAML config file. The files are merged in to the config file in the order that they are given.
|
28
|
+
|
29
|
+
2014-05-27 - version 0.0.1 - initial version.
|
22
30
|
|
23
31
|
## Contributing
|
24
32
|
|
data/bin/build-cloud
CHANGED
@@ -25,6 +25,7 @@ require 'build-cloud/cacheparametergroup'
|
|
25
25
|
require 'build-cloud/iamrole'
|
26
26
|
require 'build-cloud/s3bucket'
|
27
27
|
require 'build-cloud/instance'
|
28
|
+
require 'build-cloud/ebsvolume'
|
28
29
|
require 'build-cloud/networkinterface'
|
29
30
|
require 'build-cloud/internetgateway'
|
30
31
|
|
@@ -32,7 +33,7 @@ options = {}
|
|
32
33
|
optparse = OptionParser.new do |opts|
|
33
34
|
|
34
35
|
options[:config] = nil
|
35
|
-
opts.on('-c', '--config
|
36
|
+
opts.on('-c', '--config file1,file2', Array, 'Config files - second and subsequent files merged into first.') do |c|
|
36
37
|
options[:config] = c
|
37
38
|
end
|
38
39
|
|
@@ -72,12 +73,12 @@ optparse = OptionParser.new do |opts|
|
|
72
73
|
end
|
73
74
|
|
74
75
|
options[:find_type] = []
|
75
|
-
opts.on('--find-type
|
76
|
+
opts.on('--find-type t', 'Find objects by type') do |t|
|
76
77
|
options[:find_type].push(t.to_sym)
|
77
78
|
end
|
78
79
|
|
79
80
|
options[:find] = {}
|
80
|
-
opts.on('--find
|
81
|
+
opts.on('--find f', 'Find objects by key match') do |f|
|
81
82
|
args = f.split('=')
|
82
83
|
options[:find][ args[0].to_sym ] = args[1]
|
83
84
|
end
|
data/build-cloud.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "build-cloud"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.3"
|
8
8
|
spec.authors = ["The Scale Factory"]
|
9
9
|
spec.email = ["info@scalefactory.com"]
|
10
10
|
spec.summary = %q{Tools for building resources in AWS}
|
data/lib/build-cloud.rb
CHANGED
@@ -15,14 +15,28 @@ class BuildCloud
|
|
15
15
|
|
16
16
|
@log = options[:logger] or Logger.new( STDERR )
|
17
17
|
@mock = options[:mock] or false
|
18
|
-
@config = YAML::load( File.open( options[:config] ) )
|
19
18
|
|
20
|
-
|
21
|
-
|
19
|
+
first_config_file = options[:config].shift
|
20
|
+
|
21
|
+
@config = YAML::load( File.open( first_config_file ) )
|
22
|
+
|
23
|
+
include_files = options[:config]
|
24
|
+
if include_yaml = @config.delete(:include)
|
25
|
+
if include_yaml.is_a?(Array)
|
26
|
+
include_files.concat(include_yaml)
|
27
|
+
else
|
28
|
+
include_files.push(include_yaml)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
include_files.each do |include_file|
|
33
|
+
|
34
|
+
include_path = File.join( File.dirname( first_config_file ), include_file)
|
22
35
|
|
23
36
|
if File.exists?( include_path )
|
24
|
-
|
25
|
-
|
37
|
+
@log.info( "Including YAML file #{include_path}" )
|
38
|
+
included_conf = YAML::load( File.open( include_path ) )
|
39
|
+
@config = @config.merge( included_conf )
|
26
40
|
end
|
27
41
|
|
28
42
|
end
|
@@ -99,6 +113,7 @@ class BuildCloud
|
|
99
113
|
:iam_roles => BuildCloud::IAMRole,
|
100
114
|
:s3_buckets => BuildCloud::S3Bucket,
|
101
115
|
:instances => BuildCloud::Instance,
|
116
|
+
:ebs_volumes => BuildCloud::EBSVolume,
|
102
117
|
}
|
103
118
|
|
104
119
|
end
|
@@ -125,6 +140,7 @@ class BuildCloud
|
|
125
140
|
:as_groups,
|
126
141
|
:r53_record_sets,
|
127
142
|
:s3_buckets,
|
143
|
+
:ebs_volumes,
|
128
144
|
:instances,
|
129
145
|
]
|
130
146
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
class BuildCloud::EBSVolume
|
2
|
+
|
3
|
+
include ::BuildCloud::Component
|
4
|
+
|
5
|
+
@@objects = []
|
6
|
+
|
7
|
+
def self.get_id_by_name( name )
|
8
|
+
|
9
|
+
volume = self.search( :name => name ).first
|
10
|
+
|
11
|
+
unless volume
|
12
|
+
raise "Couldn't get an EBSVolume object for #{name} - is it defined?"
|
13
|
+
end
|
14
|
+
|
15
|
+
volume_fog = volume.read
|
16
|
+
|
17
|
+
unless volume_fog
|
18
|
+
raise "Couldn't get an EBSVolume fog object for #{name} - is it created?"
|
19
|
+
end
|
20
|
+
|
21
|
+
volume_fog.id
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize ( fog_interfaces, log, options = {} )
|
26
|
+
|
27
|
+
@compute = fog_interfaces[:compute]
|
28
|
+
@log = log
|
29
|
+
@options = options
|
30
|
+
|
31
|
+
@log.debug( options.inspect )
|
32
|
+
|
33
|
+
required_options(:name, :availability_zone, :size)
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def create
|
38
|
+
|
39
|
+
return if exists?
|
40
|
+
|
41
|
+
@log.info( "Creating volume #{@options[:name]}" )
|
42
|
+
|
43
|
+
options = @options.dup
|
44
|
+
|
45
|
+
volume = @compute.volumes.new(options)
|
46
|
+
volume.save
|
47
|
+
|
48
|
+
attributes = {}
|
49
|
+
attributes[:resource_id] = volume.id.to_s
|
50
|
+
attributes[:key] = 'Name'
|
51
|
+
attributes[:value] = @options[:name]
|
52
|
+
volume_tag = @compute.tags.new( attributes )
|
53
|
+
volume_tag.save
|
54
|
+
|
55
|
+
@log.debug( volume.inspect )
|
56
|
+
|
57
|
+
if @options[:instance_name]
|
58
|
+
instance_id = BuildCloud::Instance.get_id_by_name( options[:instance_name] )
|
59
|
+
attach_response = @compute.attach_volume(instance_id, volume.id, options[:device])
|
60
|
+
@log.debug( attach_response.inspect )
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def read
|
66
|
+
@compute.volumes.select { |v| v.tags['Name'] == @options[:name]}.first
|
67
|
+
end
|
68
|
+
|
69
|
+
alias_method :fog_object, :read
|
70
|
+
|
71
|
+
def delete
|
72
|
+
|
73
|
+
return unless exists?
|
74
|
+
|
75
|
+
@log.info( "Deleting volume #{@options[:name]}" )
|
76
|
+
|
77
|
+
fog_object.destroy
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
data/lib/build-cloud/instance.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'timeout'
|
3
|
+
|
1
4
|
class BuildCloud::Instance
|
2
5
|
|
3
6
|
include ::BuildCloud::Component
|
@@ -30,10 +33,11 @@ class BuildCloud::Instance
|
|
30
33
|
|
31
34
|
@log.debug( options.inspect )
|
32
35
|
|
33
|
-
required_options(:image_id, :flavor_id, :
|
36
|
+
required_options(:image_id, :flavor_id, :name)
|
34
37
|
require_one_of(:security_group_ids, :security_group_names, :network_interfaces)
|
35
38
|
require_one_of(:subnet_id, :subnet_name, :network_interfaces)
|
36
39
|
#require_one_of(:network_interfaces, :private_ip_address)
|
40
|
+
require_one_of(:user_data, :user_data_file, :user_data_template)
|
37
41
|
require_one_of(:vpc_id, :vpc_name)
|
38
42
|
|
39
43
|
end
|
@@ -92,7 +96,39 @@ class BuildCloud::Instance
|
|
92
96
|
options.delete(:subnet_id)
|
93
97
|
end
|
94
98
|
|
95
|
-
|
99
|
+
if options[:user_data]
|
100
|
+
|
101
|
+
options[:user_data] = JSON.generate( options[:user_data] )
|
102
|
+
|
103
|
+
elsif options[:user_data_file]
|
104
|
+
|
105
|
+
user_data_file_path = File.join( Dir.pwd, options[:user_data_file])
|
106
|
+
|
107
|
+
if File.exists?( user_data_file_path )
|
108
|
+
options[:user_data] = File.read( user_data_file_path )
|
109
|
+
options.delete(:user_data_file)
|
110
|
+
else
|
111
|
+
@log.error("config lists a :user_data_file that doesn't exist at #{options[:user_data_file]}")
|
112
|
+
end
|
113
|
+
|
114
|
+
elsif options[:user_data_template]
|
115
|
+
|
116
|
+
variable_hash = options[:user_data_variables]
|
117
|
+
user_data_template_path = File.join( Dir.pwd, options[:user_data_template])
|
118
|
+
|
119
|
+
if File.exists?( user_data_template_path )
|
120
|
+
template = File.read( user_data_template_path )
|
121
|
+
### We set 'trim_mode' to '-', which supresses end of line white space on lines ending in '-%>'
|
122
|
+
### see http://ruby-doc.org/stdlib-2.1.2/libdoc/erb/rdoc/ERB.html#method-c-new
|
123
|
+
buffer = ERB.new(template,nil,'-').result(binding)
|
124
|
+
options[:user_data] = buffer
|
125
|
+
options.delete(:user_data_variables)
|
126
|
+
options.delete(:user_data_template)
|
127
|
+
else
|
128
|
+
@log.error("config lists a :user_data_template that doesn't exist at #{options[:user_data_template]}")
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
96
132
|
|
97
133
|
options[:network_interfaces].each { |iface|
|
98
134
|
if ! iface[:network_interface_name].nil?
|
@@ -107,17 +143,61 @@ class BuildCloud::Instance
|
|
107
143
|
instance = @ec2.servers.new( options )
|
108
144
|
instance.save
|
109
145
|
|
110
|
-
options[:tags].each do | tag |
|
111
|
-
attributes = {}
|
112
|
-
attributes[:resource_id] = instance.id.to_s
|
113
|
-
attributes[:key] = tag[:key]
|
114
|
-
attributes[:value] = tag[:value]
|
115
|
-
new_tag = @ec2.tags.new( attributes )
|
116
|
-
new_tag.save
|
117
|
-
end unless options[:tags].empty? or options[:tags].nil?
|
118
|
-
|
119
146
|
@log.debug( instance.inspect )
|
120
147
|
|
148
|
+
if options[:ebs_volumes]
|
149
|
+
|
150
|
+
instance = @ec2.servers.get(instance.id)
|
151
|
+
instance_state = instance.state
|
152
|
+
|
153
|
+
begin
|
154
|
+
Timeout::timeout(30) {
|
155
|
+
until instance_state == 'running'
|
156
|
+
@log.info( "instance not ready yet: #{instance_state}" )
|
157
|
+
sleep 3
|
158
|
+
instance = @ec2.servers.get(instance.id)
|
159
|
+
instance_state = instance.state
|
160
|
+
end
|
161
|
+
@log.debug("Instance state: #{instance_state}")
|
162
|
+
}
|
163
|
+
rescue Timeout::Error
|
164
|
+
@log.error("Waiting on availability for instance: #{instance.id}, timed out")
|
165
|
+
end
|
166
|
+
|
167
|
+
instance_id = instance.id
|
168
|
+
options[:ebs_volumes].each do |vol|
|
169
|
+
vol_id = BuildCloud::EBSVolume.get_id_by_name( vol[:name] )
|
170
|
+
attach_response = @ec2.attach_volume(instance_id, vol_id, vol[:device])
|
171
|
+
@log.debug( attach_response.inspect )
|
172
|
+
volume_state = @ec2.volumes.get(vol_id).state
|
173
|
+
|
174
|
+
begin
|
175
|
+
Timeout::timeout(30) {
|
176
|
+
until volume_state == 'in-use'
|
177
|
+
@log.info( "Volume not attached yet: #{volume_state}" )
|
178
|
+
sleep 3
|
179
|
+
volume_state = @ec2.volumes.get(vol_id).state
|
180
|
+
end
|
181
|
+
@log.debug("Volume state: #{volume_state}")
|
182
|
+
}
|
183
|
+
rescue Timeout::Error
|
184
|
+
@log.error("Operation to attach volume: #{vol[:name]}, timed out")
|
185
|
+
end
|
186
|
+
|
187
|
+
if vol[:delete_on_termination] and volume_state == 'in-use'
|
188
|
+
request_resp = @ec2.modify_instance_attribute(
|
189
|
+
instance_id,
|
190
|
+
{ "BlockDeviceMapping.DeviceName" => "#{vol[:device]}",
|
191
|
+
"BlockDeviceMapping.Ebs.DeleteOnTermination" => true }
|
192
|
+
)
|
193
|
+
unless request_resp.body["return"]
|
194
|
+
@log.error("Failed to set delete_on_termination for volume: #{vol[:name]}")
|
195
|
+
end
|
196
|
+
@log.debug( request_resp.inspect )
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
121
201
|
end
|
122
202
|
|
123
203
|
def read
|
@@ -14,8 +14,9 @@ class BuildCloud::LaunchConfiguration
|
|
14
14
|
|
15
15
|
@log.debug( options.inspect )
|
16
16
|
|
17
|
-
required_options(:id, :image_id, :key_name, :
|
17
|
+
required_options(:id, :image_id, :key_name, :instance_type)
|
18
18
|
require_one_of(:security_groups, :security_group_names)
|
19
|
+
require_one_of(:user_data, :user_data_file, :user_data_template)
|
19
20
|
|
20
21
|
end
|
21
22
|
|
@@ -39,7 +40,39 @@ class BuildCloud::LaunchConfiguration
|
|
39
40
|
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
+
if options[:user_data]
|
44
|
+
|
45
|
+
options[:user_data] = JSON.generate( @options[:user_data] )
|
46
|
+
|
47
|
+
elsif options[:user_data_file]
|
48
|
+
|
49
|
+
user_data_file_path = File.join( Dir.pwd, options[:user_data_file])
|
50
|
+
|
51
|
+
if File.exists?( user_data_file_path )
|
52
|
+
options[:user_data] = File.read( user_data_file_path )
|
53
|
+
options.delete(:user_data_file)
|
54
|
+
else
|
55
|
+
@log.error("config lists a :user_data_file that doesn't exist at #{options[:user_data_file]}")
|
56
|
+
end
|
57
|
+
|
58
|
+
elsif options[:user_data_template]
|
59
|
+
|
60
|
+
variable_hash = options[:user_data_variables]
|
61
|
+
user_data_template_path = File.join( Dir.pwd, options[:user_data_template])
|
62
|
+
|
63
|
+
if File.exists?( user_data_template_path )
|
64
|
+
template = File.read( user_data_template_path )
|
65
|
+
### We set 'trim_mode' to '-', which supresses end of line white space on lines ending in '-%>'
|
66
|
+
### see http://ruby-doc.org/stdlib-2.1.2/libdoc/erb/rdoc/ERB.html#method-c-new
|
67
|
+
buffer = ERB.new(template,nil,'-').result(binding)
|
68
|
+
options[:user_data] = buffer
|
69
|
+
options.delete(:user_data_variables)
|
70
|
+
options.delete(:user_data_template)
|
71
|
+
else
|
72
|
+
@log.error("config lists a :user_data_template that doesn't exist at #{options[:user_data_template]}")
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
43
76
|
|
44
77
|
launch_config = @as.configurations.new( options )
|
45
78
|
launch_config.save
|
@@ -68,6 +68,7 @@ class BuildCloud::NetworkInterface
|
|
68
68
|
|
69
69
|
interface = @compute.network_interfaces.new(options)
|
70
70
|
interface.save
|
71
|
+
wait_until_ready
|
71
72
|
|
72
73
|
attributes = {}
|
73
74
|
attributes[:resource_id] = interface.network_interface_id
|
@@ -81,17 +82,21 @@ class BuildCloud::NetworkInterface
|
|
81
82
|
end
|
82
83
|
|
83
84
|
if options[:assign_new_public_ip]
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
85
|
+
### Need to use the request here, in order to support older accounts which still have
|
86
|
+
### 'EC2 Classic' regions/azs assigned
|
87
|
+
ip = @compute.allocate_address(domain='vpc')
|
88
|
+
public_ip = ip.body['publicIp']
|
89
|
+
allocation_id = ip.body['allocationId']
|
90
|
+
@compute.associate_address(nil, public_ip, interface.network_interface_id, allocation_id )
|
91
|
+
|
92
|
+
@log.info( "Assigned new public IP #{public_ip}" )
|
88
93
|
end
|
89
94
|
|
90
95
|
unless options[:existing_public_ip].nil?
|
91
96
|
ip = @compute.addresses.get(options[:existing_public_ip])
|
92
97
|
public_ip = ip.public_ip
|
93
98
|
allocation_id = ip.allocation_id
|
94
|
-
@compute.associate_address(nil,
|
99
|
+
@compute.associate_address(nil, ip.public_ip, interface.network_interface_id, allocation_id )
|
95
100
|
end
|
96
101
|
|
97
102
|
@log.debug( interface.inspect )
|
data/lib/build-cloud/route.rb
CHANGED
@@ -28,17 +28,17 @@ class BuildCloud::Route
|
|
28
28
|
|
29
29
|
options[:tags] = { 'Name' => options.delete(:name) }
|
30
30
|
|
31
|
-
unless options[:network_interface_name]
|
31
|
+
unless options[:network_interface_name].nil?
|
32
32
|
options[:network_interface_id] = BuildCloud::NetworkInterface.get_id_by_name( options[:network_interface_name] )
|
33
33
|
options.delete(:network_interface_name)
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
if options[:internet_gateway_name]
|
37
37
|
options[:internet_gateway_id] = BuildCloud::InternetGateway.get_id_by_name( options[:internet_gateway_name] )
|
38
38
|
options.delete(:internet_gateway_name)
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
if options[:route_table_name]
|
42
42
|
options[:route_table_id] = BuildCloud::RouteTable.get_id_by_name( options[:route_table_name] )
|
43
43
|
options.delete(:route_table_name)
|
44
44
|
end
|
@@ -46,14 +46,14 @@ class BuildCloud::Route
|
|
46
46
|
route_table_id = options[:route_table_id]
|
47
47
|
destination_cidr_block = options[:destination_cidr_block]
|
48
48
|
internet_gateway_id = options[:internet_gateway_id]
|
49
|
-
network_interface_id = options[:network_interface_id]
|
49
|
+
network_interface_id = options[:network_interface_id] ||= nil
|
50
50
|
|
51
51
|
# Using requests instead of model here, because the model
|
52
52
|
# doesn't support associations.
|
53
53
|
|
54
54
|
begin
|
55
55
|
|
56
|
-
if create_route(route_table_id, destination_cidr_block, internet_gateway_id, nil, network_interface_id)
|
56
|
+
if @compute.create_route(route_table_id, destination_cidr_block, internet_gateway_id, nil, network_interface_id)
|
57
57
|
@log.debug("route created successfully")
|
58
58
|
else
|
59
59
|
@log.debug("failed to create route")
|
@@ -67,12 +67,10 @@ class BuildCloud::Route
|
|
67
67
|
|
68
68
|
def read
|
69
69
|
rt = @compute.route_tables.select { |rt| rt.tags['Name'] == @options[:name] }.first
|
70
|
-
@log.
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@log.info( route.inspect )
|
75
|
-
|
70
|
+
@log.debug( rt.inspect )
|
71
|
+
route = rt.routes.select { |t| t['destinationCidrBlock'] == @options[:destination_cidr_block]}.first unless rt.nil?
|
72
|
+
@log.debug( route.inspect )
|
73
|
+
return true unless route.nil?
|
76
74
|
end
|
77
75
|
|
78
76
|
alias_method :fog_object, :read
|
@@ -81,9 +79,11 @@ class BuildCloud::Route
|
|
81
79
|
|
82
80
|
return unless exists?
|
83
81
|
|
84
|
-
|
82
|
+
options = @options.dup
|
83
|
+
|
84
|
+
@log.info("Deleting route #{options[:name]}")
|
85
85
|
|
86
|
-
unless options[:route_table_name]
|
86
|
+
unless options[:route_table_name].nil?
|
87
87
|
options[:route_table_id] = BuildCloud::RouteTable.get_id_by_name( options[:route_table_name] )
|
88
88
|
options.delete(:route_table_name)
|
89
89
|
end
|
@@ -93,7 +93,7 @@ class BuildCloud::Route
|
|
93
93
|
|
94
94
|
begin
|
95
95
|
|
96
|
-
if delete_route(route_table_id, destination_cidr_block)
|
96
|
+
if @compute.delete_route(route_table_id, destination_cidr_block)
|
97
97
|
@log.debug("route deleted successfully")
|
98
98
|
else
|
99
99
|
@log.debug("failed to delet route")
|
@@ -18,7 +18,7 @@ class BuildCloud::RouteTable
|
|
18
18
|
raise "Couldn't get a RouteTable fog object for #{name} - is it created?"
|
19
19
|
end
|
20
20
|
|
21
|
-
route_table_fog.
|
21
|
+
route_table_fog.id
|
22
22
|
|
23
23
|
end
|
24
24
|
|
@@ -73,6 +73,9 @@ class BuildCloud::RouteTable
|
|
73
73
|
rt.save
|
74
74
|
@log.debug(rt.inspect)
|
75
75
|
|
76
|
+
### sometimes tag creation will fail unless we wait until the API catches up:
|
77
|
+
wait_until_ready
|
78
|
+
|
76
79
|
@compute.create_tags( rt.id, options[:tags] )
|
77
80
|
|
78
81
|
options[:subnet_ids].each do |s|
|
data/lib/build-cloud/subnet.rb
CHANGED
@@ -53,14 +53,18 @@ class BuildCloud::Subnet
|
|
53
53
|
subnet = @compute.subnets.new( options )
|
54
54
|
subnet.save
|
55
55
|
|
56
|
-
options[:tag_set]
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
56
|
+
if options[:tag_set]
|
57
|
+
|
58
|
+
options[:tag_set].each do | tag |
|
59
|
+
attributes = {}
|
60
|
+
attributes[:resource_id] = subnet.subnet_id.to_s
|
61
|
+
attributes[:key] = tag[:key]
|
62
|
+
attributes[:value] = tag[:value]
|
63
|
+
new_tag = @compute.tags.new( attributes )
|
64
|
+
new_tag.save
|
65
|
+
end unless options[:tag_set].empty? or options[:tag_set].nil?
|
66
|
+
|
67
|
+
end
|
64
68
|
|
65
69
|
@log.debug( subnet.inspect )
|
66
70
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Scale Factory
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,42 +28,42 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: fog
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - '>='
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.22.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - '>='
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.22.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '>='
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.9.12.6
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '>='
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.9.12.6
|
69
69
|
description:
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/build-cloud/dbparametergroup.rb
|
91
91
|
- lib/build-cloud/dbparameters.rb
|
92
92
|
- lib/build-cloud/dbsubnetgroup.rb
|
93
|
+
- lib/build-cloud/ebsvolume.rb
|
93
94
|
- lib/build-cloud/iamrole.rb
|
94
95
|
- lib/build-cloud/instance.rb
|
95
96
|
- lib/build-cloud/internetgateway.rb
|
@@ -115,17 +116,17 @@ require_paths:
|
|
115
116
|
- lib
|
116
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
117
118
|
requirements:
|
118
|
-
- - '>='
|
119
|
+
- - ! '>='
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
123
|
requirements:
|
123
|
-
- - '>='
|
124
|
+
- - ! '>='
|
124
125
|
- !ruby/object:Gem::Version
|
125
126
|
version: '0'
|
126
127
|
requirements: []
|
127
128
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.4.1
|
129
130
|
signing_key:
|
130
131
|
specification_version: 4
|
131
132
|
summary: Tools for building resources in AWS
|