capify-ec2 1.2.4 → 1.2.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.
data/Changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.2.5 (Jan 26, 2011)
2
+
3
+ Features:
4
+
5
+ - Added ability to connect to VPC instances. Very basic functionality.
6
+
1
7
  ## 1.2.4 (Jan 24, 2011)
2
8
 
3
9
  Features:
data/lib/capify-ec2.rb CHANGED
@@ -31,9 +31,13 @@ class CapifyEc2
31
31
  desired_instances.each_with_index do |instance, i|
32
32
  puts sprintf "%-11s: %-40s %-20s %-20s %-62s %-20s (%s)",
33
33
  i.to_s.magenta, instance.name, instance.id.red, instance.flavor_id.cyan,
34
- instance.dns_name.blue, instance.availability_zone.green, (instance.roles rescue "").yellow
34
+ instance.contact_point.blue, instance.availability_zone.green, (instance.tags["Roles"] || "").yellow
35
35
  end
36
36
  end
37
+
38
+ def server_names
39
+ desired_instances.map {|instance| instance.name}
40
+ end
37
41
 
38
42
  def project_instances
39
43
  @instances.select {|instance| instance.tags["Project"] == @ec2_config[:project_tag]}
@@ -42,9 +46,9 @@ class CapifyEc2
42
46
  def desired_instances(region = nil)
43
47
  instances = @ec2_config[:project_tag].nil? ? @instances : project_instances
44
48
  end
45
-
49
+
46
50
  def get_instances_by_role(role)
47
- desired_instances.select {|instance| instance.roles.split(',').include?(role.to_s) rescue false}
51
+ desired_instances.select {|instance| instance.tags['Roles'].split(',').include?(role.to_s) rescue false}
48
52
  end
49
53
 
50
54
  def get_instances_by_region(roles, region)
@@ -59,11 +63,7 @@ class CapifyEc2
59
63
  def instance_health(load_balancer, instance)
60
64
  elb.describe_instance_health(load_balancer.id, instance.id).body['DescribeInstanceHealthResult']['InstanceStates'][0]['State']
61
65
  end
62
-
63
- def server_names
64
- desired_instances.map {|instance| instance.name}
65
- end
66
-
66
+
67
67
  def elb
68
68
  Fog::AWS::ELB.new(:aws_access_key_id => @ec2_config[:aws_access_key_id], :aws_secret_access_key => @ec2_config[:aws_secret_access_key], :region => @ec2_config[:aws_params][:region])
69
69
  end
@@ -4,7 +4,7 @@ require 'colored'
4
4
  Capistrano::Configuration.instance(:must_exist).load do
5
5
  namespace :ec2 do
6
6
 
7
- desc "Prints out all ec2 instances. index, name, instance_id, size, dns_name, region, tags"
7
+ desc "Prints out all ec2 instances. index, name, instance_id, size, DNS/IP, region, tags"
8
8
  task :status do
9
9
  CapifyEc2.new.display_instances
10
10
  end
@@ -36,7 +36,7 @@ Capistrano::Configuration.instance(:must_exist).load do
36
36
  server = variables[:logger].instance_variable_get("@options")[:actions][1]
37
37
  instance = numeric?(server) ? CapifyEc2.new.desired_instances[server.to_i] : CapifyEc2.new.get_instance_by_name(server)
38
38
  port = ssh_options[:port] || 22
39
- command = "ssh -p #{port} #{user}@#{instance.dns_name}"
39
+ command = "ssh -p #{port} #{user}@#{instance.contact_point}"
40
40
  puts "Running `#{command}`"
41
41
  exec(command)
42
42
  end
@@ -55,7 +55,7 @@ Capistrano::Configuration.instance(:must_exist).load do
55
55
 
56
56
  task named_instance.name.to_sym do
57
57
  remove_default_roles
58
- server_address = named_instance.dns_name
58
+ server_address = named_instance.contact_point
59
59
  named_instance.roles.each do |role|
60
60
  define_role({:name => role, :options => {:on_no_matching_servers => :continue}}, named_instance)
61
61
  end
@@ -120,15 +120,15 @@ Capistrano::Configuration.instance(:must_exist).load do
120
120
  options = role[:options]
121
121
  new_options = {}
122
122
  options.each {|key, value| new_options[key] = true if value.to_s == instance.name}
123
- instance.options.each do |option|
123
+ instance.tags["Options"].each do |option|
124
124
  results = option.split(',')
125
125
  results.each {|result| new_options[result.to_sym] = true }
126
126
  end rescue false
127
127
 
128
128
  if new_options
129
- role role[:name].to_sym, instance.dns_name, new_options
129
+ role role[:name].to_sym, instance.contact_point, new_options
130
130
  else
131
- role role[:name].to_sym, instance.dns_name
131
+ role role[:name].to_sym, instance.contact_point
132
132
  end
133
133
  end
134
134
 
@@ -5,20 +5,12 @@ module Fog
5
5
  module Compute
6
6
  class AWS
7
7
  class Server
8
- def method_missing(method_sym, *arguments, &block)
9
- tags.each do |key, value|
10
- tag = key.downcase.gsub(/\W/, '')
11
- return value if method_sym.to_s == tag
12
- end if tags
13
- super
8
+ def contact_point
9
+ dns_name || public_ip_address || private_ip_address
14
10
  end
15
11
 
16
- def respond_to?(method_sym, include_private = false)
17
- tags.each do |key, value|
18
- tag = key.downcase.gsub(/\W/, '')
19
- return true if method_sym.to_s == tag
20
- end if tags
21
- super
12
+ def name
13
+ tags["Name"]
22
14
  end
23
15
  end
24
16
  end
@@ -1,5 +1,5 @@
1
1
  module Capify
2
2
  module Ec2
3
- VERSION = "1.2.4"
3
+ VERSION = "1.2.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capify-ec2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 4
10
- version: 1.2.4
9
+ - 5
10
+ version: 1.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Noah Cantor
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-01-25 00:00:00 +00:00
19
+ date: 2012-01-27 00:00:00 +00:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency