awscli 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -19,7 +19,12 @@ More interfaces are in development.
19
19
 
20
20
  To Install Use:
21
21
 
22
- `gem install awscli`
22
+ ```
23
+ sudo gem install awscli
24
+ ```
25
+
26
+ Note: `awscli` depends on nokogiri gem which needs to be compiled and dynamically linked against both libxml2 and libxslt, for installing dependencies follow this link:
27
+ <http://nokogiri.org/tutorials/installing_nokogiri.html>
23
28
 
24
29
  For help using cli:
25
30
 
@@ -33,4 +38,4 @@ $ awscli <interface> help
33
38
 
34
39
  Licence:
35
40
 
36
- `awscli` is released under the terms of the MIT License, see the included LICENSE file.
41
+ `awscli` is released under the terms of the MIT License, see the included LICENSE file.
@@ -192,6 +192,13 @@ module AwsCli
192
192
  @ec2.terminate_instance options[:instance_id]
193
193
  end
194
194
 
195
+ desc "terminate_all", "terminate all running instances (causes data loss)"
196
+ method_option :delete_volumes, :aliases => "-v", :type => :boolean, :desc => "delete the ebs volumes attached to instance if any", :default => false
197
+ def terminate_all
198
+ create_ec2_object
199
+ @ec2.terminate_instances options[:delete_volumes]
200
+ end
201
+
195
202
  desc "console_output", "Retrieve console output for specified instance"
196
203
  method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id to get console output from"
197
204
  def console_output
data/lib/awscli/ec2.rb CHANGED
@@ -184,9 +184,35 @@ module Awscli
184
184
  end
185
185
  end
186
186
 
187
+ # terminates all the instances that are running
188
+ def terminate_instances(delete_attached_volumes = false)
189
+ block_mappings = []
190
+ if agree('Are you sure want to delete all the servers that are running ? ')
191
+ @conn.servers.all.each do |server|
192
+ server.destroy if server.state == 'running'
193
+ block_mappings << server.block_device_mapping
194
+ end
195
+ end
196
+ if delete_attached_volumes
197
+ if agree('Are you sure you want to delete the volumes attached to the instance as well? ')
198
+ unless block_mappings.length == 0
199
+ block_mappings.each do |server|
200
+ server.each do |map|
201
+ vol = @conn.volumes.get(map['volumeId'])
202
+ vol.wait_for { vol.state == 'available' }
203
+ vol.destroy if map['deleteOnTermination'] != 'true'
204
+ end
205
+ end
206
+ end
207
+ end
208
+ end
209
+ end
210
+
211
+ # get the console_output from instance
187
212
  def get_console_output(instance_id)
188
213
  response = @conn.get_console_output(instance_id)
189
- puts response
214
+ output = response.data['output']
215
+ output.nil? ? puts('No console output attached yet!') : puts(output)
190
216
  end
191
217
 
192
218
  end # => EC2
@@ -1,3 +1,3 @@
1
1
  module Awscli
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
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.1.5
4
+ version: 0.1.6
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-04-16 00:00:00.000000000 Z
12
+ date: 2013-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake