ec2-instance 0.0.10 → 0.0.11
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/lib/ec2-instance.rb +11 -4
- data/lib/instance.rb +11 -1
- metadata +3 -3
data/lib/ec2-instance.rb
CHANGED
|
@@ -35,14 +35,21 @@ module AWS
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
#
|
|
38
|
-
# Return
|
|
38
|
+
# Return an instance object for this machine.
|
|
39
39
|
#
|
|
40
|
-
def
|
|
40
|
+
def identity_instance
|
|
41
41
|
local_instance = parse_instance_set(self.describe_instances).detect do |inst|
|
|
42
42
|
inst.instance_id.eql? AWS::EC2::Instance.local_instance_id
|
|
43
43
|
end
|
|
44
|
+
return local_instance
|
|
45
|
+
end
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
#
|
|
48
|
+
# Deprecated. Will be removed in the next couple versions.
|
|
49
|
+
# Please use identity_instance.launch_time
|
|
50
|
+
#
|
|
51
|
+
def launch_time
|
|
52
|
+
identity_instance.launch_time
|
|
46
53
|
end
|
|
47
54
|
|
|
48
55
|
private
|
|
@@ -51,7 +58,7 @@ module AWS
|
|
|
51
58
|
instances = []
|
|
52
59
|
ec2_response_hash["reservationSet"]["item"].each do |res|
|
|
53
60
|
res["instancesSet"]["item"].each do |i|
|
|
54
|
-
instances.push AWS::EC2::Instance.new({:instance_id => parse_instance_id(i), :status => parse_status(i), :launch_time => parse_launch_time(i), :tags => parse_tags(i), :dns => parse_dns(i)})
|
|
61
|
+
instances.push AWS::EC2::Instance.new({:connection => self, :instance_id => parse_instance_id(i), :status => parse_status(i), :launch_time => parse_launch_time(i), :tags => parse_tags(i), :dns => parse_dns(i)})
|
|
55
62
|
end
|
|
56
63
|
end
|
|
57
64
|
return instances
|
data/lib/instance.rb
CHANGED
|
@@ -2,6 +2,7 @@ module AWS
|
|
|
2
2
|
module EC2
|
|
3
3
|
class Instance
|
|
4
4
|
|
|
5
|
+
attr_accessor :connection
|
|
5
6
|
attr_accessor :instance_id, :launch_time, :status, :tags, :dns
|
|
6
7
|
|
|
7
8
|
def initialize(init_hash = {})
|
|
@@ -12,7 +13,16 @@ module AWS
|
|
|
12
13
|
|
|
13
14
|
def match?(tag)
|
|
14
15
|
self.tags.detect {|h| h.detect { |k, v| v.to_s.match /#{tag}/ } }
|
|
15
|
-
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
# If connection available, terminate self.
|
|
20
|
+
#
|
|
21
|
+
def self_destruct
|
|
22
|
+
raise "No Connection Associated With This Instance." unless !@connection.nil?
|
|
23
|
+
@connection.terminate_instances(:instance_id => self.instance_id)
|
|
24
|
+
# Have a Nice Day.
|
|
25
|
+
end
|
|
16
26
|
|
|
17
27
|
end
|
|
18
28
|
end
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: 0.0.
|
|
8
|
+
- 11
|
|
9
|
+
version: 0.0.11
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Robert Berry
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2011-01-
|
|
17
|
+
date: 2011-01-25 00:00:00 -08:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|