Class: OpsWorks::Instance

Inherits:
Resource show all
Defined in:
lib/opsworks/instance.rb

Constant Summary collapse

FATAL_STATUSES =
%w(
  connection_lost setup_failed start_failed stop_failed
).freeze
SETTLED_STATUSES =
(
  FATAL_STATUSES + %w(online stopped terminated)
).freeze

Instance Attribute Summary collapse

Attributes inherited from Resource

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

account, #initialize

Constructor Details

This class inherits a constructor from OpsWorks::Resource

Instance Attribute Details

#ec2_instance_idObject

Returns the value of attribute ec2_instance_id.



3
4
5
# File 'lib/opsworks/instance.rb', line 3

def ec2_instance_id
  @ec2_instance_id
end

#hostnameObject

Returns the value of attribute hostname.



3
4
5
# File 'lib/opsworks/instance.rb', line 3

def hostname
  @hostname
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/opsworks/instance.rb', line 3

def id
  @id
end

#instance_typeObject

Returns the value of attribute instance_type.



3
4
5
# File 'lib/opsworks/instance.rb', line 3

def instance_type
  @instance_type
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/opsworks/instance.rb', line 3

def status
  @status
end

Class Method Details

.from_collection_response(client, response) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/opsworks/instance.rb', line 13

def self.from_collection_response(client, response)
  response.data[:instances].map do |hash|
    new(
      client,
      id: hash[:instance_id],
      hostname: hash[:hostname],
      ec2_instance_id: hash[:ec2_instance_id],
      instance_type: hash[:instance_type],
      status: hash[:status]
    )
  end
end

Instance Method Details

#fatal?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/opsworks/instance.rb', line 34

def fatal?
  FATAL_STATUSES.include?(status)
end

#online?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/opsworks/instance.rb', line 26

def online?
  status == 'online'
end

#settled?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/opsworks/instance.rb', line 38

def settled?
  SETTLED_STATUSES.include?(status)
end

#setup_failed?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/opsworks/instance.rb', line 30

def setup_failed?
  status == 'setup_failed'
end