aws-cache 0.0.05 → 0.0.06

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzM2ZDViMjAyYTA5MmFmNThmM2IwZDE5MTkwMzBjZGY0NDQ3NGI0OA==
4
+ NTA3ZWJjZjMzZTBkZDRkODc5MTc3YmM0ZGM1NmQ2NTJjMjdmOTQ0Mg==
5
5
  data.tar.gz: !binary |-
6
- ZWFmYTFjNDUyYjQzYzQzMzliNGQ2ODJlOGQ2NjJjZmE3NmQ4N2VmZg==
6
+ N2RiMjg5ZWM2YmExOWRkNzY2M2RlOWM4YTBhY2I2YTFkNmQ4NzA3ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTg5YTRiNDQyZTI2YWVjMzg5OGQxOWFlYzQ3ZTNmMWFlMGZjNzAzNjVhODQ4
10
- N2NhZGM4MDgyMjRhMmU1Yjg1ZGNiMjlkOTNkMGI4NTNhNzM4MzQ1NDQxZjdm
11
- OTU4OTBlMWZlODYwMGNhNWJkMTVhZjhjNTMwNWYxODI4NjA0ZDY=
9
+ MDc3N2Q2MjY5NTRmZjk4Y2ZmZTJhYzExN2RiODAxMDIyOGFhNjRhYTAwOWU0
10
+ YTk1ZTAyY2Y5YTYzMmU2OTBiNjIwYWRjMjQzZmE1YTc2ZGIwNTFiODkyZjU5
11
+ ZWQ5NDY2MGJhN2QzYzI0MDdmMDdhYjU0NDFlZTQxYjFhOGM5Yzk=
12
12
  data.tar.gz: !binary |-
13
- YWZiYTMxOTNhZDQ4ZThmYjI3NGUzNzJiZDU3OWViNTQwMGRhZjFiNmMwNTAy
14
- MTM4YzUzZTU0NThkYjBlMmQ0ZDdiMTU0ZGMyYjY0ZGNhNGFkMjM4NzE4YTM2
15
- MjNiYWE4ZDFkNzJkMTgxNjlhMjhlNDg3YjVkYTk3Zjg4MzIyZjc=
13
+ Yzk1ZTkyNWU0MGYxYWE1ODI2N2QzNDlkNThkNGFmNzQ1MmY4YThiOGQwNDJh
14
+ OWI4MmRjYmFlZDdmZTFmYzhhYmM5YjEzNjE4MTg4YzUwNDI3Y2NkOTJmYTkz
15
+ MzhhNjVlZmY5YzgyMzllMDY3ODkyNjkzODBlYjljZTk5YmQ0N2U=
@@ -1,4 +1,4 @@
1
1
  module AwsCacheVersion
2
2
  # Please follow semantic versioning (semver.org).
3
- VERSION = '0.0.05'
3
+ VERSION = '0.0.06'
4
4
  end
@@ -10,9 +10,11 @@ class AwsCache
10
10
  VERSION = AwsCacheVersion::VERSION
11
11
 
12
12
  def initialize(opts)
13
+ unless opts.has_key?('port') then opts['port'] = 6379 end
14
+ unless opts.has_key?('host') then opts['host'] = 'aws-cache' end
13
15
  @redis = optional_element(opts, ['redis'])
14
16
  if @redis.nil?
15
- @redis = Redis.new(url: 'redis://aws-cache:6379/0')
17
+ @redis = Redis.new(url: "redis://#{opts['host']}:#{opts['port']}/0")
16
18
  end
17
19
  @keyspace = optional_element(opts, ['keyspace'], AwsCache::VERSION)
18
20
  @region = optional_element(opts, ['region'], 'us-east-1')
@@ -23,9 +25,9 @@ class AwsCache
23
25
  instances = {}
24
26
 
25
27
  ec2 = Aws::EC2::Client.new(region: @region)
26
- page = ec2.describe_instances
27
- page.each do |page|
28
- page =
28
+ pages = ec2.describe_instances
29
+ pages.each do |page|
30
+ page =
29
31
  page.data[:reservations].each do |res|
30
32
  res[:instances].each do |instance|
31
33
  list_to_hash!(instance, [:tags], :key)
@@ -57,10 +59,10 @@ class AwsCache
57
59
  groups = {}
58
60
 
59
61
  autoscaling = Aws::AutoScaling::Client.new(region: @region)
60
- page = autoscaling.describe_auto_scaling_groups
61
- page.each do |page|
62
+ pages = autoscaling.describe_auto_scaling_groups
63
+ pages.each do |page|
62
64
  page.data[:auto_scaling_groups].each do |group|
63
- instances = {}
65
+ instances = Hash.new()
64
66
  list_to_hash!(group, [:instances], :instance_id)
65
67
  list_to_hash!(group, [:tags], :key)
66
68
  groups[group[:auto_scaling_group_name]] = group
@@ -89,8 +91,8 @@ class AwsCache
89
91
  cloudformation_stacks = {}
90
92
 
91
93
  cfn = Aws::CloudFormation::Client.new(region: @region)
92
- page = cfn.describe_stacks
93
- page.each do |page|
94
+ pages = cfn.describe_stacks
95
+ pages.each do |page|
94
96
  page.data[:stacks].each do |stack|
95
97
  list_to_hash!(stack, [:parameters], :parameter_key)
96
98
  list_to_hash!(stack, [:outputs], :output_key)
@@ -115,8 +117,8 @@ class AwsCache
115
117
  stack_resources = {}
116
118
  cfn = Aws::CloudFormation::Client.new(region: @region)
117
119
 
118
- page = cfn.list_stack_resources(stack_name: stack_name)
119
- page.each do |page|
120
+ pages = cfn.list_stack_resources(stack_name: stack_name)
121
+ pages.each do |page|
120
122
  resources = page.data[:stack_resource_summaries]
121
123
  resources.each do |resource|
122
124
  stack_resources[resource[:logical_resource_id]] = resource
@@ -138,8 +140,8 @@ class AwsCache
138
140
  stacks = []
139
141
 
140
142
  cfn = Aws::CloudFormation::Client.new(region: @region)
141
- page = cfn.list_stacks
142
- page.each do |page|
143
+ pages = cfn.list_stacks
144
+ pages.each do |page|
143
145
  page.data[:stack_summaries].each do |stack|
144
146
  stacks.push(stack)
145
147
  end
@@ -151,6 +153,29 @@ class AwsCache
151
153
  return stacks
152
154
  end
153
155
 
156
+ def get_snapshots()
157
+ snapshots = cache_get('aws_ec2_snapshots', 9) do
158
+ snapshots = Hash.new()
159
+ ec2 = Aws::EC2::Client.new(region: @region)
160
+ pages = ec2.describe_snapshots
161
+ pages.each do |page|
162
+ page.data.each do |data|
163
+ data.each do |snap|
164
+ if snapshots.has_key?(snap[:volume_id]) then
165
+ snapshots[snap[:volume_id]].push(snap)
166
+ else
167
+ snapshots[snap[:volume_id]] = Array.new()
168
+ snapshots[snap[:volume_id]].push(snap)
169
+ end
170
+ end
171
+ end
172
+ end
173
+ snapshots
174
+ end
175
+ return snapshots
176
+ end
177
+
178
+
154
179
  private
155
180
  def optional_element(hash, keys, default=nil)
156
181
  keys.each do |key|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.05
4
+ version: 0.0.06
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen J. Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-21 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk