swa 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96696427a2dd6945724b752802f7e041023ef335
4
- data.tar.gz: 099a422f4ebf6102bddf91ad7c39ef46e673fae0
3
+ metadata.gz: edb6eed402b48a9becd4603b16ce035cbfb4506b
4
+ data.tar.gz: 01990ca10d51726866bd933ce6b1393f7f5c076e
5
5
  SHA512:
6
- metadata.gz: d72ae93fa0a477e5abab21fd018763597ccd1f1042a27c52625f13e6f5d5c1c574181be76251124867181eb5a4c54d2745b0c05d3ec63b3264229f157543427d
7
- data.tar.gz: a71e19e5f19ab55af892fd48fbb54fab9037962ae4c4351e9606c4392c1b26e46a9450ea62526595687dfbc74d66dd6b2e6ce5ec0650125da07f0869c0ae6f63
6
+ metadata.gz: c94db3dd53d1fd461c2ef75ee64e47db90d8efee0d26ac5547713ffd5c547e6bed0dae2cb4d8ffe5dfd6a07fc694c684a2cef2b11dbfafddf6ecfa4a140c5bea
7
+ data.tar.gz: fac54c6cef75b2c85d12cb974a4084eb8556b87588ff133a50c1997b915abfdcbdbaf2f944cd9ff588886a54c669863a5526fd8eed7572adb55358963a428262
@@ -7,6 +7,7 @@ require "swa/ec2/key_pair"
7
7
  require "swa/ec2/image"
8
8
  require "swa/ec2/instance"
9
9
  require "swa/ec2/security_group"
10
+ require "swa/ec2/snapshot"
10
11
  require "swa/ec2/volume"
11
12
 
12
13
  module Swa
@@ -201,7 +202,44 @@ module Swa
201
202
 
202
203
  end
203
204
 
204
- subcommand ["volume", "vol", "v"], "Show volume" do
205
+ subcommand ["snapshot", "snap"], "Show snapshot" do
206
+
207
+ parameter "SNAPSHOT-ID", "snapshot id"
208
+
209
+ include ItemBehaviour
210
+
211
+ private
212
+
213
+ def snapshot
214
+ Swa::EC2::Snapshot.new(ec2.snapshot(snapshot_id))
215
+ end
216
+
217
+ alias_method :item, :snapshot
218
+
219
+ end
220
+
221
+ subcommand ["snapshots", "snaps"], "List snapshots" do
222
+
223
+ option "--owned-by", "OWNER", "with specified owner", :default => "self"
224
+
225
+ include TagFilterOptions
226
+ include CollectionBehaviour
227
+
228
+ private
229
+
230
+ def snapshots
231
+ options = {
232
+ :owner_ids => [owned_by]
233
+ }
234
+ options[:filters] = filters unless filters.empty?
235
+ Swa::EC2::Snapshot.list(ec2.snapshots(options))
236
+ end
237
+
238
+ alias_method :collection, :snapshots
239
+
240
+ end
241
+
242
+ subcommand ["volume", "vol"], "Show volume" do
205
243
 
206
244
  parameter "VOLUME-ID", "volume id"
207
245
 
@@ -217,7 +255,7 @@ module Swa
217
255
 
218
256
  end
219
257
 
220
- subcommand ["volumes", "vs"], "List volumes" do
258
+ subcommand ["volumes", "vols"], "List volumes" do
221
259
 
222
260
  include TagFilterOptions
223
261
  include CollectionBehaviour
@@ -13,6 +13,11 @@ module Swa
13
13
  s.ljust(width)
14
14
  end
15
15
 
16
+ def rpad(s, width)
17
+ s = (s || "").to_s
18
+ s.rjust(width)
19
+ end
20
+
16
21
  def camelize_keys(data)
17
22
  case data
18
23
  when Hash
@@ -0,0 +1,34 @@
1
+ require "forwardable"
2
+ require "swa/resource"
3
+ require "swa/ec2/tagged_resource"
4
+
5
+ module Swa
6
+ module EC2
7
+
8
+ class Snapshot < Resource
9
+
10
+ include TaggedResource
11
+
12
+ def summary
13
+ [
14
+ pad(s.snapshot_id, 13),
15
+ pad(s.volume_id, 12),
16
+ sprintf("%4d ", s.volume_size),
17
+ s.start_time.iso8601,
18
+ rpad(s.progress, 5),
19
+ quoted(s.description)
20
+ ].join(" ")
21
+ end
22
+
23
+ extend Forwardable
24
+
25
+ def_delegators :s, :delete
26
+
27
+ private
28
+
29
+ alias_method :s, :aws_resource
30
+
31
+ end
32
+
33
+ end
34
+ end
data/lib/swa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Swa
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
@@ -139,6 +139,7 @@ files:
139
139
  - lib/swa/ec2/instance.rb
140
140
  - lib/swa/ec2/key_pair.rb
141
141
  - lib/swa/ec2/security_group.rb
142
+ - lib/swa/ec2/snapshot.rb
142
143
  - lib/swa/ec2/tagged_resource.rb
143
144
  - lib/swa/ec2/volume.rb
144
145
  - lib/swa/resource.rb