class ProxmoxRb::Auth

Constants

Ticket

Public Class Methods

get_ticket(host, username, password) click to toggle source
# File lib/proxmox-rb/auth.rb, line 4
def self.get_ticket(host, username, password)
  retry_count = 0
  auth = nil
  begin
    auth = JSON.parse(RestClient.post 'https://' + host + ':8006/api2/json/access/ticket',
                      { username: username, password: password })
  rescue => e
    sleep_count += 1
    retry if sleep_count < 5
  end
  ticket = auth['data']['ticket']
  csrf = auth['data']['CSRFPreventionToken']
  tick = Ticket.new(host, ticket, csrf)
end