proxmox-sdk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -0
- data/lib/proxmox/client.rb +41 -8
- data/lib/proxmox/resources/cluster.rb +47 -0
- data/lib/proxmox/resources/clusters/acme.rb +18 -0
- data/lib/proxmox/resources/node.rb +7 -0
- data/lib/proxmox/version.rb +1 -1
- data/lib/proxmox.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18becda6b3edf4aba2a1146a3f889e618c9c49ad9d476f45197b63bae0930f5e
|
4
|
+
data.tar.gz: bc2b3f12e06eb9ef9941acf1035a81bdad3be29627fbdec33ee520e374ddb221
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aa011f0cb9ea2ca0694a095e549a410f572cd96325d3cf4886bc1a9ba80536e8d4f64ea9005bdf9836368c2b8a5c823e8d28cc81da77601958a96cd27132865
|
7
|
+
data.tar.gz: 3628b92158ebb7288bdd9f231e9db71eb180789df6e36fc7faa69d744b41bcde25535efc90bec9f0b48c1c959a5d9f0811a9aa54850a4a83ab75af6c4016ccb5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Proxmox
|
2
2
|
|
3
|
+
A lightweight Ruby gem that provides a clean, idiomatic interface to the Proxmox VE REST API. It handles authentication, token management, and all common API endpoints (nodes, virtual machines, storage, containers, etc.) so you can focus on building automation, orchestration, or custom tooling without dealing with raw HTTP calls.
|
3
4
|
|
4
5
|
## Installation
|
5
6
|
|
data/lib/proxmox/client.rb
CHANGED
@@ -22,21 +22,54 @@ module Proxmox
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def request(method, path, params = {}, body = nil)
|
25
|
-
response =
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
response = perform_http_call(method, path, params, body)
|
26
|
+
|
27
|
+
ensure_success!(response)
|
28
|
+
extract_data(response)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def perform_http_call(method, path, params, body)
|
34
|
+
http.send(method) do |req|
|
35
|
+
set_url(req, path)
|
36
|
+
add_cookie_header(req)
|
37
|
+
set_csrf_header(req, method)
|
38
|
+
set_query_params(req, method, params)
|
39
|
+
set_body(req, body)
|
31
40
|
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def set_url(req, path)
|
44
|
+
req.url "/api2/json#{path}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_cookie_header(req)
|
48
|
+
req.headers["Cookie"] = "PVEAuthCookie=#{ticket}"
|
49
|
+
end
|
32
50
|
|
51
|
+
def set_csrf_header(req, method)
|
52
|
+
return unless %i[post put delete].include?(method)
|
53
|
+
|
54
|
+
req.headers["CSRFPreventionToken"] = csrf_token
|
55
|
+
end
|
56
|
+
|
57
|
+
def set_query_params(req, method, params)
|
58
|
+
req.params.update(params) if method == :get && params.any?
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_body(req, body)
|
62
|
+
req.body = body.to_json if body
|
63
|
+
end
|
64
|
+
|
65
|
+
def ensure_success!(response)
|
33
66
|
raise ApiError, response.body unless response.success?
|
67
|
+
end
|
34
68
|
|
69
|
+
def extract_data(response)
|
35
70
|
JSON.parse(response.body)["data"]
|
36
71
|
end
|
37
72
|
|
38
|
-
private
|
39
|
-
|
40
73
|
def http
|
41
74
|
@http ||= Faraday.new(url: @base_url, ssl: { verify: @verify_ssl }) do |f|
|
42
75
|
f.request :url_encoded
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Proxmox
|
4
|
+
module Resources
|
5
|
+
# Proxmox Cluster Class
|
6
|
+
class Cluster
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
end
|
10
|
+
|
11
|
+
def log(max: nil)
|
12
|
+
params = {}
|
13
|
+
params[:max] = max unless max.nil?
|
14
|
+
|
15
|
+
@client.request(:get, "/cluster/log", params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def nextid(vmid: nil)
|
19
|
+
params = {}
|
20
|
+
params[:vmid] = vmid unless vmid.nil?
|
21
|
+
|
22
|
+
@client.request(:get, "/cluster/nextid", params)
|
23
|
+
end
|
24
|
+
|
25
|
+
def options
|
26
|
+
@client.request(:get, "/cluster/options")
|
27
|
+
end
|
28
|
+
|
29
|
+
def resources
|
30
|
+
@client.request(:get, "/cluster/resources")
|
31
|
+
end
|
32
|
+
|
33
|
+
def status
|
34
|
+
@client.request(:get, "/cluster/status")
|
35
|
+
end
|
36
|
+
|
37
|
+
def tasks
|
38
|
+
@client.request(:get, "/cluster/tasks")
|
39
|
+
end
|
40
|
+
|
41
|
+
# Getting all Nodes
|
42
|
+
def nodes
|
43
|
+
@client.request(:get, "/nodes")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Proxmox
|
4
|
+
module Resources
|
5
|
+
module Clusters
|
6
|
+
# Proxmox Cluster Acme class
|
7
|
+
class Acme
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
def tos
|
13
|
+
@client.request(:get, "/cluster/acme/tos")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -9,10 +9,17 @@ module Proxmox
|
|
9
9
|
@node = node_name
|
10
10
|
end
|
11
11
|
|
12
|
+
# Getting status of the Node
|
12
13
|
def status
|
13
14
|
@client.request(:get, "/nodes/#{@node}/status")
|
14
15
|
end
|
15
16
|
|
17
|
+
# Getting a list of updates for the Node
|
18
|
+
def updates
|
19
|
+
@client.request(:get, "/nodes/#{@node}/apt/update")
|
20
|
+
end
|
21
|
+
|
22
|
+
# Creating Resources
|
16
23
|
def create_vm(params)
|
17
24
|
@client.request(:post, "/nodes/#{@node}/qemu", {}, params)
|
18
25
|
end
|
data/lib/proxmox/version.rb
CHANGED
data/lib/proxmox.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxmox-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Wellnitz
|
@@ -36,6 +36,8 @@ files:
|
|
36
36
|
- Rakefile
|
37
37
|
- lib/proxmox.rb
|
38
38
|
- lib/proxmox/client.rb
|
39
|
+
- lib/proxmox/resources/cluster.rb
|
40
|
+
- lib/proxmox/resources/clusters/acme.rb
|
39
41
|
- lib/proxmox/resources/node.rb
|
40
42
|
- lib/proxmox/version.rb
|
41
43
|
- sig/proxmox.rbs
|