Sha256: 908790c3c8e5ffec5ddef50b2cf7397f4464ec34fd196b76a89fbb02e7db7191

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

require 'fog/core/model'

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
          service.groups.get(attributes['AutoScalingGroupName'])
        end

        def configuration
          service.configurations.get(attributes['LaunchConfigurationName'])
        end

        def set_health(health_status, options)
          requires :id
          service.set_instance_health(health_status, id, options)
          reload
        end

        def terminate(should_decrement_desired_capacity)
          requires :id
          service.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
        #  service.delete_auto_scaling_group(id)
        #end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/aws/models/auto_scaling/instance.rb
ns-fog-1.22.11 lib/fog/aws/models/auto_scaling/instance.rb
ns-fog-1.22.10 lib/fog/aws/models/auto_scaling/instance.rb
ns-fog-1.22.9 lib/fog/aws/models/auto_scaling/instance.rb
ns-fog-1.22.8 lib/fog/aws/models/auto_scaling/instance.rb
ns-fog-1.22.7 lib/fog/aws/models/auto_scaling/instance.rb
ns-fog-1.22.6 lib/fog/aws/models/auto_scaling/instance.rb
fog-1.23.0 lib/fog/aws/models/auto_scaling/instance.rb
ns-fog-1.22.4 lib/fog/aws/models/auto_scaling/instance.rb
ns-fog-1.22.3 lib/fog/aws/models/auto_scaling/instance.rb
ns-fog-1.22.2 lib/fog/aws/models/auto_scaling/instance.rb
fog-1.22.1 lib/fog/aws/models/auto_scaling/instance.rb