Class: ChefAB::TimeLinearUpgrader

Inherits:
BaseUpgrader show all
Defined in:
lib/chef-ab/time_linear_upgrader.rb

Instance Attribute Summary collapse

Attributes inherited from BaseUpgrader

#hash, #node_id

Instance Method Summary collapse

Methods inherited from BaseUpgrader

#execute

Constructor Details

#initialize(options) ⇒ TimeLinearUpgrader

Returns a new instance of TimeLinearUpgrader.



8
9
10
11
12
13
14
# File 'lib/chef-ab/time_linear_upgrader.rb', line 8

def initialize(options)
  super(options)
  @start_time = options[:start_time].to_i
  @end_time = options[:end_time].to_i
  upgrade_span = @end_time - @start_time
  @hash = @hash % upgrade_span
end

Instance Attribute Details

#end_timeObject

Returns the value of attribute end_time.



6
7
8
# File 'lib/chef-ab/time_linear_upgrader.rb', line 6

def end_time
  @end_time
end

#start_timeObject

Returns the value of attribute start_time.



6
7
8
# File 'lib/chef-ab/time_linear_upgrader.rb', line 6

def start_time
  @start_time
end

Instance Method Details

#expected_activationObject



22
23
24
25
26
# File 'lib/chef-ab/time_linear_upgrader.rb', line 22

def expected_activation
  (@start_time..@end_time).to_a.bsearch do |fake_time|
    should_execute?(fake_time)
  end
end

#should_execute?(time = nil) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/chef-ab/time_linear_upgrader.rb', line 16

def should_execute?(time = nil)
  time ||= current_time
  threshold    = time - start_time
  super(threshold)
end