auser-poolparty 1.2.7 → 1.2.8
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/README.txt +1 -1
- data/VERSION.yml +1 -1
- data/bin/cloud-configure +1 -1
- data/bin/cloud-contract +1 -1
- data/bin/cloud-expand +1 -1
- data/bin/cloud-list +3 -3
- data/bin/cloud-ssh +1 -1
- data/bin/cloud-start +1 -1
- data/bin/server-cloud-elections +17 -23
- data/bin/server-list-active +24 -16
- data/bin/server-manage-election +13 -21
- data/bin/server-show-stats +1 -1
- data/examples/metavirt_cloud.rb +12 -8
- data/examples/{poolparty.rb → simple.rb} +0 -0
- data/examples/vmrun_cloud.rb +20 -0
- data/lib/poolparty/core/proc.rb +0 -7
- data/lib/poolparty/dependency_resolver/chef_resolver.rb +1 -1
- data/lib/poolparty/dependency_resolver/puppet.rb +0 -1
- data/lib/poolparty/helpers/console.rb +0 -5
- data/lib/poolparty/modules/callbacks.rb +7 -0
- data/lib/poolparty/modules/cloud_dsl.rb +0 -6
- data/lib/poolparty/modules/cloud_resourcer.rb +38 -20
- data/lib/poolparty/modules/searchable_paths.rb +5 -1
- data/lib/poolparty/net/init.rb +17 -4
- data/lib/poolparty/net/remoter/interactive.rb +1 -1
- data/lib/poolparty/net/remoter_base.rb +40 -19
- data/lib/poolparty/net/remoter_bases/ec2/ec2.rb +7 -2
- data/lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb +1 -0
- data/lib/poolparty/net/remoter_bases/ec2/ec2_response_object.rb +2 -2
- data/lib/poolparty/net/remoter_bases/metavirt/metavirt.rb +21 -20
- data/lib/poolparty/plugins/apache2/apache.rb +24 -4
- data/lib/poolparty/plugins/authorized_key.rb +29 -0
- data/lib/poolparty/plugins/chef.rb +2 -2
- data/lib/poolparty/plugins/deploy_directory.rb +7 -2
- data/lib/poolparty/poolparty/cloud.rb +110 -23
- data/lib/poolparty/poolparty/plugin_model.rb +1 -0
- data/lib/poolparty/poolparty/poolparty_base_class.rb +25 -3
- data/lib/poolparty/poolparty/resource.rb +1 -6
- data/lib/poolparty/provision/boot_strapper.rb +5 -1
- data/lib/poolparty/resources/directory.rb +1 -1
- data/lib/poolparty/resources/symlink.rb +9 -2
- data/lib/poolparty/resources/user.rb +16 -1
- data/lib/poolparty/schema.rb +3 -4
- data/lib/poolparty/templates/haproxy.conf +1 -1
- data/lib/poolparty.rb +1 -1
- data/spec/poolparty/core/object_spec.rb +0 -24
- data/spec/poolparty/fixtures/fake_key.pub +1 -0
- data/spec/poolparty/modules/searchable_paths_spec.rb +12 -5
- data/spec/poolparty/net/remoter_bases/ec2_spec.rb +1 -1
- data/spec/poolparty/plugins/authorized_key_spec.rb +23 -0
- data/spec/poolparty/poolparty/cloud_spec.rb +3 -3
- data/test/poolparty/dependency_resolver/puppet_resolver_test.rb +1 -1
- data/test/poolparty/net/remoter_bases/metavirt/metavirt_test.rb +1 -4
- data/test/poolparty/poolparty/cloud_test.rb +40 -0
- data/test/test_helper.rb +1 -1
- metadata +8 -10
- data/lib/poolparty/core/metaid.rb +0 -15
- data/lib/poolparty/core/module.rb +0 -40
- data/lib/poolparty/helpers/display.rb +0 -30
- data/lib/poolparty/net/remote_bases.rb +0 -22
- data/spec/poolparty/core/module_spec.rb +0 -15
- data/spec/poolparty/helpers/display_spec.rb +0 -13
- data/spec/poolparty/id_rsa +0 -27
data/README.txt
CHANGED
@@ -44,7 +44,7 @@ sudo gem install auser-poolparty
|
|
44
44
|
|
45
45
|
(The MIT License)
|
46
46
|
|
47
|
-
Copyright (c) 2008 Ari Lerner
|
47
|
+
Copyright (c) 2008 Ari Lerner, CloudTeam
|
48
48
|
|
49
49
|
Permission is hereby granted, free of charge, to any person obtaining
|
50
50
|
a copy of this software and associated documentation files (the
|
data/VERSION.yml
CHANGED
data/bin/cloud-configure
CHANGED
@@ -25,7 +25,7 @@ EOS
|
|
25
25
|
puts "No nodes to bootstrap"
|
26
26
|
else
|
27
27
|
if command[:inst_num]
|
28
|
-
vputs "\nConfiguring: #{nodes[o.inst_num]}\n--------------------"
|
28
|
+
vputs "\nConfiguring: #{cld.nodes[o.inst_num]}\n--------------------"
|
29
29
|
address = cld.nodes(:status => "running")[ command[:inst_num] ]
|
30
30
|
::PoolParty::Provision::DrConfigure.new( address[:ip], :cloud => cld )
|
31
31
|
else
|
data/bin/cloud-contract
CHANGED
@@ -17,7 +17,7 @@ EOS
|
|
17
17
|
run do |command|
|
18
18
|
@loaded_clouds.each do |cld|
|
19
19
|
|
20
|
-
puts
|
20
|
+
puts "Contracting cloud #{cld.name}"
|
21
21
|
puts "#{cld.nodes(:status => "running").size} running instances (#{cld.minimum_instances} minimum instances)"
|
22
22
|
puts testing ? "Not contracting (test mode)" : "Contracting the cloud if possible"
|
23
23
|
|
data/bin/cloud-expand
CHANGED
@@ -17,7 +17,7 @@ EOS
|
|
17
17
|
run do |command|
|
18
18
|
@loaded_clouds.each do |cld|
|
19
19
|
|
20
|
-
vputs
|
20
|
+
vputs "Expanding cloud #{cld.name}"
|
21
21
|
vputs "#{cld.nodes(:status => "running").size} running instances of #{cld.maximum_instances} possible instances"
|
22
22
|
vputs testing ? "Not expanding (test mode)" : "Expanding the cloud"
|
23
23
|
|
data/bin/cloud-list
CHANGED
@@ -23,12 +23,12 @@ EOS
|
|
23
23
|
require 'pp'
|
24
24
|
pp result = cld.describe_instance(:instance_id=>command[:instance_id])
|
25
25
|
else
|
26
|
-
puts
|
27
|
-
puts
|
26
|
+
puts "Listing cloud #{cld.name}"
|
27
|
+
puts "Active instances"
|
28
28
|
puts cld.nodes(:status => "running").map{|a| "#{a[:instance_id] || a[:id]}\t#{a[:ip] ||a[:public_ip] }" }.join("\n")
|
29
29
|
|
30
30
|
if cld.nodes(:status => "pending").size > 0
|
31
|
-
puts
|
31
|
+
puts "Pending instances"
|
32
32
|
puts cld.nodes(:status => "pending").map{|a| "#{a[:instance_id] || a[:id]}\t#{a[:ip] ||a[:public_ip] }" }.join("\n")
|
33
33
|
end
|
34
34
|
end
|
data/bin/cloud-ssh
CHANGED
@@ -13,7 +13,7 @@ Usage: #{$0} #{all_options_string}
|
|
13
13
|
EOS
|
14
14
|
|
15
15
|
short_desc "ssh into an instance of the cloud"
|
16
|
-
opt :inst_num, "The number of the instance to
|
16
|
+
opt :inst_num, "The number of the instance to ssh to, starts at 0.", :type => :int
|
17
17
|
|
18
18
|
run do |command|
|
19
19
|
@cloud = @loaded_clouds.first
|
data/bin/cloud-start
CHANGED
@@ -19,7 +19,7 @@ EOS
|
|
19
19
|
@loaded_clouds.each do |cld|
|
20
20
|
|
21
21
|
if cld.nodes(:status => "running").size.zero?
|
22
|
-
puts
|
22
|
+
puts "Starting cloud #{cld.name} (#{cld.keypair})"
|
23
23
|
puts "#{cld.nodes(:status => "running").size} running instances (#{cld.minimum_instances} - #{cld.maximum_instances})"
|
24
24
|
|
25
25
|
cld.launch_instance!(:cloud_name => cld.name) do |node|
|
data/bin/server-cloud-elections
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
3
|
require "poolparty"
|
4
|
-
require "poolparty/lite"
|
5
4
|
|
6
5
|
o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
|
7
6
|
opts.on('-n cloudname', '--name name', 'Start cloud by this name') { |c| optioner.cloudname c }
|
@@ -10,28 +9,23 @@ end
|
|
10
9
|
|
11
10
|
vote_for = o.unflagged_args.shift || "none"
|
12
11
|
|
13
|
-
|
14
|
-
remote_base = PoolParty::Remote.module_eval( schema.options.remoter_base.camelcase )
|
12
|
+
cld = ::PoolParty::Cloud::Cloud.load_from_json(ENV['CLOUDS_JSON_FILE'] || '/etc/poolparty/clouds.json') #TODO: smarter option parser
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
::PoolParty::Provision::BootStrapper.new( node[:ip], :cloud => cld )
|
25
|
-
::PoolParty::Provision::DrConfigure.new( node[:ip], :cloud => cld )
|
26
|
-
end
|
27
|
-
|
28
|
-
when "contract"
|
29
|
-
`rm /etc/poolparty/neighborhood.json`
|
30
|
-
last_instance_id = %x[server-list-active instance_id].split("\t").last
|
31
|
-
remote_base.terminate_instance! schema.options.merge(:instance_id => last_instance_id)
|
32
|
-
else
|
33
|
-
puts "Unknown action: #{vote_for}"
|
34
|
-
remote_base.describe_instances
|
35
|
-
end
|
14
|
+
case vote_for
|
15
|
+
when "expand"
|
16
|
+
puts "Launching new instance"
|
17
|
+
cld.launch_instance! do |node|
|
18
|
+
dputs "Started node at #{node[:ip]}"
|
19
|
+
::PoolParty::Provision::BootStrapper.new( node[:ip], :cloud => cld )
|
20
|
+
::PoolParty::Provision::DrConfigure.new( node[:ip], :cloud => cld )
|
21
|
+
end
|
36
22
|
|
23
|
+
when "contract"
|
24
|
+
last_instance_id = %x[server-list-active instance_id].split("\t").last
|
25
|
+
cloud.terminate_instance!(:instance_id => last_instance_id)
|
26
|
+
when 'none'
|
27
|
+
nil
|
28
|
+
else
|
29
|
+
puts "Unknown action: #{vote_for}"
|
37
30
|
end
|
31
|
+
|
data/bin/server-list-active
CHANGED
@@ -1,24 +1,32 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
-
require "poolparty/lite"
|
4
|
-
require "poolparty/core/array"
|
3
|
+
# require "poolparty/lite"
|
4
|
+
# require "poolparty/core/array"
|
5
|
+
require 'poolparty'
|
5
6
|
|
6
7
|
list_type = ARGV.shift || "ip"
|
7
8
|
|
8
|
-
json_file = ARGV[0] || PoolParty::Default.properties_hash_file
|
9
|
+
json_file = ARGV[0] || ENV['CLOUD_JSON_FILE'] || PoolParty::Default.properties_hash_file
|
9
10
|
raise "ERROR: no json_file given" if !json_file
|
10
|
-
schema = PoolParty::Schema.new( ::File.read(json_file) )
|
11
11
|
|
12
|
-
|
12
|
+
cld = Cloud.load_from_json(::File.read(json_file))
|
13
|
+
conditions= {:status=>'running', :keypair=>cld.keypair_name}
|
14
|
+
inst_array = cld.remote_base.describe_instances.select_with_hash(conditions)
|
15
|
+
puts inst_array.collect{|n| n[list_type] || n[list_type.to_sym]}.join("\t")
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
|
18
|
+
# schema = PoolParty::Schema.new( ::File.read(json_file) )
|
19
|
+
#
|
20
|
+
# inst_array = nil #PoolParty::Neighborhoods.load_default.instances
|
21
|
+
#
|
22
|
+
# if !inst_array || inst_array.empty?
|
23
|
+
# remote_base = PoolParty::Remote.module_eval( schema.options.remoter_base.camelcase )
|
24
|
+
# instances = remote_base.send :describe_instances, schema.options.keypair_name
|
25
|
+
# inst_array = instances.map {|inst| inst.send list_type.to_sym }.compact
|
26
|
+
# if ['ip', 'public_id', 'internal_ip'].include? list_type
|
27
|
+
# inst_array.delete_if{|n| !n.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) }
|
28
|
+
# end
|
29
|
+
# print inst_array.compact.join("\t")
|
30
|
+
# else
|
31
|
+
# print inst_array.map {|inst| inst.send list_type.to_sym }.compact.join("\t")
|
32
|
+
# end
|
data/bin/server-manage-election
CHANGED
@@ -1,29 +1,23 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# Call server-list-active and get the neighborhood ips back
|
3
|
-
# then call each of those at the port of butterfly and retain the json
|
4
|
-
# From there, mash it up together and call server-handle-election
|
5
|
-
# to handle the election process
|
6
|
-
|
7
|
-
# Error codes
|
8
|
-
# 1 -> clouds.json was not loaded
|
9
|
-
# 2 -> server-list-active didn't run
|
10
2
|
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
11
3
|
require "rubygems"
|
12
4
|
require 'net/http'
|
13
5
|
require 'json'
|
14
|
-
require "poolparty/lite"
|
6
|
+
#require "poolparty/lite"
|
7
|
+
require 'poolparty'
|
15
8
|
|
16
9
|
status = ARGV.shift || "running" # or pending or terminated
|
17
|
-
schema = ::PoolParty.
|
10
|
+
schema = ::PoolParty::Cloud::Cloud.load_from_json(ENV['CLOUDS_JSON_FILE'] || '/etc/poolparty/clouds.json')
|
18
11
|
|
19
12
|
def get_json_stats_from(ip, port)
|
20
|
-
Net::HTTP.start(ip, port) {|http| http.get('/stats
|
13
|
+
Net::HTTP.start(ip, port) {|http| http.get('/stats') }.body rescue "{}"
|
21
14
|
end
|
22
|
-
|
23
|
-
ips = %x[server-list-active internal_ip].split("\t")
|
24
15
|
|
25
|
-
|
26
|
-
|
16
|
+
#ips = %x[server-list-active internal_ip].split("\t")
|
17
|
+
ips = schema.describe_instances.select_with_hash(:status=>'running').collect{|n| n.ip} #TODO: needs to filter to only this cloud
|
18
|
+
|
19
|
+
minimum_instances = schema.dsl_options.minimum_instances
|
20
|
+
maximum_instances = schema.dsl_options.maximum_instances
|
27
21
|
|
28
22
|
if ips.size < minimum_instances
|
29
23
|
puts "Cloud is too small, need to expand"
|
@@ -31,7 +25,7 @@ if ips.size < minimum_instances
|
|
31
25
|
exit(0)
|
32
26
|
elsif ips.size > maximum_instances
|
33
27
|
puts "Cloud is too big, need to contract"
|
34
|
-
%x[
|
28
|
+
%x[server-cloud-elections contract]
|
35
29
|
exit(0)
|
36
30
|
end
|
37
31
|
|
@@ -49,17 +43,15 @@ candidates.each do |action, ballots|
|
|
49
43
|
end
|
50
44
|
end
|
51
45
|
|
52
|
-
puts total_json_hash.inspect
|
53
|
-
puts candidates.inspect
|
54
|
-
|
55
46
|
# Expand the cloud if 50+% of the votes are for expansion
|
56
47
|
# Contract the cloud if 51+% of the votes are for contraction
|
57
48
|
@elected_action = candidates[:elected_action] || "none"
|
49
|
+
puts "checking nominations"
|
58
50
|
if (candidates[:expand] - candidates[:contract])/total_json_hash.size > 0.5
|
59
|
-
%x[
|
51
|
+
%x[server-cloud-elections expand] unless @elected_action == "expand"
|
60
52
|
@elected_action = "expand"
|
61
53
|
elsif (candidates[:contract] - candidates[:expand])/total_json_hash.size > 0.5
|
62
|
-
%x[
|
54
|
+
%x[server-cloud-elections contract] unless @elected_action == "contract"
|
63
55
|
@elected_action = "contract"
|
64
56
|
end
|
65
57
|
|
data/bin/server-show-stats
CHANGED
data/examples/metavirt_cloud.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
$:.unshift File.dirname(__FILE__)+'/../lib/'
|
3
|
+
require "poolparty"
|
2
4
|
|
3
|
-
pool :
|
5
|
+
pool :multiverse do
|
4
6
|
|
5
|
-
cloud :
|
7
|
+
cloud :vv do
|
6
8
|
keypair "front"
|
7
|
-
instances
|
9
|
+
instances 2
|
10
|
+
has_file "/etc/motd", :content => "Welcome to your poolparty instance!"
|
8
11
|
using :metavirt do
|
12
|
+
server_config({:host=>"172.16.68.1", :port=>3000})
|
9
13
|
authorized_keys 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCTppECfx7Tb0zoviRfqFaePyAek6+ZktKkHiTHu/jkhG1s4q1oHEe89no21xLxuReyJrDlNe8rLxxZzoYCaAWRdhcqMR3BNqb2w2jpF4pH+bFj0557KrwWP6HSNpRRkyYhxLqZbuH/2t3TzkPevZbcfSYa09jIzqnmTruh9l1s+n5E3cNr/RDdDn7tv3Ok7mKN7GEjkK7F83Pt9xviHevg22xqzm99nS+hg6Kl/fQUTO6pOmC5x+9V47RJz1+9WdhGJ7M83zijX9rMnAwrR5LFoL6aZyyU0G71SpoIL5e8XD/jt1WNKFJOfG8YMLb3i03UABm/Q5Q30+R7UoRxSWRX'
|
10
|
-
server_config = {:host=>'localhost', :port=>3000}
|
11
14
|
using :vmrun do
|
15
|
+
# vmx_files Dir[::File.expand_path("~/Documents/Virtual Machines.localized/metavirts/*/*.vmx")]
|
12
16
|
vmx_files [
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
"/Users/mfairchild/Documents/Virtual\ Machines.localized/Ubuntu-jaunty.vmwarevm/Ubuntu-jaunty.vmx",
|
18
|
+
"/Users/mfairchild/Documents/Virtual\ Machines.localized/metavirts/Ubuntu32bitVM copy.vmwarevm/Ubuntu32bitVM.vmx"
|
19
|
+
]
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
$:.unshift File.dirname(__FILE__)+'/../lib/'
|
3
|
+
require "poolparty"
|
4
|
+
|
5
|
+
pool :multiverse do
|
6
|
+
|
7
|
+
cloud :vv do
|
8
|
+
keypair "front"
|
9
|
+
instances 2
|
10
|
+
has_file "/etc/motd", :content => "Welcome to your poolparty instance!"
|
11
|
+
using :vmrun do
|
12
|
+
vmx_files [
|
13
|
+
"/Users/mfairchild/Documents/Virtual\ Machines.localized/Ubuntu-jaunty.vmwarevm/Ubuntu-jaunty.vmx",
|
14
|
+
"/Users/mfairchild/Documents/Virtual\ Machines.localized/metavirts/Ubuntu32bitVM copy.vmwarevm/Ubuntu32bitVM.vmx"
|
15
|
+
]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
data/lib/poolparty/core/proc.rb
CHANGED
@@ -22,6 +22,13 @@ module PoolParty
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Callbacks on bootstrap and configuration
|
25
|
+
# Defines the callback accessors:
|
26
|
+
# call_before/after_bootstrap/configure_callbacks
|
27
|
+
#
|
28
|
+
# When called, this method will first check to see if there
|
29
|
+
# are plugins and call those plugin's callbacks when called
|
30
|
+
# The method (before/after_bootstrap/configure) is called
|
31
|
+
# on self if the callback method is defined on self
|
25
32
|
def setup_callbacks
|
26
33
|
defined_callbacks.each do |meth|
|
27
34
|
unless respond_to?("call_#{meth}_callbacks".to_sym)
|
@@ -11,12 +11,6 @@ module PoolParty
|
|
11
11
|
# has_directory(:name => loc)
|
12
12
|
# end
|
13
13
|
|
14
|
-
def set_dependency_resolver(name='chef')
|
15
|
-
klass = name.preserved_class_constant("Resolver")
|
16
|
-
raise DependencyResolverException.new("Unknown resolver") unless klass
|
17
|
-
self.dependency_resolver = klass unless dsl_options[:dependency_resolver]
|
18
|
-
end
|
19
|
-
|
20
14
|
# Enable a service package
|
21
15
|
def enable(*services)
|
22
16
|
services.each do |service|
|
@@ -59,35 +59,53 @@ module PoolParty
|
|
59
59
|
# Check to make sure the available_bases is available, otherwise raise
|
60
60
|
# Give access to the cloud the remote_base and instantiate a new
|
61
61
|
# instance of the remote base
|
62
|
-
def using(t, &block)
|
62
|
+
def using(t, o={}, &block)
|
63
63
|
return self.send(t) if self.respond_to?(t)
|
64
|
-
if
|
64
|
+
if ::PoolParty::Remote::RemoterBase.available_bases.include?(t.to_sym)
|
65
65
|
klass_string = "#{t}".classify
|
66
66
|
remote_base_klass = "::PoolParty::Remote::#{klass_string}".constantize
|
67
67
|
set_default_options(remote_base_klass.default_options)
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
|
69
|
+
@remote_base = remote_base_klass.send(:new, o.merge(:cloud=>self), &block)
|
70
|
+
self.remoter_base t.to_sym
|
71
|
+
instance_eval "def #{t};@remote_base;end"
|
72
|
+
|
73
|
+
# instance_eval "def launch_new_instance!(o={}); remote_base.launch_new_instance!;end"
|
74
|
+
# instance_eval "def terminate_instance!(o={}); remote_base.terminate_instance!(o);end"
|
75
|
+
# instance_eval "def describe_instances(o={}); remote_base.describe_instances;end"
|
76
|
+
# instance_eval "def describe_instance(o={}); remote_base.describe_instance(o);end"
|
71
77
|
else
|
72
78
|
raise "Unknown remote base: #{t}"
|
73
79
|
end
|
74
80
|
end
|
75
|
-
|
76
|
-
def
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
# dsl_options[:keypairs] = keypairs
|
87
|
-
#
|
88
|
-
# dsl_options[:dependency_resolver] = schema.options.dependency_resolver.split("::")[-1].gsub(/Resolver/, '').preserved_class_constant("Resolver") rescue PoolParty::Chef
|
89
|
-
|
81
|
+
|
82
|
+
def dependency_resolver(name=nil)
|
83
|
+
if !name.nil?
|
84
|
+
ext = name=~/Resolver$/ ? nil : 'Resolver'
|
85
|
+
klass = ::PoolParty.module_eval("#{name.camelcase}#{ext}")
|
86
|
+
raise DependencyResolverException.new("Unknown resolver") unless klass
|
87
|
+
dsl_options[:dependency_resolver] = "#{name.camelcase}#{ext}"
|
88
|
+
@dependency_resolver = klass
|
89
|
+
else
|
90
|
+
@dependency_resolver
|
91
|
+
end
|
90
92
|
end
|
93
|
+
|
94
|
+
# def update_from_schema(schema)
|
95
|
+
# self.dsl_options.merge! schema.options.to_hash
|
96
|
+
# self.dependency_resolver = schema.options.dependency_resolver.split("::")[-1].gsub(/Resolver/, '').preserved_class_constant("Resolver") rescue PoolParty::Chef
|
97
|
+
# keypair schema.options.keypair_name
|
98
|
+
# remote_base_class = PoolParty::Remote.module_eval( schema.options.remoter_base.camelcase )
|
99
|
+
# self.remote_base = remote_base_class.new schema.options.remote_base.to_hash
|
100
|
+
#
|
101
|
+
# # self.keypair = PoolParty::Key.new schema.options.keypair.basename
|
102
|
+
# # keypair = schema.options.delete(:keypairs).map {|a| PoolParty::Key.new(a.basename) }
|
103
|
+
# # options.merge! schema.options.to_hash
|
104
|
+
# # dsl_options[:keypairs] = keypairs
|
105
|
+
# #
|
106
|
+
# # dsl_options[:dependency_resolver] = schema.options.dependency_resolver.split("::")[-1].gsub(/Resolver/, '').preserved_class_constant("Resolver") rescue PoolParty::Chef
|
107
|
+
#
|
108
|
+
# end
|
91
109
|
|
92
110
|
end
|
93
111
|
end
|
@@ -73,8 +73,12 @@ module PoolParty
|
|
73
73
|
# in the searchable_paths.
|
74
74
|
#
|
75
75
|
# Returns +nil+ if the file cannot be found.
|
76
|
-
def search_in_known_locations(filepath)
|
76
|
+
def search_in_known_locations(filepath, additional_search_paths=[])
|
77
77
|
return filepath if ::File.exists?(filepath) # return the file if its an absolute path
|
78
|
+
additional_search_paths.each do |path|
|
79
|
+
full_path = ::File.expand_path(path / filepath)
|
80
|
+
return full_path if ::File.exists?(full_path)
|
81
|
+
end
|
78
82
|
self.class.searchable_paths.each do |path|
|
79
83
|
self.class.searchable_paths_dirs.each do |dir|
|
80
84
|
full_path = ::File.expand_path(path / dir / filepath)
|
data/lib/poolparty/net/init.rb
CHANGED
@@ -1,10 +1,23 @@
|
|
1
|
+
class Object
|
2
|
+
#TODO: deprecate. use RemoterBase.available_bases instead
|
3
|
+
def remote_bases
|
4
|
+
$remote_bases ||= []
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
1
8
|
# Load the core net libraries. These are neccessary for any of the remoter_bases to function.
|
2
|
-
%w(remote_instance
|
9
|
+
%w(remote_instance remoter_base).each do |file|
|
3
10
|
require File.join(::File.dirname(__FILE__),file+'.rb')
|
4
11
|
end
|
12
|
+
#
|
13
|
+
# # Register available remoter_bases
|
14
|
+
# Dir["#{::File.dirname(__FILE__)}/remoter_bases/*/*.rb"].each do |base|
|
15
|
+
# name = File.join(::File.basename(base, ::File.extname(base)))
|
16
|
+
# require base
|
17
|
+
# end
|
18
|
+
|
5
19
|
|
6
|
-
#
|
7
|
-
|
8
|
-
name = File.join(::File.basename(base, ::File.extname(base)))
|
20
|
+
Dir["#{::File.dirname(__FILE__)}/remoter_bases/*/*.rb"].each do |base|
|
21
|
+
name = ::File.basename(base, ::File.extname(base))
|
9
22
|
require base
|
10
23
|
end
|
@@ -12,7 +12,7 @@ module PoolParty
|
|
12
12
|
def list_of_instances(with_neighborhood_default=true)
|
13
13
|
return @list_of_instances if @list_of_instances
|
14
14
|
@containing_cloud = self
|
15
|
-
n =
|
15
|
+
n = false ? Neighborhoods.load_default : nil
|
16
16
|
@list_of_instances = ((n.nil? || n.instances.empty?) ? _list_of_instances : n.instances)
|
17
17
|
end
|
18
18
|
|
@@ -26,8 +26,7 @@ module PoolParty
|
|
26
26
|
include ::PoolParty::Remote
|
27
27
|
include ::PoolParty::Pinger
|
28
28
|
|
29
|
-
dsl_methods :
|
30
|
-
:keypair,
|
29
|
+
dsl_methods :keypair,
|
31
30
|
:image_id,
|
32
31
|
:keypair_name
|
33
32
|
|
@@ -37,6 +36,14 @@ module PoolParty
|
|
37
36
|
instance_eval &block if block
|
38
37
|
end
|
39
38
|
|
39
|
+
def cloud(n=nil)
|
40
|
+
if n.nil?
|
41
|
+
@cloud
|
42
|
+
else
|
43
|
+
@cloud = n
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
40
47
|
# def evaluate_proc_options(opts)
|
41
48
|
# if opts.respond_to?(:call)
|
42
49
|
# opts.call
|
@@ -50,8 +57,12 @@ module PoolParty
|
|
50
57
|
# opts
|
51
58
|
# end
|
52
59
|
|
60
|
+
def self.available_bases
|
61
|
+
@available_bases ||= []
|
62
|
+
end
|
53
63
|
def self.inherited(arg)
|
54
64
|
base_name = "#{arg}".downcase.top_level_class.to_sym
|
65
|
+
(available_bases << base_name) unless available_bases.include?(base_name)
|
55
66
|
(remote_bases << base_name) unless remote_bases.include?(base_name)
|
56
67
|
end
|
57
68
|
|
@@ -105,11 +116,11 @@ module PoolParty
|
|
105
116
|
# TODO: Rename and modularize the @inst.status =~ /pending/ so that it works on all
|
106
117
|
# remoter_bases
|
107
118
|
def launch_instance!(o={}, &block)
|
108
|
-
@cloud = clouds[o[:cloud_name]]
|
119
|
+
@cloud = clouds[o[:cloud_name] || o[:name]]
|
109
120
|
@inst = launch_new_instance!( dsl_options.merge(o) )
|
110
121
|
sleep(2)
|
111
122
|
|
112
|
-
|
123
|
+
dputs "#{@cloud.name} launched instance checking for ip..."
|
113
124
|
|
114
125
|
# Wait for 10 minutes for the instance to gain an ip if it doesn't already have one
|
115
126
|
500.times do |i|
|
@@ -118,10 +129,10 @@ module PoolParty
|
|
118
129
|
break if @inst[:public_ip] && @inst[:public_ip] =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
|
119
130
|
sleep(2)
|
120
131
|
@inst = describe_instance(@inst)
|
121
|
-
|
132
|
+
dprint "."
|
122
133
|
else
|
123
134
|
@inst = describe_instances.last
|
124
|
-
|
135
|
+
dprint "."
|
125
136
|
end
|
126
137
|
end
|
127
138
|
dputs "Found an ip"
|
@@ -130,9 +141,9 @@ module PoolParty
|
|
130
141
|
|
131
142
|
# Try for 10 minutes to pint port 22
|
132
143
|
500.times do |i|
|
133
|
-
|
144
|
+
dprint "."
|
134
145
|
if ping_port(@inst[:ip], 22)
|
135
|
-
|
146
|
+
dputs ""
|
136
147
|
@cloud.started_instance = @inst
|
137
148
|
|
138
149
|
@cloud.call_after_launch_instance_callbacks(@inst)
|
@@ -153,6 +164,16 @@ module PoolParty
|
|
153
164
|
def after_launch_instance(instance=nil)
|
154
165
|
puts "after_launch_instance in remoter_base"
|
155
166
|
end
|
167
|
+
|
168
|
+
def remoter_base_options(n=nil)
|
169
|
+
if n.nil?
|
170
|
+
dsl_options[:remoter_base_options]
|
171
|
+
else
|
172
|
+
dsl_options[:remoter_base_options] = remote_base.dsl_options.choose do |k,v|
|
173
|
+
v && (v.respond_to?(:empty) ? !v.empty?: true)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
156
177
|
|
157
178
|
#TODO: Remove
|
158
179
|
# def self.when_instance_is_responding(inst, &block)
|
@@ -165,17 +186,17 @@ module PoolParty
|
|
165
186
|
# def when_instance_is_responding(inst, &block);self.class.when_instance_is_responding;end
|
166
187
|
|
167
188
|
# TODO: BAD FORM, already defined in connections.rb. Fix this, ASAP
|
168
|
-
def self.ping_port(host, port=22, retry_times=400)
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
end
|
189
|
+
# def self.ping_port(host, port=22, retry_times=400)
|
190
|
+
# connected = false
|
191
|
+
# retry_times.times do |i|
|
192
|
+
# begin
|
193
|
+
# break if connected = TCPSocket.new(host, port).is_a?(TCPSocket)
|
194
|
+
# rescue Exception => e
|
195
|
+
# sleep(2)
|
196
|
+
# end
|
197
|
+
# end
|
198
|
+
# connected
|
199
|
+
# end
|
179
200
|
|
180
201
|
# After launch callback
|
181
202
|
# This is called after a new instance is launched
|