class Awful::EMR

Constants

COLORS

Public Instance Methods

color(string) click to toggle source
# File lib/awful/emr.rb, line 21
def color(string)
  set_color(string, COLORS.fetch(string.to_sym, :yellow))
end
dump(id) click to toggle source
# File lib/awful/emr.rb, line 42
def dump(id)
  emr.describe_cluster(cluster_id: id).cluster.output do |cluster|
    puts YAML.dump(stringify_keys(cluster.to_hash))
  end
end
emr() click to toggle source
# File lib/awful/emr.rb, line 17
def emr
  @emr ||= Aws::EMR::Client.new
end
instances(id) click to toggle source
# File lib/awful/emr.rb, line 51
def instances(id)
  emr.list_instances(cluster_id: id, instance_group_types: options[:group].map(&:upcase)).instances.output do |instances|
    if options[:long]
      print_table instances.map { |i|
        [i.ec2_instance_id, i.instance_group_id, color(i.status.state), i.instance_type, i.public_ip_address, i.private_ip_address, i.status.timeline.creation_date_time]
      }
    else
      puts instances.map(&:ec2_instance_id)
    end
  end
end
ls() click to toggle source
# File lib/awful/emr.rb, line 29
def ls
  emr.list_clusters(cluster_states: options[:states].map(&:upcase)).clusters.output do |clusters|
    if options[:long]
      print_table clusters.map { |c|
        [c.name, c.id, color(c.status.state), c.status.timeline.creation_date_time, "#{c.normalized_instance_hours}h"]
      }
    else
      puts clusters.map(&:name)
    end
  end
end