Parent

Class/Module Index [+]

Quicksearch

Ironfan::Broker::Computers

Attributes

cluster[RW]

Public Class Methods

new(*args) click to toggle source
# File lib/ironfan/broker/computer.rb, line 282
def initialize(*args)
  super
  options = args.pop or return
  self.cluster = options[:cluster]
  create_expected!
end

Public Instance Methods

aggregate() click to toggle source
# File lib/ironfan/broker/computer.rb, line 313
def aggregate
  group_action(:aggregate!)
end
build_slice_array(slice_indexes) click to toggle source
# File lib/ironfan/broker/computer.rb, line 378
def build_slice_array(slice_indexes)
  return [] if slice_indexes.nil?
  raise "Bad slice_indexes: #{slice_indexes}" if slice_indexes =~ /[^0-9\.,]/
  eval("[#{slice_indexes}]").map {|idx| idx.class == Range ? idx.to_a : idx}.flatten
end
correlate() click to toggle source

Discovery

# File lib/ironfan/broker/computer.rb, line 292
def correlate
  values.each{|c| c.correlate }
end
create_expected!() click to toggle source

set up new computers for each server in the cluster definition

# File lib/ironfan/broker/computer.rb, line 345
def create_expected!
  self.cluster.servers.each do |server|
    self << Computer.new(:server => server)
  end unless self.cluster.nil?
end
empty_copy() click to toggle source
# File lib/ironfan/broker/computer.rb, line 358
def empty_copy
  result          = self.class.new
  result.cluster  = self.cluster unless self.cluster.nil?
  result
end
environments() click to toggle source
# File lib/ironfan/broker/computer.rb, line 336
def environments
  map{|comp| comp.environment }.uniq
end
group_action(verb) click to toggle source
# File lib/ironfan/broker/computer.rb, line 302
def group_action(verb)
  computers = self
  provider_keys = values.map {|c| c.chosen_providers({ :providers => :iaas })}.flatten.uniq
  providers     = provider_keys.map { |pk| values.map { |c| c.providers[pk] } }.flatten.compact.uniq
  providers.each { |p| p.send(verb, computers) }
end
joined_names() click to toggle source

provide a human-readable list of names

# File lib/ironfan/broker/computer.rb, line 385
def joined_names
  values.map(&:name).join(", ").gsub(/, ([^,]*)$/, ' and \1')
end
kill(options={}) click to toggle source

Manipulation

# File lib/ironfan/broker/computer.rb, line 320
def kill(options={})
  Ironfan.parallel(values) {|c| c.kill(options) }
end
launch() click to toggle source
# File lib/ironfan/broker/computer.rb, line 323
def launch
  Ironfan.parallel(values) {|c| c.launch }
end
prepare() click to toggle source
# File lib/ironfan/broker/computer.rb, line 309
def prepare
  group_action(:prepare!)
end
save(options={}) click to toggle source
# File lib/ironfan/broker/computer.rb, line 326
def save(options={})
  Ironfan.parallel(values) {|c| c.save(options) }
end
select(&block) click to toggle source

Return the selection inside another Computers collection

# File lib/ironfan/broker/computer.rb, line 352
def select(&block)
  result = empty_copy
  values.select(&block).each{|m| result << m}
  result
end
slice(facet_name=nil, slice_indexes=nil) click to toggle source

Find all selected computers, as well as any bogus computers from discovery

# File lib/ironfan/broker/computer.rb, line 365
def slice(facet_name=nil, slice_indexes=nil)
  return self if (facet_name.nil? and slice_indexes.nil?)
  result          = empty_copy
  slice_array     = build_slice_array(slice_indexes)
  each do |m|
    result << m if (m.bogus? or (                 # bogus computer or
      ( m.server.facet_name == facet_name ) and   # facet match and
        ( slice_array.include? m.server.index or  #   index match or
          slice_indexes.nil? ) ) )                #   no indexes specified
  end
  result
end
start() click to toggle source
# File lib/ironfan/broker/computer.rb, line 329
def start
  Ironfan.parallel(values) {|c| c.start }
end
stop() click to toggle source
# File lib/ironfan/broker/computer.rb, line 332
def stop
  Ironfan.parallel(values) {|c| c.stop }
end
to_s() click to toggle source
# File lib/ironfan/broker/computer.rb, line 389
def to_s
  "#{self.class}[#{values.map(&:name).join(",")}]"
end
validate() click to toggle source
# File lib/ironfan/broker/computer.rb, line 296
def validate
  computers = self
  values.each{|c|    c.validate }
  values.map {|c| c.providers.values}.flatten.uniq.each {|p| p.validate computers }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.