Class: ILO_SDK::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/ilo-sdk/cli.rb

Overview

cli for ilo-sdk

Defined Under Namespace

Classes: Runner

Instance Method Summary collapse

Instance Method Details

#consoleObject


92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/ilo-sdk/cli.rb', line 92

def console
  client_setup({}, true, true)
  puts "Connected to #{@client.host}"
  puts "HINT: The @client object is available to you\n\n"
rescue
  puts "WARNING: Couldn't connect to #{@options['host'] || ENV['ILO_HOST'] || 'nil (host not set)'}\n\n"
ensure
  require 'pry'
  Pry.config.prompt = proc { '> ' }
  Pry.plugins['stack_explorer'] && Pry.plugins['stack_explorer'].disable!
  Pry.plugins['byebug'] && Pry.plugins['byebug'].disable!
  Pry.start(ILO_SDK::Console.new(@client))
end

#envObject


78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ilo-sdk/cli.rb', line 78

def env
  data = {}
  ILO_SDK::ENV_VARS.each { |k| data[k] = ENV[k] }
  if @options['format'] == 'human'
    data.each do |key, value|
      value = "'#{value}'" if value && ! %w(true false).include?(value)
      printf "%-#{data.keys.max_by(&:length).length}s = %s\n", key, value || 'nil'
    end
  else
    output(parse_hash(data, true))
  end
end

#loginObject


117
118
119
120
121
# File 'lib/ilo-sdk/cli.rb', line 117

def 
  client_setup
  @client.response_handler(@client.rest_get('/redfish/v1/Sessions/'))
  puts 'Login Successful!'
end

#versionObject


107
108
109
110
111
112
113
114
# File 'lib/ilo-sdk/cli.rb', line 107

def version
  puts "Gem Version: #{ILO_SDK::VERSION}"
  client_setup({ 'log_level' => :error }, true)
  ver = @client.response_handler(@client.rest_get('/redfish/v1/'))['RedfishVersion']
  puts "iLO Redfish API version: #{ver}"
rescue StandardError, SystemExit
  puts 'iLO API version unknown'
end