Module: PoolParty

Extended by:
PoolParty
Included in:
PoolParty, Master, RemoteInstance, Remoting
Defined in:
lib/modules/callback.rb,
lib/poolparty.rb,
lib/poolparty/tasks.rb,
lib/poolparty/master.rb,
lib/poolparty/plugin.rb,
lib/poolparty/remoter.rb,
lib/poolparty/monitors.rb,
lib/poolparty/optioner.rb,
lib/poolparty/provider.rb,
lib/poolparty/remoting.rb,
lib/modules/ec2_wrapper.rb,
lib/modules/file_writer.rb,
lib/poolparty/scheduler.rb,
lib/modules/safe_instance.rb,
lib/poolparty/application.rb,
lib/poolparty/thread_pool.rb,
lib/poolparty/remote_instance.rb,
lib/helpers/plugin_spec_helper.rb

Overview

Application

This handles user interaction

Defined Under Namespace

Modules: Callbacks, Ec2Wrapper, FileWriter, Monitors, Remoter, Scheduler, ThreadSafeInstance Classes: Application, EC2ResponseObject, Master, Optioner, Plugin, PluginSpecHelper, Provider, RemoteInstance, Remoting, ScheduleTasks, Tasks, ThreadPool, Version

Instance Method Summary collapse

Instance Method Details

#include_cloud_tasksObject Also known as: tasks, include_tasks



125
126
127
# File 'lib/poolparty.rb', line 125

def include_cloud_tasks
  Tasks.new.define_tasks
end

#load_appObject



102
103
104
105
# File 'lib/poolparty.rb', line 102

def load_app
  load_monitors
  load_plugins
end

#load_monitorsObject



106
107
108
109
# File 'lib/poolparty.rb', line 106

def load_monitors
  loc = File.directory?("#{user_dir}/monitors") ? "#{user_dir}/monitors" : "#{root_dir}/lib/poolparty/monitors"
  Dir["#{loc}/*"].each {|f| require f}
end

#load_pluginsObject



111
112
113
# File 'lib/poolparty.rb', line 111

def load_plugins
  Dir["#{plugin_dir}/**/init.rb"].each {|a| require a} if File.directory?(plugin_dir)
end

#message(msg = "") ⇒ Object

Send a message if we are in verbose-mode



69
70
71
# File 'lib/poolparty.rb', line 69

def message(msg="")
  puts "-- #{msg}" if verbose?
end

#options(opts = {}) ⇒ Object

PoolParty options



61
62
63
# File 'lib/poolparty.rb', line 61

def options(opts={})
  Application.options(opts)
end

#plugin_dirObject



118
119
120
# File 'lib/poolparty.rb', line 118

def plugin_dir
  "#{user_dir}/plugins"
end

#read_config_file(filename) ⇒ Object



121
122
123
124
# File 'lib/poolparty.rb', line 121

def read_config_file(filename)
  return {} unless filename
  YAML.load(open(filename).read)
end

#register_monitor(*names) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/poolparty.rb', line 87

def register_monitor(*names)
  names.each do |name|
    unless registered_monitor?(name)
      PoolParty::Monitors.extend name
    
      PoolParty::Master.send :include, name::Master
      PoolParty::RemoteInstance.send :include, name::Remote
      
      registered_monitors << name
    end
  end
end

#registered_monitor?(name) ⇒ Boolean

Returns:

  • (Boolean)


99
# File 'lib/poolparty.rb', line 99

def registered_monitor?(name); registered_monitors.include?(name); end

#registered_monitorsObject



100
# File 'lib/poolparty.rb', line 100

def registered_monitors; @@registered_monitors ||= [];end

#reset!Object



114
115
116
117
# File 'lib/poolparty.rb', line 114

def reset!
  @@registered_monitors = nil
  @@installed_plugins = nil
end

#root_dirObject

Root directory of the application



73
74
75
# File 'lib/poolparty.rb', line 73

def root_dir
  File.expand_path(File.dirname(__FILE__) + "/..")
end

#timerObject



57
58
59
# File 'lib/poolparty.rb', line 57

def timer
  @@timer
end

#user_dirObject

User directory



77
78
79
# File 'lib/poolparty.rb', line 77

def user_dir
  Application.working_directory
end

#verbose?Boolean

Are we working in verbose-mode

Returns:

  • (Boolean)


65
66
67
# File 'lib/poolparty.rb', line 65

def verbose?
  options.verbose == true
end

#write_to_temp_file(str = "") ⇒ Object

Write string to a tempfile



81
82
83
84
85
86
# File 'lib/poolparty.rb', line 81

def write_to_temp_file(str="")
  tempfile = Tempfile.new("rand#{rand(1000)}-#{rand(1000)}")
  tempfile.print(str)
  tempfile.flush
  tempfile
end