2011-06-12 16:07:42 -04:00
|
|
|
require 'fog/core/model'
|
2011-06-21 17:15:33 -04:00
|
|
|
|
2011-06-12 16:07:42 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class AutoScaling
|
|
|
|
class Instance < Fog::Model
|
|
|
|
|
|
|
|
identity :id, :aliases => 'InstanceId'
|
|
|
|
attribute :auto_scaling_group_name, :aliases => 'AutoScalingGroupName'
|
|
|
|
attribute :availability_zone, :aliases => 'AvailabilityZone'
|
|
|
|
attribute :health_status, :aliases => 'HealthStatus'
|
|
|
|
attribute :launch_configuration_name, :aliases => 'LaunchConfigurationName'
|
|
|
|
attribute :life_cycle_state, :aliases => 'LifecycleState'
|
|
|
|
|
|
|
|
def initialize(attributes={})
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def group
|
|
|
|
connection.groups.get(attributes['AutoScalingGroupName'])
|
|
|
|
end
|
|
|
|
|
|
|
|
def configuration
|
|
|
|
connection.configurations.get(attributes['LaunchConfigurationName'])
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_health(health_status, options)
|
|
|
|
requires :id
|
|
|
|
connection.set_instance_health(health_status, id, options)
|
|
|
|
reload
|
|
|
|
end
|
|
|
|
|
|
|
|
def terminate(should_decrement_desired_capacity)
|
|
|
|
requires :id
|
|
|
|
connection.terminate_instance_in_auto_scaling_group(id, should_decrement_desired_capacity)
|
|
|
|
reload
|
|
|
|
end
|
|
|
|
|
|
|
|
def healthy?
|
|
|
|
health_status == 'HEALTHY'
|
|
|
|
end
|
|
|
|
|
|
|
|
def ready?
|
|
|
|
life_cycle_state == 'InService'
|
|
|
|
end
|
|
|
|
|
|
|
|
def reload
|
|
|
|
super
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
#def destroy
|
|
|
|
# requires :id
|
|
|
|
# connection.delete_auto_scaling_group(id)
|
|
|
|
#end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|