ec2launcher 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/ec2launcher.rb +15 -7
- data/lib/ec2launcher/block_device_builder.rb +9 -9
- data/lib/ec2launcher/version.rb +1 -1
- data/startup-scripts/setup_instance.rb +3 -0
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/lib/ec2launcher.rb
CHANGED
@@ -23,8 +23,6 @@ require 'ec2launcher/route53'
|
|
23
23
|
|
24
24
|
require 'ec2launcher/config_wrapper'
|
25
25
|
|
26
|
-
include Log4r
|
27
|
-
|
28
26
|
module EC2Launcher
|
29
27
|
|
30
28
|
class AmiDetails
|
@@ -48,12 +46,19 @@ module EC2Launcher
|
|
48
46
|
@setup_script_cache = nil
|
49
47
|
@setup_instance_script_cache = nil
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
begin
|
50
|
+
@log = Log4r::Logger['ec2launcher']
|
51
|
+
unless @log
|
52
|
+
@log = Log4r::Logger.new 'ec2launcher'
|
53
|
+
log_output = Log4r::Outputter.stdout
|
54
|
+
log_output.formatter = PatternFormatter.new :pattern => "%m"
|
55
|
+
@log.outputters = log_output
|
56
|
+
end
|
57
|
+
rescue
|
58
|
+
end
|
55
59
|
end
|
56
60
|
|
61
|
+
public
|
57
62
|
def launch(options)
|
58
63
|
@options = options
|
59
64
|
|
@@ -434,7 +439,8 @@ module EC2Launcher
|
|
434
439
|
##############################
|
435
440
|
# COMPLETED
|
436
441
|
##############################
|
437
|
-
@log.info "********************"
|
442
|
+
@log.info "********************"
|
443
|
+
instances
|
438
444
|
end
|
439
445
|
|
440
446
|
# Attaches an instance to the specified ELB.
|
@@ -542,6 +548,7 @@ module EC2Launcher
|
|
542
548
|
#
|
543
549
|
# @return [String] DNS for the instance or "n/a" if undefined.
|
544
550
|
#
|
551
|
+
public
|
545
552
|
def get_instance_dns(ec2_instance, public = true)
|
546
553
|
dns_name = public ? ec2_instance.public_dns_name : ec2_instance.private_dns_name
|
547
554
|
dns_name.nil? ? "n/a" : dns_name
|
@@ -570,6 +577,7 @@ module EC2Launcher
|
|
570
577
|
# }
|
571
578
|
#
|
572
579
|
# @return [AWS::EC2::Instance] newly created EC2 instance or nil if the launch failed.
|
580
|
+
public
|
573
581
|
def launch_instance(launch_options, user_data)
|
574
582
|
@log.warn "Launching instance... #{launch_options[:fqdn]}"
|
575
583
|
new_instance = nil
|
@@ -5,8 +5,6 @@ require 'ec2launcher/defaults'
|
|
5
5
|
require 'ec2launcher/backoff_runner'
|
6
6
|
require 'log4r'
|
7
7
|
|
8
|
-
include Log4r
|
9
|
-
|
10
8
|
module EC2Launcher
|
11
9
|
# Helper class to build EC2 block device definitions.
|
12
10
|
#
|
@@ -86,8 +84,6 @@ module EC2Launcher
|
|
86
84
|
block_device_tags
|
87
85
|
end
|
88
86
|
|
89
|
-
private
|
90
|
-
|
91
87
|
# Iterates over a number of block_devices, executing the specified Ruby block.
|
92
88
|
#
|
93
89
|
# @param [Integer] count number of block devices
|
@@ -95,6 +91,7 @@ module EC2Launcher
|
|
95
91
|
# Incremented for each iteration.
|
96
92
|
# @param [Block] block block to execute. Passes in the current device name and zero-based index.
|
97
93
|
#
|
94
|
+
private
|
98
95
|
def build_block_devices(count, device = "sdf", &block)
|
99
96
|
device_name = device
|
100
97
|
0.upto(count - 1).each do |index|
|
@@ -108,6 +105,7 @@ module EC2Launcher
|
|
108
105
|
# @param [Hash<String, Hash>] block_device_mappings Mapping of device names to EBS block device details.
|
109
106
|
# @param [Array<EC2Launcher::BlockDevice>] block_devices list of block devices to create.
|
110
107
|
#
|
108
|
+
private
|
111
109
|
def build_ebs_volumes(block_device_mappings, block_devices)
|
112
110
|
return if block_devices.nil?
|
113
111
|
base_device_name = "sdf"
|
@@ -131,6 +129,7 @@ module EC2Launcher
|
|
131
129
|
# @param [Hash<String, Hash>] block_devices Map of device names to EC2 block device details.
|
132
130
|
# @param [String] instance_type type of instance. See EC2Launcher::Defaults::INSTANCE_TYPES.
|
133
131
|
#
|
132
|
+
private
|
134
133
|
def build_ephemeral_drives(block_device_mappings, instance_type)
|
135
134
|
ephemeral_drive_count = case instance_type
|
136
135
|
when "m1.small" then 1
|
@@ -159,6 +158,7 @@ module EC2Launcher
|
|
159
158
|
# @param [EC2Launcher::Application] application current application
|
160
159
|
# @param [String] clone_host name of host to clone
|
161
160
|
#
|
161
|
+
private
|
162
162
|
def clone_volumes(block_device_mappings, application, clone_host = nil)
|
163
163
|
return if clone_host.nil?
|
164
164
|
|
@@ -183,12 +183,12 @@ module EC2Launcher
|
|
183
183
|
AWS.stop_memoizing
|
184
184
|
end
|
185
185
|
|
186
|
-
private
|
187
186
|
# @param [String] purpose purpose of RAID array, which is stored in the `purpose` tag for snapshots/volumes
|
188
187
|
# and is part of the snapshot name.
|
189
188
|
# @param [AWS::EC2::SnapshotCollection] snapshots collection of snapshots to examine
|
190
189
|
#
|
191
190
|
# @return [Array<AWS::EC2::Snapshot>] list of matching snapshots
|
191
|
+
private
|
192
192
|
def build_snapshot_clone_list(purpose, snapshots)
|
193
193
|
snapshot_name_regex = /#{purpose} raid.*/
|
194
194
|
host_snapshots = []
|
@@ -206,11 +206,11 @@ module EC2Launcher
|
|
206
206
|
host_snapshots
|
207
207
|
end
|
208
208
|
|
209
|
-
private
|
210
209
|
# Creates a mapping of volume numbers to snapshots.
|
211
210
|
#
|
212
211
|
# @param [Array<AWS::EC2::Snapshot>] snapshots list of matching snapshots
|
213
212
|
# @result [Hash<String, AWS::EC2::Snapshot>] map of volume numbers as strings ("1", "2", etc.) to snapshots
|
213
|
+
private
|
214
214
|
def bucket_snapshots_by_volume_number(snapshots)
|
215
215
|
snapshot_buckets = { }
|
216
216
|
volume_number_regex = /raid \((\d)\)$/
|
@@ -233,10 +233,10 @@ module EC2Launcher
|
|
233
233
|
snapshot_buckets
|
234
234
|
end
|
235
235
|
|
236
|
-
private
|
237
236
|
# Find the most recent backup time that all snapshots have in common.
|
238
237
|
#
|
239
238
|
# @param [Hash<String, AWS::EC2::Snapshot>] snapshot_buckets map of volume numbers as strings ("1", "2", etc.) to snapshots
|
239
|
+
public
|
240
240
|
def get_most_recent_common_snapshot_time(snapshot_buckets)
|
241
241
|
# We need to find the most recent backup time that all snapshots have in common.
|
242
242
|
#
|
@@ -261,7 +261,6 @@ module EC2Launcher
|
|
261
261
|
most_recent_dates[0]
|
262
262
|
end
|
263
263
|
|
264
|
-
public
|
265
264
|
# Retrieves the latest set of completed snapshots for a RAID array of EBS volumes.
|
266
265
|
#
|
267
266
|
# Volumes must have the following tags:
|
@@ -276,12 +275,12 @@ module EC2Launcher
|
|
276
275
|
#
|
277
276
|
# @return [Hash<Integer, AWS::EC2::Snapshot>] mapping of RAID device numbers (zero based) to AWS Snapshots.
|
278
277
|
#
|
278
|
+
public
|
279
279
|
def get_latest_raid_snapshot_mapping(hostname, purpose, count)
|
280
280
|
@log.info "Retrieving list of snapshots ..."
|
281
281
|
result = @ec2.snapshots.tagged("host").tagged_values(hostname).tagged("volumeName").tagged_values("*raid*").tagged("time")
|
282
282
|
|
283
283
|
@log.info "Building list of snapshots to clone (#{purpose}) for '#{hostname}'..."
|
284
|
-
snapshot_name_regex = /#{purpose} raid.*/
|
285
284
|
host_snapshots = build_snapshot_clone_list(purpose, result)
|
286
285
|
|
287
286
|
# Bucket the snapshots based on volume number e.g. "raid (1)" vs "raid (2)"
|
@@ -326,6 +325,7 @@ module EC2Launcher
|
|
326
325
|
#
|
327
326
|
# @return [AWS::EC2::Snapshot, nil] matching snapshot or nil if no matching snapshot
|
328
327
|
#
|
328
|
+
public
|
329
329
|
def get_latest_snapshot_by_purpose(clone_host, purpose)
|
330
330
|
@log.info "Retrieving snapshtos for #{clone_host} [#{purpose}]"
|
331
331
|
results = @ec2.snapshots.tagged("host").tagged_values(clone_host).tagged("purpose").tagged_values(purpose)
|
data/lib/ec2launcher/version.rb
CHANGED
@@ -443,8 +443,11 @@ EOF
|
|
443
443
|
# Creates a mount point, mounts the device and adds it to fstab
|
444
444
|
def mount_device(device, mount_point, owner, group, fs_type)
|
445
445
|
puts `echo #{device} #{mount_point} #{fs_type} noatime 0 0|tee -a /etc/fstab`
|
446
|
+
puts "Making mount directory #{mount_point} for #{device}"
|
446
447
|
puts `mkdir -p #{mount_point}`
|
448
|
+
puts "Mounting #{device} at #{mount_point}"
|
447
449
|
puts `mount #{mount_point}`
|
450
|
+
puts "Setting ownership on #{mount_point} to #{owner}"
|
448
451
|
puts `chown #{owner}:#{owner} #{mount_point}`
|
449
452
|
end
|
450
453
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ec2launcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|