lib/testlab/node.rb in testlab-1.21.1 vs lib/testlab/node.rb in testlab-1.22.0

- old
+ new

@@ -42,11 +42,17 @@ attribute :provider attribute :provisioners, :default => Array.new attribute :config, :default => Hash.new + # Execution priority; set the order in which the object should execute when + # performing parallel operations; a higher value priority equates to more + # precedence. Objects with identical priority values will execute in + # parallel. + attribute :priority, :default => 0 + def initialize(*args) @ui = TestLab.ui @ui.logger.debug { "Loading Node" } @@ -70,9 +76,21 @@ end def domain self.config[:bind] ||= Hash.new self.config[:bind][:domain] ||= 'tld.invalid' + end + + class << self + + def priority_groups + self.all.map(&:priority).sort.uniq.reverse + end + + def by_priority(priority) + self.all.select{ |n| n.priority == priority } + end + end end end