57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/ftl/client.rb', line 57
def launch_instance(args)
display "Spinning up FTL..."
opts = options
opts = options.merge(options[:templates][args.first.to_sym]) if !options[:templates][args.first.to_sym].nil?
opts[:group_ids] = (opts[:group_ids] || []) + opts[:groups].select { | group | group.to_s =~ /^sg-[0-9a-f]{8}$/ }
opts[:groups] = opts[:groups].reject { | group | group.to_s =~ /^sg-[0-9a-f]{8}$/ }
launcher = options.delete(:launcher) || :servers
server = con.send(launcher).create(
:user_data => opts[:user_data],
:key_name => opts[:keypair],
:groups => opts[:groups],
:security_group_ids => opts[:group_ids],
:image_id => opts[:ami],
:availability_zone => opts[:availability_zone],
:flavor_id => opts[:instance_type],
:username => opts[:username],
:tags => opts[:tags].merge(:Name => args.first),
:subnet_id => opts[:subnet_id],
:private_ip_address => opts[:ip_private],
:ip_address => opts[:ip_address],
:price => opts[:price],
:instance_count => opts[:count]
)
display server
display "Executing :post_script..." if opts[:post_script]
eval(opts[:post_script]) if opts[:post_script]
end
|