lib/poolparty/poolparty/poolparty_base_class.rb
# Add resource
# When we are looking to add a resource, we want to make sure the
# resources isn't already added. This way we prevent duplicates 
# as puppet can be finicky about duplicate resource definitions. 
# We'll look for the resource in either a local or global store
# If the resource appears in either, return that resource, we'll just append
# to the resource config, otherwise instantiate a new resource of the type
# and store it into the global and local resource stores
# 
# A word about stores, the global store stores the entire list of stored
# resources. The local resource store is available on all clouds and plugins
# which stores the instance variable's local resources. 
Add resource
When we are looking to add a resource, we want to make sure the
resources isn't already added. This way we prevent duplicates
as puppet can be finicky about duplicate resource definitions.
We'll look for the resource in either a local or global store
If the resource appears in either, return that resource, we'll just append
to the resource config, otherwise instantiate a new resource of the type
and store it into the global and local resource stores

A word about stores, the global store stores the entire list of stored
resources. The local resource store is available on all clouds and plugins
which stores the instance variable's local resources.
Add resource When we are looking to add a resource we want to make sure the resources isn ' t already added . This way we prevent duplicates as puppet can be finicky about duplicate resource definitions . We ' ll look for the resource in either a local or global store If the resource appears in either return that resource we ' ll just append to the resource config otherwise instantiate a new resource of the type and store it into the global and local resource stores A word about stores the global store stores the entire list of stored resources . The local resource store is available on all clouds and plugins which stores the instance variable ' s local resources .
def add_resource(ty, opts={}, extra_opts={}, &block)    
      temp_name = get_name_from_options_and_extra_options(opts, extra_opts)
      if res = get_resource(ty, temp_name, opts)        
        res
      else
        opts = (opts.is_a?(Hash) ? extra_opts.merge(opts) : extra_opts).merge(:name => temp_name)
        res = if PoolParty::Resources::Resource.available_resources.include?(ty.to_s.camelize)
          "PoolParty::Resources::#{ty.to_s.camelize}".camelize.constantize.new(opts, &block)
        else
          "#{ty.to_s.camelize}".camelize.constantize.new(opts.merge(:name), &block)
        end
        res.after_create
        store_in_local_resources(ty, res)
        ordered_resources << res
        res
      end
    end
def add_resource ( ty , opts = { } , extra_opts = { } , & block ) temp_name = get_name_from_options_and_extra_options ( opts , extra_opts ) if res = get_resource ( ty , temp_name , opts ) res else opts = ( opts . is_a? ( Hash ) ? extra_opts . merge ( opts ) : extra_opts ) . merge ( :name => temp_name ) res = if PoolParty :: Resources :: Resource . available_resources . include? ( ty . to_s . camelize ) "PoolParty::Resources::#{ty.to_s.camelize}" . camelize . constantize . new ( opts , & block ) else "#{ty.to_s.camelize}" . camelize . constantize . new ( opts . merge ( :name ) , & block ) end res . after_create store_in_local_resources ( ty , res ) ordered_resources << res res end end
Add resource
When we are looking to add a resource, we want to make sure the
resources isn't already added.
Add resource When we are looking to add a resource we want to make sure the resources isn ' t already added .
# opts.merge!(:name => temp_name) unless opts.has_key?(:name)
ty
opts
extra_opts
block