aws_cloud_map 0.1.0
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/lib/aws_cloud_map.rb +340 -0
- data/spec/aws_cloud_map_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- metadata +75 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Marcus Irven
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= aws_cloud_map
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 Marcus Irven. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "aws_cloud_map"
|
8
|
+
gem.summary = %Q{An easy to use object-oriented library for accessing and manipulating Amazon EC2 information.}
|
9
|
+
gem.description = %Q{An easy to use object-oriented library for accessing and manipulating Amazon EC2 information.}
|
10
|
+
gem.email = "marcus@marcusirven.com"
|
11
|
+
gem.homepage = "http://github.com/mirven/aws_cloud_map"
|
12
|
+
gem.authors = ["Marcus Irven"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
spec.libs << 'lib' << 'spec'
|
24
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
end
|
26
|
+
|
27
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
30
|
+
spec.rcov = true
|
31
|
+
end
|
32
|
+
|
33
|
+
task :spec => :check_dependencies
|
34
|
+
|
35
|
+
task :default => :spec
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "aws_cloud_map #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,340 @@
|
|
1
|
+
require 'right_aws'
|
2
|
+
|
3
|
+
module AWS
|
4
|
+
def self.ec2
|
5
|
+
@@ec2
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.connect(aws_access_key_id, aws_secret_access_key)
|
9
|
+
@@ec2 = RightAws::Ec2.new(aws_access_key_id, aws_secret_access_key)
|
10
|
+
end
|
11
|
+
|
12
|
+
class Image
|
13
|
+
include AWS
|
14
|
+
|
15
|
+
def initialize(attributes)
|
16
|
+
@attributes = attributes
|
17
|
+
end
|
18
|
+
|
19
|
+
def aws_architecture
|
20
|
+
@attributes[:aws_architecture]
|
21
|
+
end
|
22
|
+
|
23
|
+
def aws_owner
|
24
|
+
@attributes[:aws_owner]
|
25
|
+
end
|
26
|
+
|
27
|
+
def aws_id
|
28
|
+
@attributes[:aws_id]
|
29
|
+
end
|
30
|
+
|
31
|
+
def aws_image_type
|
32
|
+
@attributes[:aws_image_type]
|
33
|
+
end
|
34
|
+
|
35
|
+
def aws_location
|
36
|
+
@attributes[:aws_location]
|
37
|
+
end
|
38
|
+
|
39
|
+
def aws_kernel_id
|
40
|
+
@attributes[:aws_kernel_id]
|
41
|
+
end
|
42
|
+
|
43
|
+
def aws_state
|
44
|
+
@attributes[:aws_state]
|
45
|
+
end
|
46
|
+
|
47
|
+
def aws_ramdisk_id
|
48
|
+
@attributes[:aws_ramdisk_id]
|
49
|
+
end
|
50
|
+
|
51
|
+
def aws_is_public
|
52
|
+
@attributes[:aws_is_public]
|
53
|
+
end
|
54
|
+
|
55
|
+
alias_method :id, :aws_id
|
56
|
+
alias_method :public?, :aws_is_public
|
57
|
+
|
58
|
+
def instances
|
59
|
+
@@ec2.describe_instances.select { |instance| instance[:aws_image_id] == id }.map { |instance| Instance.new(instance) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.all
|
63
|
+
@@ec2.describe_images_by_owner('self').map { |image| new(image) }
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.find(image_id)
|
67
|
+
new(@@ec2.describe_images([image_id]).first)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class Instance
|
72
|
+
include AWS
|
73
|
+
|
74
|
+
def initialize(attributes)
|
75
|
+
@attributes = attributes
|
76
|
+
end
|
77
|
+
|
78
|
+
def aws_reservation_id
|
79
|
+
@attributes[:aws_reservation_id]
|
80
|
+
end
|
81
|
+
|
82
|
+
def dns_name
|
83
|
+
@attributes[:dns_name]
|
84
|
+
end
|
85
|
+
|
86
|
+
def aws_instance_type
|
87
|
+
@attributes[:aws_instance_type]
|
88
|
+
end
|
89
|
+
|
90
|
+
def aws_groups
|
91
|
+
@attributes[:aws_groups]
|
92
|
+
end
|
93
|
+
|
94
|
+
def private_dns_name
|
95
|
+
@attributes[:private_dns_name]
|
96
|
+
end
|
97
|
+
|
98
|
+
def aws_kernel_id
|
99
|
+
@attributes[:aws_kernel_id]
|
100
|
+
end
|
101
|
+
|
102
|
+
def aws_launch_time
|
103
|
+
@attributes[:aws_launch_time]
|
104
|
+
end
|
105
|
+
|
106
|
+
def ami_launch_index
|
107
|
+
@attributes[:ami_launch_index]
|
108
|
+
end
|
109
|
+
|
110
|
+
def aws_state
|
111
|
+
@attributes[:aws_state]
|
112
|
+
end
|
113
|
+
|
114
|
+
def aws_owner
|
115
|
+
@attributes[:aws_owner]
|
116
|
+
end
|
117
|
+
|
118
|
+
def ssh_key_name
|
119
|
+
@attributes[:ssh_key_name]
|
120
|
+
end
|
121
|
+
|
122
|
+
def aws_ramdisk_id
|
123
|
+
@attributes[:aws_ramdisk_id]
|
124
|
+
end
|
125
|
+
|
126
|
+
def aws_availability_zone
|
127
|
+
@attributes[:aws_availability_zone]
|
128
|
+
end
|
129
|
+
|
130
|
+
def aws_image_id
|
131
|
+
@attributes[:aws_image_id]
|
132
|
+
end
|
133
|
+
|
134
|
+
def aws_instance_id
|
135
|
+
@attributes[:aws_instance_id]
|
136
|
+
end
|
137
|
+
|
138
|
+
def aws_product_codes
|
139
|
+
@attributes[:aws_product_codes]
|
140
|
+
end
|
141
|
+
|
142
|
+
def aws_reason
|
143
|
+
@attributes[:aws_reason]
|
144
|
+
end
|
145
|
+
|
146
|
+
def aws_state_code
|
147
|
+
@attributes[:aws_state_code]
|
148
|
+
end
|
149
|
+
|
150
|
+
alias_method :id, :aws_instance_id
|
151
|
+
|
152
|
+
def image
|
153
|
+
@image ||= Image.find(aws_image_id)
|
154
|
+
end
|
155
|
+
|
156
|
+
def address
|
157
|
+
#TODO
|
158
|
+
end
|
159
|
+
|
160
|
+
def volumes
|
161
|
+
#TODO
|
162
|
+
[]
|
163
|
+
end
|
164
|
+
|
165
|
+
#TODO test
|
166
|
+
def terminate!
|
167
|
+
@@ec2.terminate_instances [id]
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.all
|
171
|
+
@@ec2.describe_instances.map { |instance| new(instance) }
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.find(instance_id)
|
175
|
+
new(@@ec2.describe_instances([instance_id]).first)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
class Volume
|
180
|
+
include AWS
|
181
|
+
|
182
|
+
def initialize(attributes)
|
183
|
+
@attributes = attributes
|
184
|
+
end
|
185
|
+
|
186
|
+
def aws_created_at
|
187
|
+
@attributes[:aws_created_at]
|
188
|
+
end
|
189
|
+
|
190
|
+
def aws_size
|
191
|
+
@attributes[:aws_size]
|
192
|
+
end
|
193
|
+
|
194
|
+
def aws_device
|
195
|
+
@attributes[:aws_device]
|
196
|
+
end
|
197
|
+
|
198
|
+
def aws_status
|
199
|
+
@attributes[:aws_status]
|
200
|
+
end
|
201
|
+
|
202
|
+
def aws_instance_id
|
203
|
+
@attributes[:aws_instance_id]
|
204
|
+
end
|
205
|
+
|
206
|
+
def zone
|
207
|
+
@attributes[:zone]
|
208
|
+
end
|
209
|
+
|
210
|
+
def snapshot_id
|
211
|
+
@attributes[:snapshot_id]
|
212
|
+
end
|
213
|
+
|
214
|
+
def aws_attachment_status
|
215
|
+
@attributes[:aws_attachment_status]
|
216
|
+
end
|
217
|
+
|
218
|
+
def aws_id
|
219
|
+
@attributes[:aws_id]
|
220
|
+
end
|
221
|
+
|
222
|
+
def aws_attached_at
|
223
|
+
@attributes[:aws_attached_at]
|
224
|
+
end
|
225
|
+
|
226
|
+
alias_method :id, :aws_id
|
227
|
+
|
228
|
+
#TODO test
|
229
|
+
def instance
|
230
|
+
return nil if aws_instance_id.nil?
|
231
|
+
@instance ||= Instance.find(aws_instance_id)
|
232
|
+
end
|
233
|
+
|
234
|
+
def snapshots
|
235
|
+
#TODO
|
236
|
+
[]
|
237
|
+
end
|
238
|
+
|
239
|
+
def self.all
|
240
|
+
@@ec2.describe_volumes.map { |volume| new(volume) }
|
241
|
+
end
|
242
|
+
|
243
|
+
def self.find(volume_id)
|
244
|
+
new(@@ec2.describe_volumes([volume_id]).first)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
class Snapshot
|
249
|
+
include AWS
|
250
|
+
|
251
|
+
def initialize(attributes)
|
252
|
+
@attributes = attributes
|
253
|
+
end
|
254
|
+
|
255
|
+
def aws_progress
|
256
|
+
@attributes[:aws_progress]
|
257
|
+
end
|
258
|
+
|
259
|
+
def aws_status
|
260
|
+
@attributes[:aws_status]
|
261
|
+
end
|
262
|
+
|
263
|
+
def aws_volume_id
|
264
|
+
@attributes[:aws_volume_id]
|
265
|
+
end
|
266
|
+
|
267
|
+
def aws_id
|
268
|
+
@attributes[:aws_id]
|
269
|
+
end
|
270
|
+
|
271
|
+
def aws_started_at
|
272
|
+
@attributes[:aws_started_at]
|
273
|
+
end
|
274
|
+
|
275
|
+
alias_method :id, :aws_id
|
276
|
+
|
277
|
+
#TODO test
|
278
|
+
def volume
|
279
|
+
@volume ||= Volume.find(aws_volume_id)
|
280
|
+
end
|
281
|
+
|
282
|
+
#TODO test
|
283
|
+
def create_volume(size, region)
|
284
|
+
@@ec2.create_volume(id, size, region)
|
285
|
+
end
|
286
|
+
|
287
|
+
def self.all
|
288
|
+
@@ec2.describe_snapshots.map { |snapshot| new(snapshot) }
|
289
|
+
end
|
290
|
+
|
291
|
+
def self.find(snapshot_id)
|
292
|
+
new(@@ec2.describe_snapshots([snapshot_id]).first)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
class Address
|
297
|
+
include AWS
|
298
|
+
|
299
|
+
def initialize(attributes)
|
300
|
+
@attributes = attributes
|
301
|
+
end
|
302
|
+
|
303
|
+
def instance_id
|
304
|
+
@attributes[:instance_id]
|
305
|
+
end
|
306
|
+
|
307
|
+
def public_ip
|
308
|
+
@attributes[:public_ip]
|
309
|
+
end
|
310
|
+
|
311
|
+
#TODO test
|
312
|
+
def associate!(instance_or_id)
|
313
|
+
instance_id = case instance_or_id
|
314
|
+
when Instance
|
315
|
+
instance_or_id.id
|
316
|
+
else
|
317
|
+
instance_or_id
|
318
|
+
end
|
319
|
+
|
320
|
+
@ec2.associate_address(instance_id, public_ip)
|
321
|
+
|
322
|
+
# TODO refresh @attributes
|
323
|
+
end
|
324
|
+
|
325
|
+
def instance
|
326
|
+
return nil if instance_id.nil?
|
327
|
+
@instance ||= Instance.find(instance_id)
|
328
|
+
end
|
329
|
+
|
330
|
+
def self.all
|
331
|
+
@@ec2.describe_addresses.map { |address| new(address) }
|
332
|
+
end
|
333
|
+
|
334
|
+
def self.find(ip)
|
335
|
+
new(@@ec2.describe_addresses([ ip ]).first)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aws_cloud_map
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcus Irven
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-26 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
description: An easy to use object-oriented library for accessing and manipulating Amazon EC2 information.
|
26
|
+
email: marcus@marcusirven.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- lib/aws_cloud_map.rb
|
42
|
+
- spec/aws_cloud_map_spec.rb
|
43
|
+
- spec/spec.opts
|
44
|
+
- spec/spec_helper.rb
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://github.com/mirven/aws_cloud_map
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options:
|
51
|
+
- --charset=UTF-8
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.5
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: An easy to use object-oriented library for accessing and manipulating Amazon EC2 information.
|
73
|
+
test_files:
|
74
|
+
- spec/aws_cloud_map_spec.rb
|
75
|
+
- spec/spec_helper.rb
|