Module: Proxmox
- Defined in:
- lib/pve/proxmox.rb
Defined Under Namespace
Modules: RestConnection
Classes: AlreadyExists, AplInfo, Base, Exception, HA, Hosted, LXC, Node, NotFound, Qemu, Storage, Task
Class Method Summary
collapse
Class Method Details
.api_ticket ⇒ Object
45
46
47
|
# File 'lib/pve/proxmox.rb', line 45
def self.api_ticket
@@api_ticket
end
|
.connect(username, password, realm: nil, verify_tls: nil, uri: nil) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/pve/proxmox.rb', line 16
def self.connect username, password, realm: nil, verify_tls: nil, uri: nil
uri ||= 'https://localhost:8006/api2/json'
cred =
{
username: username,
password: password,
realm: realm || 'pve'
}
@@connection =
RestClient::Resource.new( uri, verify_ssl: ! ! verify_tls).tap do |rs|
resp = rs['/access/ticket'].post cred
case resp.code
when 200
data = JSON.parse resp.body, symbolize_names: true
@@api_ticket =
{
CSRFPreventionToken: data[:data][:CSRFPreventionToken],
cookie: "PVEAuthCookie=#{CGI.escape data[:data][:ticket]}"
}
else
raise Exception, "Authentication failed"
end
end
end
|
.connection ⇒ Object
41
42
43
|
# File 'lib/pve/proxmox.rb', line 41
def self.connection
@@connection
end
|
.find(name_or_id) ⇒ Object
.find_by_name(name) ⇒ Object
.find_by_vmid(vmid) ⇒ Object