lib/poolparty/pool/base.rb in poolparty-0.2.18 vs lib/poolparty/pool/base.rb in poolparty-0.2.69
- old
+ new
@@ -8,50 +8,66 @@
class Base
include Configurable
extend MethodMissingSugar
default_options({
- :environment => "production",
:user => "root", # This should change here
- :base_keypair_path => "~/.ec2",
+ :base_keypair_path => "#{ENV["HOME"]}/.ec2",
:tmp_path => "/tmp/poolparty",
- :remote_storage_path => "/var/poolparty",
- :fileserver_base => "puppet:///files",
+ :remote_storage_path => "/var/poolparty",
+ :remote_gem_path => "/var/poolparty/gems",
+ :fileserver_base => "puppet://master/files",
:base_config_directory => "/etc/poolparty",
:template_directory => "templates",
:template_path => "/var/lib/puppet/templates",
:module_path => "/etc/puppet/modules/poolparty",
:default_specfile_name => "pool.spec",
+ :default_project_specfile_name => "spec/pool.spec",
:port => "80",
:forwarding_port => "8080",
- :proxy_mode => "http",
+ :proxy_mode => "http",
+ :messenger_client_port => 7050,
# EC2 Options
- :ami => "ami-1cd73375"
+ :ami => "ami-1cd73375",
+ :size => 'm1.small', # must be 'm1.small', 'm1.large', 'm1.xlarge', 'c1.medium', or 'c1.xlarge'
+ :security_group => ["default"],
+ # Options that should not be touched pretty much ever
+ :manifest_path => "/etc/puppet/manifests"
})
# Class methods
class << self
def options(h={})
@options ||= default_options.merge(h)
end
# Get the access_key
def access_key
- ENV["AWS_ACCESS_KEY_ID"] ? ENV["AWS_ACCESS_KEY_ID"] : load_keys_from_file[:access_key]
+ @access_key ||= ENV["AWS_ACCESS_KEY"] ? ENV["AWS_ACCESS_KEY"] : load_keys_from_file[:access_key]
end
def secret_access_key
- ENV["AWS_SECRET_ACCESS_ID"] ? ENV["AWS_SECRET_ACCESS_ID"] : load_keys_from_file[:secret_access_key]
+ @secret_access_key ||= ENV["AWS_SECRET_ACCESS_KEY"] ? ENV["AWS_SECRET_ACCESS_KEY"] : load_keys_from_file[:secret_access_key]
end
+ def read_keyfile
+ open(get_working_key_file_locations).read
+ end
def load_keys_from_file
- @keys ||= get_working_key_file_locations ? YAML::load( open(get_working_key_file_locations).read ) : {}
+ @keys ||= get_working_key_file_locations ? YAML::load( read_keyfile ) : {}
end
# Store the keys in a yaml format to give the master access
# So that the master has access to the files
def store_keys_in_file
unless access_key.nil? || secret_access_key.nil?
write_to_file( key_file_locations.first, YAML::dump({:access_key => access_key, :secret_access_key => secret_access_key}))
end
end
+ def store_keys_in_file_for(obj=nil)
+ if obj
+ @access_key = obj.access_key
+ @secret_access_key = obj.secret_access_key
+ end
+ store_keys_in_file
+ end
def reset!
@keys = nil
end
# Get the instance first instance file that exists on the system from the expected places
# denoted in the local_instances_list_file_locations
@@ -66,26 +82,39 @@
"#{Base.storage_directory}/ppkeys",
"~/.ppkeys",
"ppkeys"
]
end
-
def storage_directory
[
"/var/poolparty"
].select do |dir|
- dir if ::File.directory?(dir) && ::File.readable?(dir)
+ dir if viable_directory?(dir)
end.first || ::File.join( "/tmp/poolparty")
end
-
+ def logger_location
+ [
+ "/var/log/poolparty"
+ ].select do |dir|
+ dir if viable_directory?(dir)
+ end.first || ::File.join(Dir.pwd, "log")
+ end
+ # Assume the logs will be at the pool.log location within the
+ # logger_location set above
def pool_logger_location
- File.join(Dir.pwd, "logs")
+ ::File.join(logger_location, "pool.log")
end
-
- # Array of allowed_commands that you can run on the remote nodes
- def allowed_commands
- @allowed_commands ||= open(::File.join( ::File.dirname(__FILE__), "..", "config", "allowed_commands.yml")).read.split(/\n/).map {|a| a.chomp }
+ def custom_monitor_directories
+ [
+ "/var/poolparty/monitors",
+ "/etc/poolparty/monitors",
+ "#{Dir.pwd}/monitors"
+ ].select {|d| d if viable_directory?(d) }
end
-
+ # Only return true if the directory we are reading is both readable
+ # and exists
+ def viable_directory?(dir)
+ ::File.directory?(dir) && ::File.readable?(dir)
+ end
end
end
end
\ No newline at end of file