Module: PoolParty::CloudResourcer
- Included in:
- PoolParty::Cloud::Cloud, Plugin::Plugin, Pool::Pool, Remote::Metavirt
- Defined in:
- lib/poolparty/modules/cloud_resourcer.rb
Instance Method Summary collapse
- #dependency_resolver(name = nil) ⇒ Object
-
#instances(arg) ⇒ Object
Set instances with a range or a number if passed with a hash, call nodes(hash) to return filtered list of instances.
- #plugin_directory(arr = []) ⇒ Object
-
#run_stored_block ⇒ Object
This will run the blocks after they are stored if there is a block associated.
-
#store_block(&block) ⇒ Object
Store block.
- #stored_block ⇒ Object
-
#using(t, o = {}, &block) ⇒ Object
Declare the remoter base Check to make sure the available_bases is available, otherwise raise Give access to the cloud the remote_base and instantiate a new instance of the remote base.
Instance Method Details
#dependency_resolver(name = nil) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 81 def dependency_resolver(name=nil) if !name.nil? ext = name=~/Resolver$/ ? nil : 'Resolver' klass = ::PoolParty.module_eval("#{name.camelcase}#{ext}") raise DependencyResolverException.new("Unknown resolver") unless klass [:dependency_resolver] = "#{name.camelcase}#{ext}" @dependency_resolver = klass else @dependency_resolver end end |
#instances(arg) ⇒ Object
Set instances with a range or a number if passed with a hash, call nodes(hash) to return filtered list of instances
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 43 def instances(arg) case arg when Range minimum_instances arg.first maximum_instances arg.last when Fixnum minimum_instances arg maximum_instances arg when Hash nodes(arg) else raise SpecException.new("Don't know how to handle instances cloud input #{arg}") end end |
#plugin_directory(arr = []) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 14 def plugin_directory(arr=[]) arr = [arr] if arr.is_a?(String) arr << [ "#{::File.(Dir.pwd)}/plugins", "#{::File.(Default.poolparty_home_path)}/plugins" ] arr.flatten.each {|arg| Dir["#{arg}/*/*.rb"].each {|f| require f } if ::File.directory?(arg) } end |
#run_stored_block ⇒ Object
This will run the blocks after they are stored if there is a block associated
36 37 38 |
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 36 def run_stored_block self.run_in_context @stored_block if @stored_block end |
#store_block(&block) ⇒ Object
Store block
26 27 28 |
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 26 def store_block(&block) @stored_block ||= block ? block : nil end |
#stored_block ⇒ Object
30 31 32 |
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 30 def stored_block @stored_block end |
#using(t, o = {}, &block) ⇒ Object
Declare the remoter base Check to make sure the available_bases is available, otherwise raise Give access to the cloud the remote_base and instantiate a new instance of the remote base
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 62 def using(t, o={}, &block) return self.send(t) if self.respond_to?(t) klass_string = "::PoolParty::Remote::#{t.to_s.camelcase}" remote_base_klass = klass_string.constantize if ::PoolParty::Remote.available.include?(remote_base_klass) (remote_base_klass.) @remote_base = remote_base_klass.send(:new, o.merge(:cloud=>self), &block) self.remoter_base t.to_sym instance_eval "def #{t};@remote_base;end" # instance_eval "def launch_new_instance!(o={}); remote_base.launch_new_instance!;end" # instance_eval "def terminate_instance!(o={}); remote_base.terminate_instance!(o);end" # instance_eval "def describe_instances(o={}); remote_base.describe_instances;end" # instance_eval "def describe_instance(o={}); remote_base.describe_instance(o);end" else raise "Unknown remote base: #{t}" end end |