2012-06-15 11:10:04 -07:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class AutoScaling
|
|
|
|
class Policy < Fog::Model
|
|
|
|
identity :id, :aliases => 'PolicyName'
|
|
|
|
attribute :arn, :aliases => 'PolicyARN'
|
|
|
|
attribute :adjustment_type, :aliases => 'AdjustmentType'
|
|
|
|
attribute :alarms, :aliases => 'Alarms'
|
|
|
|
attribute :auto_scaling_group_name, :aliases => 'AutoScalingGroupName'
|
|
|
|
attribute :cooldown, :aliases => 'Cooldown'
|
|
|
|
attribute :min_adjustment_step, :aliases => 'MinAdjustmentStep'
|
|
|
|
attribute :scaling_adjustment, :aliases => 'ScalingAdjustment'
|
|
|
|
|
|
|
|
def initialize(attributes)
|
2012-06-17 09:47:07 -07:00
|
|
|
attributes['AdjustmentType'] ||= 'ChangeInCapacity'
|
|
|
|
attributes['ScalingAdjustment'] ||= 1
|
2012-06-15 11:10:04 -07:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
# TODO: implement #alarms
|
|
|
|
# TODO: implement #auto_scaling_group
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :id
|
|
|
|
requires :adjustment_type
|
|
|
|
requires :auto_scaling_group_name
|
|
|
|
requires :scaling_adjustment
|
|
|
|
|
|
|
|
options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
|
|
|
|
options.delete_if { |key, value| value.nil? }
|
|
|
|
|
2012-12-22 23:32:30 +00:00
|
|
|
service.put_scaling_policy(adjustment_type, auto_scaling_group_name, id, scaling_adjustment, options)
|
2012-06-15 11:10:04 -07:00
|
|
|
reload
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
requires :auto_scaling_group_name
|
2012-12-22 23:32:30 +00:00
|
|
|
service.delete_policy(auto_scaling_group_name, id)
|
2012-06-15 11:10:04 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|