awsome 0.0.38 → 0.0.39
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/bin/awsome +15 -17
- data/lib/awsome/ec2/instance.rb +26 -25
- data/lib/awsome/matchmaker.rb +2 -1
- data/lib/awsome/requirements.rb +2 -2
- metadata +1 -1
data/bin/awsome
CHANGED
@@ -24,32 +24,30 @@ end.parse!
|
|
24
24
|
def perform_task(task, &block)
|
25
25
|
puts Terminal::Table.new { |t| t << ["[#{task}] Started"] }
|
26
26
|
retval = yield task
|
27
|
-
puts Terminal::Table.new { |t| t << ["[#{task}] Complete"] }
|
28
|
-
retval
|
27
|
+
#puts Terminal::Table.new { |t| t << ["[#{task}] Complete"] }
|
28
|
+
#retval
|
29
29
|
end
|
30
30
|
|
31
|
-
requirements =
|
32
|
-
|
33
|
-
|
31
|
+
requirements = nil
|
32
|
+
instances = nil
|
33
|
+
matches = nil
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
perform_task "Gathering Instance Requirements" do
|
36
|
+
requirements = Awsome::Requirements.from_yaml_file(requirements_file)
|
37
|
+
puts Awsome::Requirements.to_table(requirements.instances)
|
38
|
+
end
|
37
39
|
|
38
|
-
|
40
|
+
perform_task "Analyzing Running Instances" do
|
39
41
|
filters = {'instance-state-name' => 'running'}.merge(requirements.filters)
|
40
|
-
Awsome::Ec2.describe_instances(filters)
|
42
|
+
instances = Awsome::Ec2.describe_instances(filters)
|
43
|
+
puts Awsome::Ec2::Instance.to_table(instances)
|
41
44
|
end
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
matches = perform_task "Matching Requirements to Instances" do
|
47
|
-
Awsome::Matchmaker.new(instances, requirements).matches
|
46
|
+
perform_task "Matching Requirements to Instances" do
|
47
|
+
matches = Awsome::Matchmaker.new(instances, requirements).matches
|
48
|
+
puts Awsome::Matchmaker.to_table(matches)
|
48
49
|
end
|
49
50
|
|
50
|
-
# print out the matches
|
51
|
-
puts Awsome::Matchmaker.to_table(matches)
|
52
|
-
|
53
51
|
perform_task "Executing Plan" do
|
54
52
|
Awsome::Executor.new(matches).execute
|
55
53
|
end
|
data/lib/awsome/ec2/instance.rb
CHANGED
@@ -86,7 +86,7 @@ module Awsome
|
|
86
86
|
def self.to_table(instances)
|
87
87
|
headings = %w(tags packages volumes elbs elasticips cnames ami key type zone secgroup)
|
88
88
|
Terminal::Table.new :headings => headings do |t|
|
89
|
-
instances.
|
89
|
+
instances.each_with_index do |instance, i|
|
90
90
|
t << [
|
91
91
|
'Not built', #req.tags.join("\n"),
|
92
92
|
instance.packages.to_a.join("\n"),
|
@@ -100,35 +100,40 @@ module Awsome
|
|
100
100
|
instance.availability_zone,
|
101
101
|
instance.security_group_ids
|
102
102
|
]
|
103
|
-
t << :separator
|
103
|
+
t << :separator unless i == instances.length-1
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
108
|
+
def elbs
|
109
|
+
Awsome::Elb.describe_lbs.select { |elb| elb.instances.include?(@properties['instance_id']) }
|
110
|
+
end
|
112
111
|
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
def id
|
113
|
+
properties['instance_id']
|
114
|
+
end
|
116
115
|
|
117
|
-
|
118
|
-
|
119
|
-
|
116
|
+
def ami_id
|
117
|
+
properties['ami_id']
|
118
|
+
end
|
120
119
|
|
121
|
-
|
122
|
-
|
123
|
-
|
120
|
+
def key
|
121
|
+
properties['key']
|
122
|
+
end
|
124
123
|
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
def instance_type
|
125
|
+
properties['instance_type']
|
126
|
+
end
|
128
127
|
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
def availability_zone
|
129
|
+
properties['availability_zone']
|
130
|
+
end
|
131
|
+
|
132
|
+
def security_group_ids
|
133
|
+
properties['security_group_ids']
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
132
137
|
|
133
138
|
def reload!
|
134
139
|
instance = Awsome::Ec2.describe_instances('instance-id' => @properties['instance_id']).first
|
@@ -140,10 +145,6 @@ module Awsome
|
|
140
145
|
Awsome::Ssh.has_ssh?(@properties['public_dns_name'])
|
141
146
|
end
|
142
147
|
|
143
|
-
def elbs
|
144
|
-
Awsome::Elb.describe_lbs.select { |elb| elb.instances.include?(@properties['instance_id']) }
|
145
|
-
end
|
146
|
-
|
147
148
|
end
|
148
149
|
end
|
149
150
|
end
|
data/lib/awsome/matchmaker.rb
CHANGED
@@ -36,7 +36,7 @@ module Awsome
|
|
36
36
|
def self.to_table(matches)
|
37
37
|
headings = %w(instance packages volumes elbs ami key type zone secgroup)
|
38
38
|
Terminal::Table.new :headings => headings do |t|
|
39
|
-
matches.
|
39
|
+
matches.each_with_index do |match, midx|
|
40
40
|
1.upto(match['i_pool'].length) do |idx|
|
41
41
|
i = match['i_pool'][idx]
|
42
42
|
r = match['r_pool'][idx]
|
@@ -51,6 +51,7 @@ module Awsome
|
|
51
51
|
r.availability_zone,
|
52
52
|
r.security_group_ids,
|
53
53
|
]
|
54
|
+
t << :separator unless idx == match['i_pool'].length-1 && midx == matches.length-1
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
data/lib/awsome/requirements.rb
CHANGED
@@ -33,7 +33,7 @@ module Awsome
|
|
33
33
|
def self.to_table(requirements)
|
34
34
|
headings = %w(tags packages volumes elbs elasticips cnames ami key type zone secgroup)
|
35
35
|
Terminal::Table.new :headings => headings do |t|
|
36
|
-
requirements.
|
36
|
+
requirements.each_with_index do |req, i|
|
37
37
|
t << [
|
38
38
|
req.tags.collect { |v| "#{v[0]}: #{v[1]}" }.join("\n"),
|
39
39
|
req.packages.to_a.join("\n"),
|
@@ -47,7 +47,7 @@ module Awsome
|
|
47
47
|
req.availability_zone,
|
48
48
|
req.security_group_ids
|
49
49
|
]
|
50
|
-
t << :separator
|
50
|
+
t << :separator unless i == requirements.length-1
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|