Class: Cumulus::AutoScaling::ScheduledConfig
- Inherits:
-
Object
- Object
- Cumulus::AutoScaling::ScheduledConfig
- Defined in:
- lib/autoscaling/models/ScheduledConfig.rb
Overview
Public: A class representing the configuration for a scheduled scaling action
Instance Attribute Summary collapse
-
#desired ⇒ Object
Returns the value of attribute desired.
-
#end ⇒ Object
Returns the value of attribute end.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#name ⇒ Object
Returns the value of attribute name.
-
#recurrence ⇒ Object
Returns the value of attribute recurrence.
-
#start ⇒ Object
Returns the value of attribute start.
Instance Method Summary collapse
-
#diff(aws) ⇒ Object
Public: Produce the differences between this local configuration and the configuration in AWS.
-
#hash ⇒ Object
Public: Get the configuration as a hash.
-
#initialize(json = nil) ⇒ ScheduledConfig
constructor
Public: Constructor.
-
#populate(resource) ⇒ Object
Public: Populate the ScheduledConfig from an existing AWS resource.
Constructor Details
#initialize(json = nil) ⇒ ScheduledConfig
Public: Constructor
json - a hash representing the JSON configuration for this action
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 18 def initialize(json = nil) if !json.nil? @name = json["name"] if !json["start"].nil? and json["start"] != "" @start = Time.parse(json["start"]) end if !json["end"].nil? and json["end"] != "" @end = Time.parse(json["end"]) end @recurrence = json["recurrence"] @min = json["min"] @max = json["max"] @desired = json["desired"] end end |
Instance Attribute Details
#desired ⇒ Object
Returns the value of attribute desired.
7 8 9 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 7 def desired @desired end |
#end ⇒ Object
Returns the value of attribute end.
8 9 10 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 8 def end @end end |
#max ⇒ Object
Returns the value of attribute max.
9 10 11 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 9 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
10 11 12 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 10 def min @min end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 11 def name @name end |
#recurrence ⇒ Object
Returns the value of attribute recurrence.
12 13 14 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 12 def recurrence @recurrence end |
#start ⇒ Object
Returns the value of attribute start.
13 14 15 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 13 def start @start end |
Instance Method Details
#diff(aws) ⇒ Object
Public: Produce the differences between this local configuration and the configuration in AWS
aws - the scheduled action in AWS
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 53 def diff(aws) diffs = [] # we check if start is nil, cause even in the case that it is nil, aws # will still give the scheduled action a start time on creation. This is # annoying, because it will make it seem as if start time is always changed. if @start != aws.start_time and !@start.nil? diffs << ScheduledActionDiff.new(ScheduledActionChange::START, aws, self) end if @end != aws.end_time diffs << ScheduledActionDiff.new(ScheduledActionChange::ENDTIME, aws, self) end if @recurrence != aws.recurrence diffs << ScheduledActionDiff.new(ScheduledActionChange::RECURRENCE, aws, self) end if @min != aws.min_size diffs << ScheduledActionDiff.new(ScheduledActionChange::MIN, aws, self) end if @max != aws.max_size diffs << ScheduledActionDiff.new(ScheduledActionChange::MAX, aws, self) end if @desired != aws.desired_capacity diffs << ScheduledActionDiff.new(ScheduledActionChange::DESIRED, aws, self) end diffs end |
#hash ⇒ Object
Public: Get the configuration as a hash
Returns the hash
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 37 def hash { "desired" => @desired, "end" => @end, "max" => @max, "min" => @min, "name" => @name, "recurrence" => @recurrence, "start" => @start }.reject { |k, v| v.nil? } end |
#populate(resource) ⇒ Object
Public: Populate the ScheduledConfig from an existing AWS resource
resource - the aws resource to populate from
84 85 86 87 88 89 90 91 92 |
# File 'lib/autoscaling/models/ScheduledConfig.rb', line 84 def populate(resource) @desired = resource.desired_capacity @end = resource.end_time @max = resource.max_size @min = resource.min_size @name = resource.scheduled_action_name @recurrence = resource.recurrence @start = resource.start_time end |