capify-ec2 1.3.4 → 1.3.5

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.
@@ -1,3 +1,18 @@
1
+ ## 1.3.5 (Jan 11, 2013)
2
+
3
+ Features:
4
+
5
+ - Updated output from ec2:status, improving readability, and improving handling of instance attributes that vary in size.
6
+
7
+ Bugfixes:
8
+
9
+ - Region role creation fixed, so that you can deploy just to instances in specific regions again (i.e. cap us-east-1 deploy).
10
+ - Fixed 'already initialized constant' warning which may be shown to users running some versions of Ruby 1.8.
11
+
12
+ ## 1.3.0 to 1.3.4
13
+
14
+ Sorry, release notes were not added for these versions.
15
+
1
16
  ## 1.2.9 (June 29, 2012)
2
17
 
3
18
  Bugfixes:
@@ -7,7 +7,10 @@ require File.expand_path(File.dirname(__FILE__) + '/capify-ec2/server')
7
7
  class CapifyEc2
8
8
 
9
9
  attr_accessor :load_balancer, :instances
10
- SLEEP_COUNT = 5
10
+
11
+ unless const_defined? :SLEEP_COUNT
12
+ SLEEP_COUNT = 5
13
+ end
11
14
 
12
15
  def initialize(ec2_config = "config/ec2.yml")
13
16
  case ec2_config
@@ -42,12 +45,38 @@ class CapifyEc2
42
45
  end
43
46
 
44
47
  def display_instances
48
+ # Set minimum widths for the variable length instance attributes.
49
+ column_widths = { :name_min => 4, :type_min => 4, :dns_min => 5, :roles_min => 5, :options_min => 6 }
50
+
51
+ # Find the longest attribute across all instances, to format the columns properly.
52
+ column_widths[:name] = desired_instances.map{|i| i.name || ' ' * column_widths[:name_min] }.max_by(&:length).length
53
+ column_widths[:type] = desired_instances.map{|i| i.flavor_id || ' ' * column_widths[:type_min] }.max_by(&:length).length
54
+ column_widths[:dns] = desired_instances.map{|i| i.contact_point || ' ' * column_widths[:dns_min] }.max_by(&:length).length
55
+ column_widths[:roles] = desired_instances.map{|i| i.tags[@ec2_config[:aws_roles_tag]] || ' ' * column_widths[:roles_min] }.max_by(&:length).length
56
+ column_widths[:options] = desired_instances.map{|i| i.tags["Options"] || ' ' * column_widths[:options_min] }.max_by(&:length).length
57
+
58
+ # Title row.
59
+ puts sprintf "%-3s %s %s %s %s %s %s %s",
60
+ '',
61
+ 'Name' .ljust( column_widths[:name] ).bold,
62
+ 'ID' .ljust( 10 ).bold,
63
+ 'Type' .ljust( column_widths[:type] ).bold,
64
+ 'DNS' .ljust( column_widths[:dns] ).bold,
65
+ 'Zone' .ljust( 10 ).bold,
66
+ 'Roles' .ljust( column_widths[:roles] ).bold,
67
+ 'Options'.ljust( column_widths[:options] ).bold
68
+
45
69
  desired_instances.each_with_index do |instance, i|
46
- puts sprintf "%02d: %-40s %-20s %-20s %-62s %-20s (%s) (%s)",
47
- i, (instance.name || "").green, instance.id.red, instance.flavor_id.cyan,
48
- instance.contact_point.blue, instance.availability_zone.magenta, (instance.tags[@ec2_config[:aws_roles_tag]] || "").yellow,
49
- (instance.tags["Options"] || "").yellow
50
- end
70
+ puts sprintf "%02d: %-10s %s %s %s %-10s %s %s",
71
+ i,
72
+ (instance.name || '') .ljust( column_widths[:name] ).green,
73
+ instance.id .ljust( 2 ).red,
74
+ instance.flavor_id .ljust( column_widths[:type] ).cyan,
75
+ instance.contact_point .ljust( column_widths[:dns] ).blue.bold,
76
+ instance.availability_zone .ljust( 10 ).magenta,
77
+ (instance.tags[@ec2_config[:aws_roles_tag]] || '').ljust( column_widths[:roles] ).yellow,
78
+ (instance.tags["Options"] || '') .ljust( column_widths[:options] ).yellow
79
+ end
51
80
  end
52
81
 
53
82
  def server_names
@@ -68,7 +97,7 @@ class CapifyEc2
68
97
 
69
98
  def get_instances_by_region(roles, region)
70
99
  return unless region
71
- desired_instances.select {|instance| instance.availability_zone.match(region) && instance.roles == roles.to_s rescue false}
100
+ desired_instances.select {|instance| instance.availability_zone.match(region) && instance.tags['Roles'].split(%r{,\s*}).include?(roles.to_s) rescue false}
72
101
  end
73
102
 
74
103
  def get_instance_by_name(name)
@@ -128,7 +128,7 @@ Capistrano::Configuration.instance(:must_exist).load do
128
128
  end
129
129
  end
130
130
 
131
- def define_role(role, instance, variables)
131
+ def define_role(role, instance, variables = {})
132
132
  options = role[:options] || {}
133
133
 
134
134
  cap_options = options.inject({}) do |cap_options, (key, value)|
@@ -1,6 +1,6 @@
1
1
  module Capify
2
2
  module Ec2
3
- VERSION = "1.3.4"
3
+ VERSION = "1.3.5"
4
4
  end
5
5
  end
6
6
 
data/readme.md CHANGED
@@ -1,8 +1,3 @@
1
- Capify Ec2 is no longer being maintained. It has been superseded by capify-cloud, which adds Brightbox integration.
2
- You may continue to use this as long as you like, but active development and gems will now be found under the capify-cloud moniker.
3
- https://github.com/forward/capify-cloud
4
-
5
-
6
1
  Capify Ec2
7
2
  ====================================================
8
3
 
metadata CHANGED
@@ -1,73 +1,79 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: capify-ec2
3
- version: !ruby/object:Gem::Version
4
- version: 1.3.4
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 5
10
+ version: 1.3.5
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Noah Cantor
9
14
  - Siddharth Dawara
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2012-11-30 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2013-01-11 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
16
22
  name: fog
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - '='
21
- - !ruby/object:Gem::Version
22
- version: 1.3.1
23
- type: :runtime
24
23
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
26
25
  none: false
27
- requirements:
28
- - - '='
29
- - !ruby/object:Gem::Version
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 25
30
+ segments:
31
+ - 1
32
+ - 3
33
+ - 1
30
34
  version: 1.3.1
31
- - !ruby/object:Gem::Dependency
32
- name: colored
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - '='
37
- - !ruby/object:Gem::Version
38
- version: '1.2'
39
35
  type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: colored
40
39
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - '='
45
- - !ruby/object:Gem::Version
46
- version: '1.2'
47
- - !ruby/object:Gem::Dependency
48
- name: capistrano
49
- requirement: !ruby/object:Gem::Requirement
40
+ requirement: &id002 !ruby/object:Gem::Requirement
50
41
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 11
46
+ segments:
47
+ - 1
48
+ - 2
49
+ version: "1.2"
55
50
  type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: capistrano
56
54
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
55
+ requirement: &id003 !ruby/object:Gem::Requirement
58
56
  none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :runtime
65
+ version_requirements: *id003
63
66
  description: Grabs roles from ec2's tags and autogenerates capistrano tasks
64
- email:
67
+ email:
65
68
  - noah.cantor@forward.co.uk
66
69
  - siddharth.dawara@forward.co.uk
67
70
  executables: []
71
+
68
72
  extensions: []
73
+
69
74
  extra_rdoc_files: []
70
- files:
75
+
76
+ files:
71
77
  - .gitignore
72
78
  - Changelog.md
73
79
  - Gemfile
@@ -81,26 +87,36 @@ files:
81
87
  - readme.md
82
88
  homepage: http://github.com/forward/capify-ec2
83
89
  licenses: []
90
+
84
91
  post_install_message:
85
92
  rdoc_options: []
86
- require_paths:
93
+
94
+ require_paths:
87
95
  - lib
88
- required_ruby_version: !ruby/object:Gem::Requirement
96
+ required_ruby_version: !ruby/object:Gem::Requirement
89
97
  none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
106
  none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '0'
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ hash: 3
111
+ segments:
112
+ - 0
113
+ version: "0"
100
114
  requirements: []
115
+
101
116
  rubyforge_project: capify-ec2
102
- rubygems_version: 1.8.24
117
+ rubygems_version: 1.8.15
103
118
  signing_key:
104
119
  specification_version: 3
105
120
  summary: Grabs roles from ec2's tags and autogenerates capistrano tasks
106
121
  test_files: []
122
+