class NeptuneApex::Cli::Main

Public Instance Methods

datalog() click to toggle source
# File lib/neptune_apex/cli/main.rb, line 36
def datalog
  puts "Not yet implemented"
end
status() click to toggle source
# File lib/neptune_apex/cli/main.rb, line 11
def status
  cont = create_controller
  status = cont.status

  puts "Apex status as of #{status.date.strftime('%F %R')}"

  puts Terminal::Table.new :headings => ['Probe', 'Value'] {|t|
    status.probes.each{|name, probe|
      t << [name, probe[:value].to_s('F')]
    }
  }

  puts "\n"

  puts Terminal::Table.new :headings => ['Outlet', 'State'] {|t|
    status.outlets.each{|name, outlet|
      t << [name, outlet[:state]]
    }
  }

end

Private Instance Methods

create_controller() click to toggle source

Look for a config file & load

# File lib/neptune_apex/cli/main.rb, line 47
def create_controller
  conf_file = File.expand_path('~/.apexcli')

  if ENV['APEXCONF']
    conf_file = ENV['APEXCONF']
  end

  if File.exist?(conf_file)
    controller = NeptuneApex::Controller.new()
    conf = YAML.load_file(conf_file)
    controller.url = conf['url']
    controller.user = conf['user']
    controller.password = conf['password']
    return controller
  else
    raise Exception.new('Config file not found!')
  end
end