class Bosh::Cli::Command::Disks
Public Instance Methods
attach(job_name, id, disk_cid)
click to toggle source
# File lib/cli/commands/disks.rb, line 46 def attach(job_name, id, disk_cid) auth_required manifest = prepare_deployment_manifest status, result = director.attach_disk(manifest.name, job_name, id, disk_cid) task_report(status, result, "Attached disk #{disk_cid} to #{job_name}/#{id}") end
delete(orphan_disk_cid)
click to toggle source
# File lib/cli/commands/disks.rb, line 56 def delete(orphan_disk_cid) auth_required status, result = director.delete_orphan_disk_by_disk_cid(orphan_disk_cid) task_report(status, result, "Deleted orphaned disk #{orphan_disk_cid}") end
list()
click to toggle source
# File lib/cli/commands/disks.rb, line 6 def list auth_required unless options[:orphaned] err("Only 'bosh disks --orphaned' is supported") end disks = sort(director.list_orphan_disks) if disks.empty? nl say('No orphaned disks') nl return end disks_table = table do |table| table.headings = 'Disk CID', 'Size (MiB)', 'Deployment Name', 'Instance Name', 'AZ', 'Orphaned At' disks.each do |disk| table << [ disk['disk_cid'], disk['size'] || 'n/a', disk['deployment_name'], disk['instance_name'], disk['az'] || 'n/a', disk['orphaned_at'] ] end end nl say(disks_table) end
Private Instance Methods
sort(disks)
click to toggle source
# File lib/cli/commands/disks.rb, line 66 def sort(disks) disks.sort do |a, b| Time.parse(b['orphaned_at']).to_i <=> Time.parse(a['orphaned_at']).to_i end end