auser-poolparty 1.3.10 → 1.3.11

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 3
3
- :patch: 10
3
+ :patch: 11
4
4
  :major: 1
data/bin/cloud-thrift CHANGED
@@ -60,8 +60,8 @@ EOS
60
60
  if cmd == "query"
61
61
  require "command_query_handler"
62
62
 
63
- @loaded_clouds.map do |cld|
64
- CommandQueryHandler.run_query(cld, ARGV.shift, ARGV, options)
63
+ @loaded_clouds.each do |cld|
64
+ puts CommandQueryHandler.run_query(cld, ARGV.shift, ARGV, options)
65
65
  end
66
66
  else
67
67
  block = Proc.new do
data/config/jeweler.rb CHANGED
@@ -25,7 +25,6 @@ end
25
25
  s.test_files = Dir["test/**/test_*.rb"]
26
26
 
27
27
  s.files = (%w(Rakefile README.rdoc License.txt VERSION.yml) + Dir["{config,examples,lib,test,tasks,script,generators,bin,vendor}/**/*"])
28
-
29
28
  s.files += ["vendor/erlang/hermes/ebin/*.tar.gz"]
30
29
 
31
30
  s.files.exclude 'vendor/erlang/hermes'
@@ -23,7 +23,8 @@ client = CloudThrift::CommandInterface::Client.new(protocol)
23
23
  transport.open()
24
24
 
25
25
  cld = CloudThrift::CloudQuery.new
26
- cld.name = 'monitored_app'
26
+ cld.name = 'pp2'
27
+ # cld.name = 'monitored_app'
27
28
  # cld.name = 'vmware'
28
29
 
29
30
  resp = client.run_command(cld, "name", [])
@@ -68,10 +68,15 @@ module CloudProviders
68
68
  raise StandardError.new("You must pass in a cloud to configure an instance") unless cloud
69
69
  cloud.compile(self)
70
70
 
71
- scp(:source => keypair.full_filepath,
72
- :destination => "/etc/poolparty/keys/#{keypair.basename}")
71
+ # scp(:source => keypair.full_filepath,
72
+ # :destination => "/etc/poolparty/keys/#{keypair.basename}")
73
73
 
74
74
  FileUtils.mkdir_p cloud.tmp_path/"etc"/"poolparty" unless File.directory?(cloud.tmp_path/"etc"/"poolparty")
75
+ FileUtils.mkdir_p cloud.tmp_path/"etc"/"poolparty"/"keys" unless File.directory?(cloud.tmp_path/"etc"/"poolparty"/"keys")
76
+
77
+ FileUtils.cp keypair.full_filepath, cloud.tmp_path/"etc"/"poolparty"/"keys"/keypair.basename
78
+ File.open(cloud.tmp_path/"etc"/"poolparty"/"cloud_name", "w") {|f| f << cloud.name }
79
+
75
80
  pack_clouds_dot_rb_and_expected_directories
76
81
 
77
82
  dputs("Rsyncing #{cloud.tmp_path/"*"}")
@@ -159,7 +159,7 @@ module CloudProviders
159
159
  end
160
160
 
161
161
  def after_compile(cld)
162
- save_aws_env_to_yml(cld.tmp_path/"etc"/"poolparty"/"env.yml")
162
+ save_aws_env_to_yml(cld.tmp_path/"etc"/"poolparty"/"env.yml") rescue nil
163
163
  end
164
164
 
165
165
  # Read yaml file and use it to set environment variables and local variables.
@@ -171,7 +171,8 @@ module CloudProviders
171
171
 
172
172
  # Save aws keys and env variables to a yaml file
173
173
  def save_aws_env_to_yml(filename='/etc/poolparty/env.yml')
174
- File.open(filename, 'w') {|f| f<<YAML::dump(aws_hash(dsl_options, "/etc/poolparty/ec2")) } rescue nil
174
+ hsh = aws_hash(default_options, "/etc/poolparty/ec2")
175
+ File.open(filename, 'w') {|f| f<<YAML::dump(hsh) }
175
176
  end
176
177
 
177
178
  # Return a hash of the aws keys and environment variables
@@ -196,12 +196,14 @@ module PoolParty
196
196
  # the defined (or the default dependency_resolver, chef)
197
197
  def compile(caller=nil)
198
198
  callback :before_compile
199
+ cloud_provider.before_compile(self)
199
200
  FileUtils.mkdir_p tmp_path unless File.directory?(tmp_path)
200
201
  ddputs <<-EOE
201
202
  Compiling cloud #{self.name} to #{tmp_path/"etc"/"#{dependency_resolver_name}"}
202
203
  number of resources: #{ordered_resources.size}
203
204
  EOE
204
205
  out = dependency_resolver.compile_to(ordered_resources, tmp_path/"etc"/"#{dependency_resolver_name}", caller)
206
+ cloud_provider.after_compile(self)
205
207
  callback :after_compile
206
208
  out
207
209
  end
@@ -27,7 +27,7 @@ You must pass a block with your monitor
27
27
  end
28
28
  EOE
29
29
  raise PoolPartyError.create("MonitorDefinitionError", msg) unless block
30
- @name = monitor_name
30
+ @name = monitor_name.to_sym
31
31
  @monitor_block = block
32
32
  end
33
33
 
@@ -14,6 +14,7 @@ module PoolParty
14
14
  run_dependencies
15
15
  build_rsync_directory
16
16
  add_unpack
17
+ run_dependencies
17
18
  run_if_needed
18
19
  end
19
20
 
@@ -53,16 +54,20 @@ module PoolParty
53
54
  end
54
55
 
55
56
  def add_unpack
56
- has_exec "install_hermes",
57
+ has_exec "install_hermes",
57
58
  :command => "cd /tmp/hermes && escript target_system install hermes-#{hermes_release_version} #{remote_hermes_deployed_dir}",
58
59
  :creates => "#{remote_hermes_deployed_dir}/releases/#{hermes_release_version}",
59
- :requires => get_exec("install_erlang")
60
+ :requires => get_package("erlang-dev")
61
+
62
+ has_link :name => "collectd_dir",
63
+ :to => "/var/lib/collectd/rrd/\#{`hostname -f`.chomp}", :source => "/var/lib/collectd/localhost",
64
+ :requires => [get_package("collectd")]
60
65
  end
61
66
 
62
67
  def run_if_needed
63
- has_exec "env GEN_CLUSTER_SEED_CONFIG=/etc/poolparty/seeds.conf #{remote_hermes_deployed_dir}/bin/erl -boot #{remote_hermes_deployed_dir}/releases/#{hermes_release_version}/start -noshell -detached",
68
+ has_exec "env GEN_CLUSTER_SEED_CONFIG=/etc/poolparty/seeds.conf HERMES_RRD_DIRECTORY=/var/lib/collectd/localhost #{remote_hermes_deployed_dir}/bin/erl -boot #{remote_hermes_deployed_dir}/releases/#{hermes_release_version}/start -noshell -detached",
64
69
  :not_if => "ps aux | grep -v grep | grep hermes | grep beam",
65
- :requires => get_exec("install_hermes")
70
+ :requires => [get_exec("install_hermes"), get_link("collectd_dir")]
66
71
  end
67
72
 
68
73
  private
@@ -66,8 +66,8 @@ end
66
66
  file = arg.first
67
67
  @template = if File.file?(b = File.expand_path(file))
68
68
  b
69
- elsif File.file?(c = File.expand_path(File.join(clouds_dot_rb_dir, file)))
70
- c
69
+ elsif File.file?(d = File.expand_path(File.join(clouds_dot_rb_dir, file)))
70
+ d
71
71
  elsif f = search_in_known_locations(file)
72
72
  f
73
73
  else
@@ -30,12 +30,13 @@ module PoolParty
30
30
 
31
31
  default_options(
32
32
  :link_type => :symbolic,
33
+ :source => nil,
33
34
  :to => nil
34
35
  )
35
36
 
36
37
  def print_to_chef
37
38
  <<-EOE
38
- link "<%= name %>" do
39
+ link "<%= source || name %>" do
39
40
  link_type <%= print_variable(link_type) %>
40
41
  action :<%= exists? ? :create : :delete %>
41
42
  to <%= print_variable(to) %>
@@ -4,7 +4,31 @@ class CommandInterfaceHandler
4
4
  cr = CloudThrift::CloudResponse.new
5
5
  cr.name = cld.name
6
6
  cr.command = command
7
- resp = begin
7
+
8
+ cr.response = format_response(get_response(cld, command, args))
9
+
10
+ return cr
11
+ end
12
+
13
+ def cast_command(cld, command, args)
14
+
15
+ cr = CloudThrift::CloudResponse.new
16
+ cr.name = cld.name
17
+ cr.command = command
18
+ cr.response = format_response("Running command: #{command}(#{args})")
19
+
20
+ fork do
21
+ get_response(cld, command, args)
22
+ end
23
+
24
+ return cr
25
+ end
26
+
27
+
28
+ private
29
+
30
+ def get_response(cld, command, args)
31
+ begin
8
32
  the_cloud = clouds[cld.name]
9
33
  if the_cloud
10
34
  if command.include?(".")
@@ -25,15 +49,9 @@ class CommandInterfaceHandler
25
49
  end
26
50
  rescue Exception => e
27
51
  cr.response = "Error: #{e.inspect}"
28
- end
29
-
30
- cr.response = format_response(resp)
31
-
32
- return cr
52
+ end
33
53
  end
34
54
 
35
- private
36
-
37
55
  def format_response(resp)
38
56
  case resp
39
57
  when Array
@@ -44,4 +62,5 @@ class CommandInterfaceHandler
44
62
  [resp]
45
63
  end.map {|ele| ele.to_s }
46
64
  end
65
+
47
66
  end
data/tasks/poolparty.rake CHANGED
@@ -22,6 +22,30 @@ task :thrift do
22
22
  end
23
23
  end
24
24
 
25
+ namespace(:hermes) do
26
+
27
+ desc "Pack for distribution"
28
+ task :target_system do
29
+ erl_dir = File.dirname(__FILE__) + "/../vendor/erlang"
30
+ hermes_dir = File.join(erl_dir, "hermes")
31
+
32
+ puts `cd #{hermes_dir} && make target_system`
33
+ end
34
+ desc "Update hermes code"
35
+ task :update do
36
+ erl_dir = File.dirname(__FILE__) + "/../vendor/erlang"
37
+ hermes_dir = File.join(erl_dir, "hermes")
38
+
39
+ if File.directory?(hermes_dir)
40
+ `cd #{hermes_dir} && git pull origin master`
41
+ else
42
+ FileUtils.mkdir_p erl_dir
43
+ r = "git clone git://github.com/auser/hermes.git #{hermes_dir}"
44
+ Kernel.system r
45
+ end
46
+ end
47
+ end
48
+
25
49
  namespace(:pp) do
26
50
  task :build_gem => ["poolparty:vendor:setup", "poolparty:vendor:update", :gemspec, :build]
27
51
 
@@ -134,7 +134,6 @@ class CloudTest < Test::Unit::TestCase
134
134
  assert_equal 22, clouds["noneity"].ssh_port
135
135
  end
136
136
 
137
-
138
137
  def test_children_getting_parent_options
139
138
  clear!
140
139
  pool "outside" do
@@ -183,5 +182,11 @@ class CloudTest < Test::Unit::TestCase
183
182
  assert_equal 1, clouds["app_cloud"].monitors.size
184
183
 
185
184
  clouds["app_cloud"].compile
185
+
186
+ compile_dir = clouds["app_cloud"].tmp_path/"etc"/"chef"/"cookbooks"/"poolparty"
187
+ recipe_file = compile_dir/"recipes"/"default.rb"
188
+ recipe_contents = open(recipe_file).read
189
+
190
+ assert_match /install hermes/, recipe_contents
186
191
  end
187
192
  end
@@ -3,7 +3,7 @@ require "#{File.dirname(__FILE__)}/../../test_helper"
3
3
  class MonitorTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- @mon = PoolParty::Monitor.new(:'cpu-idle') do |c|
6
+ @mon = PoolParty::Monitor.new("cpu-idle") do |c|
7
7
  vote_for(:expand) if c > 0.8
8
8
  configure if c < 0.1
9
9
  end
@@ -27,6 +27,7 @@ end'
27
27
  pool "conditional_cloud" do
28
28
  cloud "test" do
29
29
 
30
+ keypair "test_key"
30
31
  has_case "os" do
31
32
  when_is :ubuntu, "git-core"
32
33
  else_is "git"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auser-poolparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.10
4
+ version: 1.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Lerner