Class: Fission::Command::Info
- Inherits:
-
Fission::Command
- Object
- Fission::Command
- Fission::Command::Info
- Defined in:
- lib/fission/command/info.rb
Instance Attribute Summary
Attributes inherited from Fission::Command
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
#execute ⇒ Object
5 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 43 44 |
# File 'lib/fission/command/info.rb', line 5 def execute super incorrect_arguments unless @args.count == 1 vm = VM.new @args.first output "name: #{vm.name}" guest_os_response = vm.guestos if guest_os_response.successful? os = guest_os_response.data.empty? ? 'unknown' : guest_os_response.data output "os: #{os}" else output_and_exit "There was an error getting the OS info. The error was:\n#{guest_os_response.}", guest_os_response.code end hardware_response = vm.hardware_info if hardware_response.successful? hardware_response.data.each_pair do |k, v| output "#{k}: #{v}" end else output_and_exit "There was an error getting the hardware info. The error was:\n#{hardware_response.}", hardware_response.code end network_response = vm.network_info if network_response.successful? network_response.data.each_pair do |int, data| data.each_pair do |k, v| output "#{int} #{k.gsub(/[-_]/, ' ')}: #{v}" end output "" end else output_and_exit "There was an error getting the network info. The error was:\n#{network_response.}", network_response.code end end |
#option_parser ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/fission/command/info.rb', line 46 def option_parser optparse = OptionParser.new do |opts| opts. = 'Usage: fission info TARGET_VM' opts.separator '' opts.separator 'Lists known information about TARGET_VM' end optparse end |
#summary ⇒ Object
56 57 58 |
# File 'lib/fission/command/info.rb', line 56 def summary 'Show information for a VM' end |