instance_selector 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb2b44d579472c7c234a48fb6d9892ecebf006ec
4
- data.tar.gz: 2243b19c9f711da2f51f695fbb0faa0ccb24d65c
3
+ metadata.gz: 6bf8913d19e961b3b2bf2483471ab2977ed3df19
4
+ data.tar.gz: fc210a3b0dc754c62884127a3cdba34ca5c90397
5
5
  SHA512:
6
- metadata.gz: 5e268509740d28db122682dc70e12b8dcd6f568106616757188d4290025af58fccca199dbdd9dae1cdee3729c20ef6b66627cb4555d623737c3f7f844cb0256a
7
- data.tar.gz: 477a13c805017e7e21aeac5a3875effc27ce37d0d981b95c7e924b628f7ec451af19f8c7f041229157aaca341cb38ad597997cb9fa85d6994f7a2618c66397fb
6
+ metadata.gz: 8cb934239d57e47027dcd7d3fa4aaa478854892efcc7a570a6396bdc9ce87a2d658c9d0f6da0ff407a5428ba2b3f281276391a29d78724ffde7406f4ebb995e9
7
+ data.tar.gz: 19533d33a80aac59de41403c4a854771db2b544667318e13b68a09e61b04a38283c557ecb08d143aaad829b4f5d6bdd12bf4e5d1c988b91b8da83a8516e79d51
@@ -13,11 +13,9 @@ module InstanceSelector
13
13
  end
14
14
  end
15
15
 
16
- def instances(filters={})
17
- instances = @fog.describe_instances({"instance-state-name" => "running"}.merge(filters))
18
-
19
- instances.body['reservationSet'].inject({}) do |memo, i|
20
16
 
17
+ def dns_from_instance_reservation_set(reservation_set)
18
+ reservation_set.inject({}) do |memo, i|
21
19
  # Each instancesSet can have multiple instances
22
20
  # Odd, but explains why it's plural.
23
21
  i['instancesSet'].each do |instance|
@@ -30,6 +28,32 @@ module InstanceSelector
30
28
  end
31
29
  end
32
30
 
31
+ def on_demand_instances(filters={})
32
+ instances = @fog.describe_instances({"instance-state-name" => "running"}.merge(filters))
33
+
34
+ dns_from_instance_reservation_set instances.body['reservationSet']
35
+ end
36
+
37
+ def spot_instances(filters={})
38
+ requests = @fog.describe_spot_instance_requests({'state' => 'active'}.merge(filters))
39
+ requests.body['spotInstanceRequestSet'].inject({}) do |memo, req|
40
+
41
+ if req['instanceId'] && !req['instanceId'].empty?
42
+ instances = @fog.describe_instances('instance-id' => req['instanceId'])
43
+ memo.merge! dns_from_instance_reservation_set(instances.body['reservationSet'])
44
+ end
45
+
46
+ memo
47
+ end
48
+ end
49
+
50
+
51
+ def instances(filters={})
52
+ on_demand = on_demand_instances(filters)
53
+ spot = spot_instances(filters)
54
+ on_demand.merge(spot)
55
+ end
56
+
33
57
  def connect
34
58
  begin
35
59
  @fog = Fog::Compute.new(provider: 'AWS',
@@ -1,3 +1,3 @@
1
1
  module InstanceSelector
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instance_selector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McFadden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-17 00:00:00.000000000 Z
11
+ date: 2013-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog