Parent

Class/Module Index [+]

Quicksearch

Ironfan::Dsl::Compute

Public Class Methods

new(attrs={},&block) click to toggle source
# File lib/ironfan/dsl/compute.rb, line 30
def initialize(attrs={},&block)
  self.underlay   = attrs[:owner] if attrs[:owner]
  super
end

Public Instance Methods

cloud(provider=nil) click to toggle source
# File lib/ironfan/deprecated.rb, line 16
def cloud(provider=nil)
  if provider.nil?
    Ironfan.deprecated 'cloud(nil)','use cloud(:ec2) instead'
    provider = :ec2
  end
  super(provider)
end
ec2(*attrs,&block) click to toggle source
# File lib/ironfan/dsl/ec2.rb, line 7
def ec2(*attrs,&block)            cloud(:ec2,*attrs,&block);      end
full_name() click to toggle source
# File lib/ironfan/dsl/compute.rb, line 35
def full_name()   name;   end
raid_group(rg_name, attrs={}, &block) click to toggle source
# File lib/ironfan/dsl/compute.rb, line 54
def raid_group(rg_name, attrs={}, &block)
  raid = volumes[rg_name] || Ironfan::Dsl::RaidGroup.new(:name => rg_name)
  raid.receive!(attrs, &block)
  raid.sub_volumes.each do |sv_name|
    volume(sv_name){ in_raid(rg_name) ; mountable(false) ; tags({}) }
  end
  volumes[rg_name] = raid
end
recipe(recipe_name, placement=nil) click to toggle source
# File lib/ironfan/dsl/compute.rb, line 43
def recipe(recipe_name, placement=nil)
  add_to_run_list(recipe_name, placement)
end
role(role_name, placement=nil) click to toggle source

Add the given role/recipe to the run list. You can specify placement of

`:first`, `:normal` (or nil) or `:last`; the final runlist is assembled
in order by placement, and then by source position.
# File lib/ironfan/dsl/compute.rb, line 40
def role(role_name, placement=nil)
  add_to_run_list("role[#{role_name}]", placement)
end
run_list() click to toggle source
# File lib/ironfan/dsl/compute.rb, line 46
def run_list
  mapper = run_list_items.values.map
  result =  mapper.each {|i| i[:name] if i[:placement]==:first  }
  result += mapper.each {|i| i[:name] if i[:placement]==:normal }
  result += mapper.each {|i| i[:name] if i[:placement]==:last   }
  result.compact
end
selected_cloud() click to toggle source

TODO: Expand the logic here to include CLI parameters, probably by injecting

the CLI as a layer in the underlay structure
# File lib/ironfan/dsl/compute.rb, line 65
def selected_cloud
  raise "No clouds defined, cannot select a cloud" if clouds.length == 0

  # Use the selected cloud for this server
  unless use_cloud.nil?
    return cloud(use_cloud) if clouds.include? use_cloud
    raise "Requested a cloud (#{use_cloud}) that is not defined"
  end

  # Use the cloud marked default_cloud
  default = clouds.values.select{|c| c.default_cloud == true }
  raise "More than one cloud (#{default.map{|c| c.name}.join(', ')}) marked default" if default.length > 1
  return default[0] unless default.empty?

  # Use the first cloud defined
  clouds.values.first
end

Protected Instance Methods

add_to_run_list(item, placement=nil) click to toggle source
# File lib/ironfan/dsl/compute.rb, line 85
def add_to_run_list(item, placement=nil)
  raise "run_list placement must be one of :first, :normal, :last or nil (also means :normal)" unless [:first, :last, :own, nil].include?(placement)
  placement = :normal if placement.nil?
  @@run_list_rank += 1
  run_list_items[item] = { :name => item, :rank => @@run_list_rank, :placement => placement }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.