cloud_info 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -14,10 +14,8 @@ end
14
14
  desc "Install gem"
15
15
  task :install do
16
16
  Rake::Task['gem'].invoke
17
- $stdout.puts "Use sudo?"
18
- sudo = ($stdin.gets.downcase[0..0] == 'y') ? 'sudo ' : ''
19
17
  $stdout.puts "Installing gem..."
20
- `#{sudo} gem install pkg/#{GEM_NAME}*.gem`
18
+ `gem install pkg/#{GEM_NAME}*.gem`
21
19
  `rm -Rf pkg`
22
20
  end
23
21
 
data/gemspec.rb CHANGED
@@ -16,5 +16,5 @@ GEM_SPEC = Gem::Specification.new do |s|
16
16
  s.name = GEM_NAME
17
17
  s.platform = Gem::Platform::RUBY
18
18
  s.require_path = "lib"
19
- s.version = "0.1.2"
19
+ s.version = "0.1.3"
20
20
  end
@@ -12,7 +12,7 @@ class CloudInfo
12
12
  end
13
13
 
14
14
  # if a cache exist it uses it instead of finding the servers
15
- def hosts(use_cache = true)
15
+ def hosts(use_cache = false)
16
16
  # check yaml file first
17
17
  if use_cache and File.exist?(@cache_path)
18
18
  @hosts = (CloudInfo.read_yaml(@cache_path) || {})[env_name]
@@ -43,10 +43,16 @@ class CloudInfo
43
43
 
44
44
  def connect_to_servers
45
45
  thread = Thread.current
46
- hosts = instances.collect {|i| i[:dns_name]}
46
+ hosts_with_blanks = instances.select{|i| i[:aws_state] == 'running'}.collect {|i| i[:dns_name]}
47
+ hosts = hosts_with_blanks.select{|i| i[:dns_name] != ""}
48
+ if hosts_with_blanks.size != hosts.size
49
+ puts "WARNING: some hosts do not have dns_name's yet, amazon is not yet ready"
50
+ end
51
+
47
52
  threads = hosts.collect do |host|
48
53
  Thread.new {
49
54
  @sessions << Net::SSH.start(host, @user, {:keys => @private_key})
55
+ @sessions
50
56
  }
51
57
  end
52
58
  threads.collect {|t| t.join}
@@ -64,9 +70,13 @@ class CloudInfo
64
70
 
65
71
  def execute_on_servers
66
72
  connect_to_servers
73
+ threads = []
67
74
  sessions.each do |ssh|
68
- yield(ssh)
75
+ threads << Thread.new {
76
+ yield(ssh)
77
+ }
69
78
  end
79
+ threads.collect{|t| t.join}
70
80
  end
71
81
 
72
82
  # builds up the hosts hash
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tung Nguyen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-04 00:00:00 -08:00
17
+ date: 2010-03-07 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -69,7 +69,6 @@ extra_rdoc_files:
69
69
  - README.markdown
70
70
  files:
71
71
  - bin/cloud_info
72
- - config/cloud_info.yml
73
72
  - gemspec.rb
74
73
  - lib/cloud_info/instances.rb
75
74
  - lib/cloud_info.rb
@@ -1,12 +0,0 @@
1
- ---
2
- prod_br:
3
- prod_br_app0: 184.73.240.218
4
- prod_br_util0: ec2-174-129-69-169.compute-1.amazonaws.com
5
- prod_br_memcached0: ec2-204-236-244-26.compute-1.amazonaws.com
6
- prod_br_util1: ec2-174-129-111-60.compute-1.amazonaws.com
7
- prod_br_memcached1: ec2-184-73-18-219.compute-1.amazonaws.com
8
- prod_br_app1: ec2-75-101-183-44.compute-1.amazonaws.com
9
- prod_br_app2: ec2-174-129-55-203.compute-1.amazonaws.com
10
- prod_br_app3: ec2-184-73-5-255.compute-1.amazonaws.com
11
- prod_br_db0: ec2-174-129-47-164.compute-1.amazonaws.com
12
- prod_br_db1: ec2-72-44-44-156.compute-1.amazonaws.com