Class: Fission::Command::Status

Inherits:
Fission::Command show all
Defined in:
lib/fission/command/status.rb

Instance Attribute Summary

Attributes inherited from Fission::Command

#args, #options

Instance Method Summary collapse

Methods inherited from Fission::Command

#command_name, help, #initialize, #ui

Methods included from Fission::CommandHelpers

#incorrect_arguments, #parse_arguments

Constructor Details

This class inherits a constructor from Fission::Command

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fission/command/status.rb', line 5

def execute
  super

  response = VM.all_with_status
  unless response.successful?
    output_and_exit "There was an error getting the status of the VMs.  The error was:\n#{response.message}", response.code
  end

  vms_status = response.data
  longest_vm_name = vms_status.keys.max { |a,b| a.length <=> b.length }

  vms_status.each_pair do |vm_name, status|
    output_printf "%-#{longest_vm_name.length}s   [%s]\n", vm_name, status
  end
end

#option_parserObject



21
22
23
24
25
26
27
28
29
# File 'lib/fission/command/status.rb', line 21

def option_parser
  optparse = OptionParser.new do |opts|
    opts.banner = "Usage: fission status"
    opts.separator ''
    opts.separator 'Lists the status for all known VMs.'
  end

  optparse
end

#summaryObject



31
32
33
# File 'lib/fission/command/status.rb', line 31

def summary
  'Show the status of all VMs'
end