Class: ProxmoxRb::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/proxmox-rb/auth.rb

Defined Under Namespace

Classes: Ticket

Class Method Summary collapse

Class Method Details

.get_ticket(host, username, password) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/proxmox-rb/auth.rb', line 4

def self.get_ticket(host, username, password)
  auth = nil
  begin
    auth = JSON.parse(RestClient.post 'https://' + host + ':8006/api2/json/access/ticket',
                      { username: username, password: password })
  rescue => e
    puts "#{e}"
    sleep 1
    retry
  end
  ticket = auth['data']['ticket']
  csrf = auth['data']['CSRFPreventionToken']
  tick = Ticket.new(host, ticket, csrf)
end