Class: Bosh::Cli::Command::Vms
- Includes:
- DeploymentHelper
- Defined in:
- lib/cli/commands/vms.rb
Constant Summary
Constants inherited from Base
Base::BLOBS_DIR, Base::BLOBS_INDEX_FILE
Instance Attribute Summary
Attributes inherited from Base
#cache, #config, #options, #out, #usage, #work_dir
Instance Method Summary collapse
Methods included from DeploymentHelper
#deployment_changed?, #inspect_deployment_changes, #prepare_deployment_manifest
Methods inherited from Base
#blob_manager, #blobstore, command, #confirmed?, #director, #dry_run?, #exit_code, #full_target_name, #initialize, #interactive?, #logged_in?, #non_interactive?, #redirect, #release, #run, #show_usage, #target_name, #target_version, #task_report, #verbose?
Constructor Details
This class inherits a constructor from Bosh::Cli::Command::Base
Instance Method Details
#list(*args) ⇒ Object
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 43 44 45 46 47 48 49 50 |
# File 'lib/cli/commands/vms.rb', line 7 def list(*args) auth_required show_full_stats = !args.delete("--full").nil? name = args.first if name.nil? deployment_required manifest = prepare_deployment_manifest name = manifest["name"] end say("Deployment #{name.green}") vms = director.fetch_vm_state(name) err("No VMs") if vms.size == 0 sorted = vms.sort do |a, b| s = a["job_name"].to_s <=> b["job_name"].to_s s = a["index"].to_i <=> b["index"].to_i if s == 0 s = a["resource_pool"].to_s <=> b["resource_pool"].to_s if s == 0 s end vms_table = table do |t| headings = ["Job/index", "State", "Resource Pool", "IPs"] headings += ["CID", "Agent ID"] if show_full_stats t.headings = headings sorted.each do |vm| job = "#{vm["job_name"]}/#{vm["index"]}" if vm["job_name"] row = [job, vm["job_state"], vm["resource_pool"], Array(vm["ips"]).join(", ")] row += [vm["vm_cid"], vm["agent_id"]] if show_full_stats t << row end end say("\n") say(vms_table) say("\n") say("VMs total: %d" % vms.size) end |