pareidolia 0.14.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +54 -0
- data/LICENSE.txt +21 -0
- data/README.org +65 -0
- data/lib/pareidolia/aws/ec2/client.rb +198 -0
- data/lib/pareidolia/aws/ec2.rb +1 -0
- data/lib/pareidolia/aws.rb +1 -0
- data/lib/pareidolia.rb +1 -0
- data/pareidolia.gemspec +16 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3dedcb75f8608a1e6925b2ead8e0801c3f8ebfc1
|
4
|
+
data.tar.gz: 5182c8a05251d0e4ed397c256895034e2568f63d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a0972727f7f7eb95a37099937def133de9bb42f4f3c8abe19956d8b2f5bae72605078b0840d0cc850d00e8fb18e395f634c7131d4700b3a2c3d1fb2a6dbfd4f
|
7
|
+
data.tar.gz: 6fb32ae0c98e13426e4af6982b24a34675357d4a998859107e1d99bca6115b9e54ec03e49d846682869bfcd68bb51babf7acb8749f770190328bb4583934c252
|
data/.gitignore
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
# Created by https://www.gitignore.io/api/ruby
|
3
|
+
|
4
|
+
### Ruby ###
|
5
|
+
*.gem
|
6
|
+
*.rbc
|
7
|
+
/.config
|
8
|
+
/coverage/
|
9
|
+
/InstalledFiles
|
10
|
+
/pkg/
|
11
|
+
/spec/reports/
|
12
|
+
/spec/examples.txt
|
13
|
+
/test/tmp/
|
14
|
+
/test/version_tmp/
|
15
|
+
/tmp/
|
16
|
+
|
17
|
+
# Used by dotenv library to load environment variables.
|
18
|
+
# .env
|
19
|
+
|
20
|
+
## Specific to RubyMotion:
|
21
|
+
.dat*
|
22
|
+
.repl_history
|
23
|
+
build/
|
24
|
+
*.bridgesupport
|
25
|
+
build-iPhoneOS/
|
26
|
+
build-iPhoneSimulator/
|
27
|
+
|
28
|
+
## Specific to RubyMotion (use of CocoaPods):
|
29
|
+
#
|
30
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
31
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
32
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
33
|
+
#
|
34
|
+
# vendor/Pods/
|
35
|
+
|
36
|
+
## Documentation cache and generated files:
|
37
|
+
/.yardoc/
|
38
|
+
/_yardoc/
|
39
|
+
/doc/
|
40
|
+
/rdoc/
|
41
|
+
|
42
|
+
## Environment normalization:
|
43
|
+
/.bundle/
|
44
|
+
/vendor/bundle
|
45
|
+
/lib/bundler/man/
|
46
|
+
|
47
|
+
# for a library or gem, you might want to ignore these files since the code is
|
48
|
+
# intended to run in multiple environments; otherwise, check them in:
|
49
|
+
# Gemfile.lock
|
50
|
+
# .ruby-version
|
51
|
+
# .ruby-gemset
|
52
|
+
|
53
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
54
|
+
.rvmrc
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
The MIT License (MIT)
|
3
|
+
Copyright © 2016 Chris Olstrom <chris@olstrom.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the “Software”), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.org
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#+TITLE: Pareidolia - A Library for Clouding Coherently
|
2
|
+
#+LATEX: \pagebreak
|
3
|
+
|
4
|
+
* Overview
|
5
|
+
|
6
|
+
=pareidolia= makes aws-sdk seem more consistent than actually it is.
|
7
|
+
|
8
|
+
* Why does this exist?
|
9
|
+
|
10
|
+
=aws-sdk= is an excellent gem, but there are a lot of places where the
|
11
|
+
inconsistencies of the API show through. =pareidolia= is a thin layer on top of
|
12
|
+
this, providing the missing consistency.
|
13
|
+
|
14
|
+
* Installation
|
15
|
+
|
16
|
+
#+BEGIN_SRC shell
|
17
|
+
gem install pareidolia
|
18
|
+
#+END_SRC
|
19
|
+
|
20
|
+
* Enhancements
|
21
|
+
|
22
|
+
** Handles Rate Limiting
|
23
|
+
|
24
|
+
Rate Limit errors are handled by retrying after a randomized delay of between
|
25
|
+
=1.0= and =4.0= seconds.
|
26
|
+
|
27
|
+
** Caching
|
28
|
+
|
29
|
+
Responses are cached by default, using simple memoization. Every method
|
30
|
+
includes a ~!~ variant that ignores the cache (and updates it with the
|
31
|
+
response).
|
32
|
+
|
33
|
+
** Straightforward Response Payloads
|
34
|
+
|
35
|
+
Most AWS calls return an envelope of sorts. More confusingly, the
|
36
|
+
envelope is not consistently shaped.
|
37
|
+
|
38
|
+
- =describe_vpcs= returns a =Struct= with a =vpcs= field.
|
39
|
+
- =describe_instances= returns a =Struct= with a =reservations= field, that
|
40
|
+
in turn contains an =Array= of =Structs= with an =instances= field.
|
41
|
+
- =describe_moving_addresses= returns a =Struct= with a
|
42
|
+
=moving_address_statuses= field.
|
43
|
+
- =describe_volume_status= returns a =Struct= with a =volume_statuses= field.
|
44
|
+
- and so on.
|
45
|
+
|
46
|
+
=pareidolia= returns the *contents* of the envelope, instead.
|
47
|
+
|
48
|
+
- =vpcs= returns an =Array= of =VPC=.
|
49
|
+
- =instances= returns an =Array= of =Instance=.
|
50
|
+
- =moving_address_statuses= returns an =Array= of =MovingAddressStatus=.
|
51
|
+
- =volume_statuses= returns an =Array= of =VolumeStatus=.
|
52
|
+
|
53
|
+
** Consistent Method Names
|
54
|
+
|
55
|
+
- =reservations= returns an =Array= of =Reservation=.
|
56
|
+
- =moving_address_statuses= is an alias for =moving_addresses=
|
57
|
+
- =instance_statuses= is an alias for =instance_status=
|
58
|
+
|
59
|
+
* License
|
60
|
+
|
61
|
+
~pareidolia~ is available under the [[https://tldrlegal.com/license/mit-license][MIT License]]. See ~LICENSE.txt~ for the full text.
|
62
|
+
|
63
|
+
* Contributors
|
64
|
+
|
65
|
+
- [[https://colstrom.github.io/][Chris Olstrom]] | [[mailto:chris@olstrom.com][e-mail]] | [[https://twitter.com/ChrisOlstrom][Twitter]]
|
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
|
3
|
+
module Pareidolia
|
4
|
+
module Aws
|
5
|
+
module EC2
|
6
|
+
class Client
|
7
|
+
METHODS = ::Aws::EC2::Client.public_instance_methods(false)
|
8
|
+
DESCRIBE_METHODS = METHODS.select { |m| m.to_s.start_with? 'describe' }
|
9
|
+
|
10
|
+
def initialize(**options)
|
11
|
+
@options = options
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def classic_link_instances!
|
16
|
+
@classic_link_instances = describe_classic_link_instances.instances
|
17
|
+
end
|
18
|
+
|
19
|
+
def host_reservations!
|
20
|
+
@host_reservations = describe_host_reservations.host_reservation_set
|
21
|
+
end
|
22
|
+
|
23
|
+
def id_format!
|
24
|
+
@id_format = describe_id_format.statuses
|
25
|
+
end
|
26
|
+
|
27
|
+
def image_attribute!(**options)
|
28
|
+
describe_image_attribute options
|
29
|
+
end
|
30
|
+
|
31
|
+
alias image_attribute image_attribute!
|
32
|
+
|
33
|
+
def instance_attribute!(**options)
|
34
|
+
describe_instance_attribute options
|
35
|
+
end
|
36
|
+
|
37
|
+
alias instance_attribute instance_attribute!
|
38
|
+
|
39
|
+
def instance_status!
|
40
|
+
@instance_status = describe_instance_status.instance_statuses
|
41
|
+
end
|
42
|
+
|
43
|
+
def instance_status
|
44
|
+
@instance_status ||= instance_status!
|
45
|
+
end
|
46
|
+
|
47
|
+
alias instance_statuses! instance_status!
|
48
|
+
alias instance_statuses instance_status
|
49
|
+
|
50
|
+
def reservations!
|
51
|
+
@reservations = describe_instances.reservations
|
52
|
+
end
|
53
|
+
|
54
|
+
def reservations
|
55
|
+
@reservations ||= reservations!
|
56
|
+
end
|
57
|
+
|
58
|
+
def instances!
|
59
|
+
@instances = reservations!.flat_map(&:instances)
|
60
|
+
end
|
61
|
+
|
62
|
+
def moving_addresses!
|
63
|
+
@moving_addresses = describe_moving_addresses.moving_address_statuses
|
64
|
+
end
|
65
|
+
|
66
|
+
def moving_addresses
|
67
|
+
@moving_addresses ||= moving_addresses!
|
68
|
+
end
|
69
|
+
|
70
|
+
alias moving_address_statuses! moving_addresses!
|
71
|
+
alias moving_address_statuses moving_addresses
|
72
|
+
|
73
|
+
def network_interface_attribute!(**options)
|
74
|
+
describe_network_interface_attribute options
|
75
|
+
end
|
76
|
+
|
77
|
+
alias network_interface_attribute network_interface_attribute!
|
78
|
+
|
79
|
+
def scheduled_instance_availability!(**options)
|
80
|
+
describe_scheduled_instance_availability options
|
81
|
+
end
|
82
|
+
|
83
|
+
alias scheduled_instance_availability scheduled_instance_availability!
|
84
|
+
|
85
|
+
def scheduled_instances!
|
86
|
+
@scheduled_instances = describe_scheduled_instances.scheduled_instance_set
|
87
|
+
end
|
88
|
+
|
89
|
+
def security_group_references!(**options)
|
90
|
+
describe_security_group_references(options).security_group_reference_set
|
91
|
+
end
|
92
|
+
|
93
|
+
alias security_group_references security_group_references!
|
94
|
+
|
95
|
+
def snapshot_attribute!(**options)
|
96
|
+
describe_snapshot_attribute options
|
97
|
+
end
|
98
|
+
|
99
|
+
alias snapshot_attribute snapshot_attribute!
|
100
|
+
|
101
|
+
def spot_fleet_instances!(**options)
|
102
|
+
describe_spot_fleet_instances options
|
103
|
+
end
|
104
|
+
|
105
|
+
alias spot_fleet_instances spot_fleet_instances!
|
106
|
+
|
107
|
+
def spot_fleet_request_history!(**options)
|
108
|
+
describe_spot_fleet_request_history options
|
109
|
+
end
|
110
|
+
|
111
|
+
alias spot_fleet_request_history spot_fleet_request_history!
|
112
|
+
|
113
|
+
def spot_fleet_requests!
|
114
|
+
@spot_fleet_requests = describe_spot_fleet_requests.spot_fleet_request_configs
|
115
|
+
end
|
116
|
+
|
117
|
+
def stale_security_groups!(**options)
|
118
|
+
describe_stale_security_groups options
|
119
|
+
end
|
120
|
+
|
121
|
+
alias stale_security_groups stale_security_groups!
|
122
|
+
|
123
|
+
def volume_attribute!(**options)
|
124
|
+
describe_volume_attribute options
|
125
|
+
end
|
126
|
+
|
127
|
+
alias volume_attribute volume_attribute!
|
128
|
+
|
129
|
+
def volume_status!
|
130
|
+
@volume_status = describe_volume_status.volume_statuses
|
131
|
+
end
|
132
|
+
|
133
|
+
def volume_status
|
134
|
+
@volume_status ||= volume_status!
|
135
|
+
end
|
136
|
+
|
137
|
+
alias volume_statuses! volume_status!
|
138
|
+
alias volume_statuses volume_status
|
139
|
+
|
140
|
+
def vpc_attribute!(**options)
|
141
|
+
describe_vpc_attribute options
|
142
|
+
end
|
143
|
+
|
144
|
+
alias vpc_attribute vpc_attribute!
|
145
|
+
|
146
|
+
def vpc_classic_link!
|
147
|
+
@vpc_classic_link = describe_vpc_classic_link.vpcs
|
148
|
+
end
|
149
|
+
|
150
|
+
def vpc_classic_link_dns_support!
|
151
|
+
@vpc_classic_link_dns_support = describe_vpc_classic_link_dns_support.vpcs
|
152
|
+
end
|
153
|
+
|
154
|
+
def vpc_endpoint_services!
|
155
|
+
@vpc_endpoint_services = describe_vpc_endpoint_services.service_names
|
156
|
+
end
|
157
|
+
|
158
|
+
DESCRIBE_METHODS.each do |method|
|
159
|
+
name = method.to_s.split('_').drop(1).join('_')
|
160
|
+
raw = [name, '!'].join
|
161
|
+
var = ['@', name].join
|
162
|
+
|
163
|
+
define_method(raw) do |*args|
|
164
|
+
r = send(method, *args)
|
165
|
+
instance_variable_set var, (r.respond_to?(name) ? r.send(name) : r)
|
166
|
+
end unless method_defined?(raw)
|
167
|
+
|
168
|
+
define_method(name) do |*args|
|
169
|
+
if instance_variable_defined? var
|
170
|
+
instance_variable_get var
|
171
|
+
else
|
172
|
+
send(raw, *args)
|
173
|
+
end
|
174
|
+
end unless method_defined?(name)
|
175
|
+
end
|
176
|
+
|
177
|
+
private
|
178
|
+
|
179
|
+
def ec2
|
180
|
+
@ec2 ||= ::Aws::EC2::Client.new @options
|
181
|
+
end
|
182
|
+
|
183
|
+
def method_missing(method, *args)
|
184
|
+
return super unless respond_to? method
|
185
|
+
|
186
|
+
ec2.public_send(method, *args)
|
187
|
+
rescue ::Aws::EC2::Errors::RequestLimitExceeded
|
188
|
+
sleep rand 1..4.0
|
189
|
+
retry
|
190
|
+
end
|
191
|
+
|
192
|
+
def respond_to?(method)
|
193
|
+
ec2.respond_to?(method) || super
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'ec2/client'
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'aws/ec2'
|
data/lib/pareidolia.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'pareidolia/aws'
|
data/pareidolia.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.name = 'pareidolia'
|
3
|
+
gem.version = `git describe --tags --abbrev=0`.chomp
|
4
|
+
gem.licenses = 'MIT'
|
5
|
+
gem.authors = ['Chris Olstrom']
|
6
|
+
gem.email = 'chris@olstrom.com'
|
7
|
+
gem.homepage = 'https://github.com/colstrom/pareidolia'
|
8
|
+
gem.summary = 'Clouding Coherently'
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split("\n")
|
11
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
13
|
+
gem.require_paths = ['lib']
|
14
|
+
|
15
|
+
gem.add_runtime_dependency 'aws-sdk', '~> 2.6', '>= 2.6.0'
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pareidolia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.14.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Olstrom
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.6'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.6.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.6'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.6.0
|
33
|
+
description:
|
34
|
+
email: chris@olstrom.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- ".gitignore"
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.org
|
42
|
+
- lib/pareidolia.rb
|
43
|
+
- lib/pareidolia/aws.rb
|
44
|
+
- lib/pareidolia/aws/ec2.rb
|
45
|
+
- lib/pareidolia/aws/ec2/client.rb
|
46
|
+
- pareidolia.gemspec
|
47
|
+
homepage: https://github.com/colstrom/pareidolia
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata: {}
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 2.6.7
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: Clouding Coherently
|
71
|
+
test_files: []
|