Class: ChefAB::TimeIPBasedUpgrader
- Inherits:
-
BaseUpgrader
- Object
- BaseUpgrader
- ChefAB::TimeIPBasedUpgrader
- Includes:
- IPmetric
- Defined in:
- lib/chef-ab/time_ipbased_upgrader.rb
Instance Attribute Summary collapse
-
#initial_ip ⇒ Object
Returns the value of attribute initial_ip.
-
#period ⇒ Object
Returns the value of attribute period.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Attributes inherited from BaseUpgrader
Instance Method Summary collapse
- #expected_activation ⇒ Object
-
#initialize(options) ⇒ TimeIPBasedUpgrader
constructor
A new instance of TimeIPBasedUpgrader.
- #should_execute?(time = nil) ⇒ Boolean
Methods included from IPmetric
Methods inherited from BaseUpgrader
Constructor Details
#initialize(options) ⇒ TimeIPBasedUpgrader
Returns a new instance of TimeIPBasedUpgrader.
11 12 13 14 15 16 17 |
# File 'lib/chef-ab/time_ipbased_upgrader.rb', line 11 def initialize() [:node_id] = ip_metric([:initial_ip], [:node_id]) super() @start_time = [:start_time].to_i @period = [:period] @end_time = 31 * @period + @start_time end |
Instance Attribute Details
#initial_ip ⇒ Object
Returns the value of attribute initial_ip.
9 10 11 |
# File 'lib/chef-ab/time_ipbased_upgrader.rb', line 9 def initial_ip @initial_ip end |
#period ⇒ Object
Returns the value of attribute period.
8 9 10 |
# File 'lib/chef-ab/time_ipbased_upgrader.rb', line 8 def period @period end |
#start_time ⇒ Object
Returns the value of attribute start_time.
8 9 10 |
# File 'lib/chef-ab/time_ipbased_upgrader.rb', line 8 def start_time @start_time end |
Instance Method Details
#expected_activation ⇒ Object
25 26 27 28 29 |
# File 'lib/chef-ab/time_ipbased_upgrader.rb', line 25 def expected_activation (@start_time..@end_time).to_a.bsearch do |fake_time| should_execute?(fake_time) end end |
#should_execute?(time = nil) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/chef-ab/time_ipbased_upgrader.rb', line 19 def should_execute?(time = nil) time ||= current_time threshold = (time - start_time) / @period + 1 super(threshold) end |