class Awful::Ami
Constants
- COLORS
Public Instance Methods
color(string)
click to toggle source
# File lib/awful/ami.rb, line 32 def color(string) set_color(string, COLORS.fetch(string.to_sym, :yellow)) end
delete(id)
click to toggle source
# File lib/awful/ami.rb, line 52 def delete(id) ami = images(id).first if yes? "Really deregister image #{ami.name} (#{ami.image_id})?", :yellow ec2.deregister_image(image_id: ami.image_id) end end
dump(*ids)
click to toggle source
# File lib/awful/ami.rb, line 60 def dump(*ids) images(*ids).output do |images| images.each do |image| puts YAML.dump(stringify_keys(image.to_hash)) end end end
images(*image_ids)
click to toggle source
# File lib/awful/ami.rb, line 19 def images(*image_ids) params = { image_ids: Array(image_ids), owners: options[:owners], filters: options[:filters].map do |tag| k, v = tag.split('=') {name: k, values: v.split(',')} end }.reject { |k,v| v.empty? } ec2.describe_images(params).images end
last(name = /./)
click to toggle source
# File lib/awful/ami.rb, line 99 def last(name = /./) images.select do |image| image.name.match(name) end.sort_by(&:creation_date).last(options[:count]).map do |image| image.image_id end.output do |list| puts list end end
ls(*ids)
click to toggle source
# File lib/awful/ami.rb, line 39 def ls(*ids) images(*ids).output do |list| if options[:long] print_table list.map { |i| [ i.name, i.image_id, i.root_device_type, color(i.state), i.creation_date, i.tags.map{ |t| "#{t.key}=#{t.value}" }.sort.join(',') ] }.sort else puts list.map(&:name).sort end end end