Class: Elasticity::ClusterStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticity/cluster_status.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cluster_idObject

Returns the value of attribute cluster_id.



6
7
8
# File 'lib/elasticity/cluster_status.rb', line 6

def cluster_id
  @cluster_id
end

#created_atObject

Returns the value of attribute created_at.



8
9
10
# File 'lib/elasticity/cluster_status.rb', line 8

def created_at
  @created_at
end

#ended_atObject

Returns the value of attribute ended_at.



10
11
12
# File 'lib/elasticity/cluster_status.rb', line 10

def ended_at
  @ended_at
end

#last_state_change_reasonObject

Returns the value of attribute last_state_change_reason.



11
12
13
# File 'lib/elasticity/cluster_status.rb', line 11

def last_state_change_reason
  @last_state_change_reason
end

#master_public_dns_nameObject

Returns the value of attribute master_public_dns_name.



12
13
14
# File 'lib/elasticity/cluster_status.rb', line 12

def master_public_dns_name
  @master_public_dns_name
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/elasticity/cluster_status.rb', line 5

def name
  @name
end

#normalized_instance_hoursObject

Returns the value of attribute normalized_instance_hours.



13
14
15
# File 'lib/elasticity/cluster_status.rb', line 13

def normalized_instance_hours
  @normalized_instance_hours
end

#ready_atObject

Returns the value of attribute ready_at.



9
10
11
# File 'lib/elasticity/cluster_status.rb', line 9

def ready_at
  @ready_at
end

#stateObject

Returns the value of attribute state.



7
8
9
# File 'lib/elasticity/cluster_status.rb', line 7

def state
  @state
end

Class Method Details

.from_aws_data(cluster_data) ⇒ Object

ClusterStatus is created via the results of the DescribeCluster API call



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/elasticity/cluster_status.rb', line 16

def self.from_aws_data(cluster_data)
  cluster_data = cluster_data['Cluster']
  ClusterStatus.new.tap do |c|
    c.name = cluster_data['Name']
    c.cluster_id = cluster_data['Id']
    c.state = cluster_data['Status']['State']
    c.created_at = Time.at(cluster_data['Status']['Timeline']['CreationDateTime'])
    c.ready_at = cluster_data['Status']['Timeline']['ReadyDateTime'] ? Time.at(cluster_data['Status']['Timeline']['ReadyDateTime']) : nil
    c.ended_at = cluster_data['Status']['Timeline']['EndDateTime'] ? Time.at(cluster_data['Status']['Timeline']['EndDateTime']) : nil
    c.last_state_change_reason = cluster_data['Status']['StateChangeReason']['Code']
    c.master_public_dns_name = cluster_data['MasterPublicDnsName']
    c.normalized_instance_hours = cluster_data['NormalizedInstanceHours']
  end
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/elasticity/cluster_status.rb', line 32

def active?
  %w{RUNNING STARTING BOOTSTRAPPING WAITING SHUTTING_DOWN}.include?(@state)
end