Methods
public instance
Public instance methods
disks
()
[show source]
# File lib/rudy/cli/disks.rb, line 7 7: def disks 8: disk_list = get_disks 9: # If there are no disks currently, there could be backups 10: # so we grab those to create a list of disks. 11: if @option.backups 12: backups = Rudy::Backups.list(more, less) || [] 13: backups.each_with_index do |b, index| 14: disk_list << b.disk 15: end 16: end 17: # We go through the list of disks but we'll skip ones we've seen 18: seen = [] 19: disk_list.each do |d| 20: next if seen.member?(d.name) 21: seen << d.name 22: print_stobject d 23: if @option.backups 24: d.backups.each_with_index do |b, index| 25: li ' %s' % b.name 26: ##break if @option.all.nil? && index >= 2 # display only 3, unless all 27: end 28: end 29: end 30: end
disks_create
()
[show source]
# File lib/rudy/cli/disks.rb, line 63 63: def disks_create 64: @mlist.each do |m| 65: li machine_separator(m.name, m.instid) 66: rbox = Rudy::Routines::Handlers::RyeTools.create_box m 67: rbox.stash = m 68: disk = Rudy::Disk.new m.position, @argv.first 69: disk.device = @option.device if @option.device 70: disk.size = @option.size if @option.size 71: disk.refresh! if disk.exists? # We need the volume ID if available 72: li "Creating disk: #{disk.name}" 73: volumes = m.attached_volumes 74: # don't include the current disk in the count. 75: volumes.reject! { |v| v.awsid == disk.volid } if disk.volid && disk.volume_attached? 76: disk_index = volumes.size + 2 77: Rudy::Routines::Handlers::Disks.create rbox, disk, disk_index 78: end 79: end
disks_create_valid?
()
[show source]
# File lib/rudy/cli/disks.rb, line 50 50: def disks_create_valid? 51: @mlist = Rudy::Machines.list 52: raise "No machines" if @mlist.nil? 53: 54: raise "No path provided" unless @argv.first 55: if !@@global.force && Rudy::Disks.exists?( @argv.first) 56: raise "Disk exists" if Rudy::Disks.get(@argv.first).volume_attached? 57: end 58: raise "No size provided" unless @option.size 59: 60: true 61: end
disks_destroy
()
[show source]
# File lib/rudy/cli/disks.rb, line 93 93: def disks_destroy 94: execute_check(:medium) 95: if !@mlist.empty? 96: @mlist.each do |m| 97: rbox = Rudy::Routines::Handlers::RyeTools.create_box m 98: rbox.stash = m 99: disk = Rudy::Disk.new m.position, @argv.first 100: li "Destroying disk: #{disk.name}" 101: Rudy::Routines::Handlers::Disks.destroy rbox, disk, 0 102: end 103: else 104: @dlist.each do |d| 105: li "Working on #{d.name}" 106: Rudy::Routines::Handlers::Disks.destroy nil, d, 0 107: end 108: end 109: end
disks_destroy_valid?
()
[show source]
# File lib/rudy/cli/disks.rb, line 81 81: def disks_destroy_valid? 82: @dlist = Rudy::Disks.list 83: raise "No disks" if @dlist.nil? 84: 85: @mlist = Rudy::Machines.list 86: raise "No machines" if @mlist.nil? && !@@global.force 87: 88: raise "No path provided" unless @argv.first 89: raise "Disk does not exist" unless Rudy::Disks.exists? @argv.first 90: true 91: end
disks_wash
()
[show source]
# File lib/rudy/cli/disks.rb, line 32 32: def disks_wash 33: dirt = (get_disks || []).select { |d| !d.volume_exists? } 34: if dirt.empty? 35: li "Nothing to wash in #{current_machine_group}" 36: return 37: end 38: 39: li "The following disk metadata will be deleted:" 40: li dirt.collect {|d| d.name } 41: 42: execute_check(:medium) 43: 44: dirt.each do |d| 45: d.destroy(:force) 46: end 47: 48: end