ec2-instance 0.0.2

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.
Files changed (3) hide show
  1. data/README +37 -0
  2. data/lib/ec2-instance.rb +34 -0
  3. metadata +74 -0
data/README ADDED
@@ -0,0 +1,37 @@
1
+ == ec2-instance
2
+
3
+ This is a small set of extensions for common uses of the amazon-ec2 gem.
4
+
5
+ It is intended to be used in processes which are running on actual ec2 instances. It uses the Instance module and other functions in EC2::Base to extract useful information from the hashes returned and to provide useful actions.
6
+
7
+ == Example
8
+
9
+ With an instance of EC2::Base:
10
+
11
+ @ec2.launch_time
12
+ => Returns a Time object with a value representing the time amazon says this instance launched.
13
+
14
+ == License
15
+
16
+ Offered under the MIT license:
17
+
18
+ Copyright (c) 2010 Robert Berry
19
+
20
+ Permission is hereby granted, free of charge, to any person obtaining a copy
21
+ of this software and associated documentation files (the "Software"), to deal
22
+ in the Software without restriction, including without limitation the rights
23
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24
+ copies of the Software, and to permit persons to whom the Software is
25
+ furnished to do so, subject to the following conditions:
26
+
27
+ The above copyright notice and this permission notice shall be included in
28
+ all copies or substantial portions of the Software.
29
+
30
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
36
+ THE SOFTWARE.
37
+
@@ -0,0 +1,34 @@
1
+ #
2
+ # All methods added to AWS::EC2::Base return values and initiate actions for the machine
3
+ # on which the process is running.
4
+ #
5
+
6
+ module AWS
7
+ module EC2
8
+ class Base
9
+
10
+ #
11
+ # Return the launch time of this machine.
12
+ #
13
+ def launch_time
14
+ instance_data = parse_instance_set(self.describe_instances).detect do |inst|
15
+ inst.to_s.include? AWS::EC2::Instance.local_instance_id
16
+ end
17
+
18
+ launched_time = Time.parse(parse_launch_time(instance_data)).localtime
19
+ return launched_time
20
+ end
21
+
22
+ private
23
+
24
+ def parse_intance_set(ec2_response_hash)
25
+ ec2_response_hash["reservationSet"]["item"]
26
+ end
27
+
28
+ def parse_launch_time(instance_hash)
29
+ instance_hash["instancesSet"]["item"].first["launchTime"]
30
+ end
31
+
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ec2-instance
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Robert Berry
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-10 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: amazon-ec2
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ description: Monkey patch some amazon-ec2 gem classes and modules to handle common operations.
33
+ email: berrydigital@gmail.com
34
+ executables: []
35
+
36
+ extensions: []
37
+
38
+ extra_rdoc_files: []
39
+
40
+ files:
41
+ - lib/ec2-instance.rb
42
+ - README
43
+ has_rdoc: false
44
+ homepage: http://github.com/bdigital/ec2-instance
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options: []
49
+
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.6
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Extension for amazon-ec2 gem for instance operations
73
+ test_files: []
74
+