awscli 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awscli/cli/ec2/instances.rb +24 -16
- data/lib/awscli/ec2.rb +25 -13
- data/lib/awscli/version.rb +1 -1
- metadata +2 -2
@@ -121,6 +121,10 @@ module AwsCli
|
|
121
121
|
|
122
122
|
`awscli ec2 instances create -i ami-b63210f3 -k ruby-sample-1363113606 -b "/dev/sdb=ephemeral10" "/dev/sdc=:10:false::"`
|
123
123
|
|
124
|
+
Running Multiple Instances:
|
125
|
+
|
126
|
+
`awscli ec2 instances create -i <ami_id> -c 10 -k <key_name> -b "/dev/sdd=:100:false::"`
|
127
|
+
|
124
128
|
Block Device Mapping Format:
|
125
129
|
This argument is passed in the form of <devicename>=<blockdevice>. The devicename is the device name of the physical device on the instance to map. The blockdevice can be one of the following values:
|
126
130
|
|
@@ -157,6 +161,7 @@ module AwsCli
|
|
157
161
|
method_option :tags, :type => :hash, :default => {'Name' => "awscli-#{Time.now.to_i}"}, :desc => "Tags to identify server"
|
158
162
|
method_option :private_ip_address, :banner => "IP",:type => :string, :desc => "VPC option to specify ip address within subnet"
|
159
163
|
method_option :wait_for, :aliases => "-w", :type => :boolean, :default => false, :desc => "wait for the server to get created and return public_dns"
|
164
|
+
method_option :count, :aliases => '-c', :type => :numeric, :default => 1, :desc => 'Number of instances to launch'
|
160
165
|
def create
|
161
166
|
create_ec2_object
|
162
167
|
@ec2.create_instance options
|
@@ -168,6 +173,7 @@ module AwsCli
|
|
168
173
|
method_option :flavor_id, :aliases => '-t', :default => 'm1.small', :desc => 'Type of the instance to boot'
|
169
174
|
method_option :key_name, :aliases => '-k', :required => true, :desc => 'Name of the keypair to use'
|
170
175
|
method_option :tags, :type => :hash, :default => {'Name' => "awscli-centos-#{Time.now.to_i}"}, :desc => "Tags to identify server"
|
176
|
+
method_option :wait_for, :aliases => "-w", :type => :boolean, :default => false, :desc => "wait for the server to get created and return public_dns"
|
171
177
|
def create_centos
|
172
178
|
create_ec2_object
|
173
179
|
centos_amis = {
|
@@ -180,14 +186,14 @@ module AwsCli
|
|
180
186
|
'ap-northeast-1' => 'ami-3fe8603e', #Tokyo
|
181
187
|
'sa-east-1' => 'ami-e2cd68ff', #Sao Paulo
|
182
188
|
}
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
189
|
+
@ec2.create_instance :image_id => centos_amis[parent_options[:region]],
|
190
|
+
:block_device_mapping => %w(/dev/sda=:100:true::),
|
191
|
+
:groups => options[:groups],
|
192
|
+
:flavor_id => options[:flavor_id],
|
193
|
+
:key_name => options[:key_name],
|
194
|
+
:tags => options[:tags],
|
195
|
+
:count => options[:count],
|
196
|
+
:wait_for => options[:wait_for]
|
191
197
|
end
|
192
198
|
|
193
199
|
desc 'create_ubuntu', 'Create a ubuntu based instance, ebs_backed with root being 100GB (user has to manually execute resize2fs /dev/sda1 to reclaim extra storage on root device)'
|
@@ -196,6 +202,7 @@ module AwsCli
|
|
196
202
|
method_option :flavor_id, :aliases => '-t', :default => 'm1.small', :desc => 'Type of the instance to boot'
|
197
203
|
method_option :key_name, :aliases => '-k', :required => true, :desc => 'Name of the keypair to use'
|
198
204
|
method_option :tags, :type => :hash, :default => {'Name' => "awscli-ubuntu-#{Time.now.to_i}"}, :desc => "Tags to identify server"
|
205
|
+
method_option :wait_for, :aliases => "-w", :type => :boolean, :default => false, :desc => "wait for the server to get created and return public_dns"
|
199
206
|
def create_ubuntu
|
200
207
|
create_ec2_object
|
201
208
|
ubuntu_amis = {
|
@@ -208,14 +215,15 @@ module AwsCli
|
|
208
215
|
'ap-northeast-1' => 'ami-57109956', #Tokyo
|
209
216
|
'sa-east-1' => 'ami-a4fb5eb9', #Sao Paulo
|
210
217
|
}
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
218
|
+
@ec2.create_instance :image_id => ubuntu_amis[parent_options[:region]],
|
219
|
+
:block_device_mapping => %w(/dev/sda1=:100:true::),
|
220
|
+
:groups => options[:groups],
|
221
|
+
:flavor_id => options[:flavor_id],
|
222
|
+
:key_name => options[:key_name],
|
223
|
+
:tags => options[:tags],
|
224
|
+
:count => options[:count],
|
225
|
+
:wait_for => options[:wait_for]
|
226
|
+
|
219
227
|
end
|
220
228
|
|
221
229
|
desc "start", "start instances"
|
data/lib/awscli/ec2.rb
CHANGED
@@ -117,25 +117,37 @@ module Awscli
|
|
117
117
|
if block_devices = opts.delete(:block_device_mapping)
|
118
118
|
opts.merge!(:block_device_mapping => block_device_mapping)
|
119
119
|
end
|
120
|
-
wait_for_server = options[:wait_for]
|
120
|
+
wait_for_server = options[:wait_for]
|
121
|
+
opts.reject! { |k| k == 'wait_for' }
|
122
|
+
count = options[:count]
|
123
|
+
opts.reject! { |k| k == 'count' }
|
121
124
|
puts 'Validating Options ... OK'
|
122
|
-
|
123
|
-
|
125
|
+
servers = Array.new
|
126
|
+
puts "Creating #{count} Server(s) ..."
|
127
|
+
count.times { servers << @conn.servers.create(opts) }
|
124
128
|
#wait for server to get created and return public_dns
|
125
129
|
if wait_for_server
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
+
if count == 1
|
131
|
+
print 'Waiting for server to get created'
|
132
|
+
servers.first.wait_for { print "."; ready? }
|
133
|
+
puts
|
134
|
+
puts "Server dns_name: #{servers.first.dns_name}"
|
135
|
+
else
|
136
|
+
print 'Waiting for servers to get created'
|
137
|
+
servers.each do |s|
|
138
|
+
s.wait_for { print '.'; ready? }
|
139
|
+
end
|
140
|
+
puts
|
141
|
+
puts 'Servers dns_name: '
|
142
|
+
servers.each do |s|
|
143
|
+
puts s.dns_name
|
144
|
+
end
|
145
|
+
end
|
130
146
|
end
|
131
147
|
end
|
132
148
|
|
133
|
-
## create a new instance(s)
|
134
|
-
#def run_instances options
|
135
|
-
#end
|
136
|
-
|
137
149
|
# describe instance status
|
138
|
-
def describe_instance_status(
|
150
|
+
def describe_instance_status(instance_id)
|
139
151
|
response = @conn.servers.get(instance_id)
|
140
152
|
abort "InstanceId Not found :#{instance_id}" unless response
|
141
153
|
puts "Instance #{instance_id} State: #{response.state}"
|
@@ -145,7 +157,7 @@ module Awscli
|
|
145
157
|
#def import_instance
|
146
158
|
#end
|
147
159
|
|
148
|
-
#@conn.server.get(
|
160
|
+
#@conn.server.get(instance_id).(:reboot, :save, :setup, :start, :stop)
|
149
161
|
# reboot an instance
|
150
162
|
def reboot_instance(instance_id)
|
151
163
|
response = @conn.servers.get(instance_id)
|
data/lib/awscli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awscli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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-06-
|
12
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|