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 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 = perform_task "Gathering Instance Requirements" do
32
- Awsome::Requirements.from_yaml_file(requirements_file)
33
- end
31
+ requirements = nil
32
+ instances = nil
33
+ matches = nil
34
34
 
35
- # print out the required instances
36
- puts Awsome::Requirements.to_table(requirements.instances)
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
- instances = perform_task "Analyzing Running Instances" do
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
- # print out the scouted instances
44
- puts Awsome::Ec2::Instance.to_table(instances)
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
@@ -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.each do |instance|
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
- private
109
- def id
110
- properties['instance_id']
111
- end
108
+ def elbs
109
+ Awsome::Elb.describe_lbs.select { |elb| elb.instances.include?(@properties['instance_id']) }
110
+ end
112
111
 
113
- def ami_id
114
- properties['ami_id']
115
- end
112
+ def id
113
+ properties['instance_id']
114
+ end
116
115
 
117
- def key
118
- properties['key']
119
- end
116
+ def ami_id
117
+ properties['ami_id']
118
+ end
120
119
 
121
- def instance_type
122
- properties['instance_type']
123
- end
120
+ def key
121
+ properties['key']
122
+ end
124
123
 
125
- def availability_zone
126
- properties['availability_zone']
127
- end
124
+ def instance_type
125
+ properties['instance_type']
126
+ end
128
127
 
129
- def security_group_ids
130
- properties['security_group_ids']
131
- end
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
@@ -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.each do |match|
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
@@ -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.each do |req|
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awsome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.38
4
+ version: 0.0.39
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: