Class: Bosh::Cli::Command::Disks

Inherits:
Base show all
Defined in:
lib/cli/commands/disks.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_DIRECTOR_PORT

Instance Attribute Summary

Attributes inherited from Base

#args, #exit_code, #info, #options, #out, #runner, #work_dir

Instance Method Summary collapse

Methods inherited from Base

#add_option, #blob_manager, #blobstore, #cache_dir, #config, #confirmed?, #credentials, #deployment, #director, #initialize, #interactive?, #logged_in?, #non_interactive?, #progress_renderer, #redirect, #release, #remove_option, #run_nested_command, #show_current_state, #target, #target_name, #verbose?

Methods included from Bosh::Cli::CommandDiscovery

#desc, #method_added, #option, #register_command, #usage

Methods included from DeploymentHelper

#build_manifest, #cancel_deployment, #deployment_changed?, #inspect_deployment_changes, #job_exists_in_deployment?, #job_unique_in_deployment?, #jobs_and_indexes, #prepare_deployment_manifest, #prompt_for_errand_name, #prompt_for_job_and_index

Constructor Details

This class inherits a constructor from Bosh::Cli::Command::Base

Instance Method Details

#attach(job_name, id, disk_cid) ⇒ Object


46
47
48
49
50
51
52
# 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) ⇒ Object


56
57
58
59
60
61
62
# 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

#listObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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