proxmox-sdk 0.1.2 → 0.1.4
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/lib/proxmox/client.rb +15 -1
- data/lib/proxmox/resources/cluster.rb +5 -2
- data/lib/proxmox/resources/node.rb +30 -2
- data/lib/proxmox/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7c0b67d16c5998e774ca622ca64f157b586080e958323c97d10225595a3372f
|
|
4
|
+
data.tar.gz: c2ced47a6a4c274adf06a69b728b2c5c175b964696d7f2984927376502390c2c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5157b2839030a07102344ff43188e6f4b54bcb2c631016bce6d373c45ebda9519447a4f80a6446bdf1e81d40e68b8c1129bd2208db19676221c566a4b846cec
|
|
7
|
+
data.tar.gz: fa53ebc0acac4c23b3cda3d6a4687bf8bbb67740ef32da50e4fd1e5c2626371daf5dab7aaf09b3000ce91416ad361ebf325d4b8a94644bfc80c524f861991cdc
|
data/lib/proxmox/client.rb
CHANGED
|
@@ -28,6 +28,20 @@ module Proxmox
|
|
|
28
28
|
login
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
def cluster
|
|
32
|
+
@cluster ||= Proxmox::Resources::Cluster.new(self)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def node(name)
|
|
36
|
+
Proxmox::Resources::Node.new(self, name)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def nodes
|
|
40
|
+
request(:get, "/nodes").map do |node_data|
|
|
41
|
+
Proxmox::Resources::Node.new(self, node_data)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
31
45
|
def login
|
|
32
46
|
resp = http.post("/api2/json/access/ticket",
|
|
33
47
|
{ username: "#{@username}@#{@realm}", password: @password })
|
|
@@ -99,7 +113,7 @@ module Proxmox
|
|
|
99
113
|
end
|
|
100
114
|
|
|
101
115
|
def set_body(req, body)
|
|
102
|
-
req.body = body
|
|
116
|
+
req.body = body if body
|
|
103
117
|
end
|
|
104
118
|
|
|
105
119
|
def ensure_success!(response)
|
|
@@ -8,6 +8,10 @@ module Proxmox
|
|
|
8
8
|
@client = client
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
def inspect
|
|
12
|
+
"#<Proxmox::Resources::Cluster client_url=#{@client.base_url}>"
|
|
13
|
+
end
|
|
14
|
+
|
|
11
15
|
def log(max: nil)
|
|
12
16
|
params = {}
|
|
13
17
|
params[:max] = max unless max.nil?
|
|
@@ -38,9 +42,8 @@ module Proxmox
|
|
|
38
42
|
@client.request(:get, "/cluster/tasks")
|
|
39
43
|
end
|
|
40
44
|
|
|
41
|
-
# Getting all Nodes
|
|
42
45
|
def nodes
|
|
43
|
-
@client.
|
|
46
|
+
@client.nodes
|
|
44
47
|
end
|
|
45
48
|
end
|
|
46
49
|
end
|
|
@@ -4,9 +4,37 @@ module Proxmox
|
|
|
4
4
|
module Resources
|
|
5
5
|
# Proxmox Node Class
|
|
6
6
|
class Node
|
|
7
|
-
|
|
7
|
+
# Define the attributes we expect from the API
|
|
8
|
+
STATS_ATTRIBUTES = %i[id cpu maxcpu mem maxmem uptime].freeze
|
|
9
|
+
attr_reader :node, *STATS_ATTRIBUTES
|
|
10
|
+
alias name node
|
|
11
|
+
|
|
12
|
+
def initialize(client, name_or_data)
|
|
8
13
|
@client = client
|
|
9
|
-
|
|
14
|
+
if name_or_data.is_a?(Hash)
|
|
15
|
+
@node = name_or_data["node"]
|
|
16
|
+
@raw_status = name_or_data["status"]
|
|
17
|
+
|
|
18
|
+
# Dynamically set known attributes to avoid boilerplate
|
|
19
|
+
STATS_ATTRIBUTES.each do |attr|
|
|
20
|
+
instance_variable_set("@#{attr}", name_or_data[attr.to_s])
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
@node = name_or_data
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def inspect
|
|
28
|
+
"#<Proxmox::Resources::Node name=#{@node} status=#{@raw_status}>"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def online?
|
|
32
|
+
@raw_status == "online"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Access the Cluster resource
|
|
36
|
+
def cluster
|
|
37
|
+
@client.cluster
|
|
10
38
|
end
|
|
11
39
|
|
|
12
40
|
# Getting status of the Node
|
data/lib/proxmox/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Wellnitz
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -51,7 +50,6 @@ metadata:
|
|
|
51
50
|
homepage_uri: https://github.com/alexohneander/proxmox-sdk-ruby
|
|
52
51
|
source_code_uri: https://github.com/alexohneander/proxmox-sdk-ruby
|
|
53
52
|
changelog_uri: https://raw.githubusercontent.com/alexohneander/proxmox-sdk-ruby/refs/heads/main/CHANGELOG.md
|
|
54
|
-
post_install_message:
|
|
55
53
|
rdoc_options: []
|
|
56
54
|
require_paths:
|
|
57
55
|
- lib
|
|
@@ -66,8 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
66
64
|
- !ruby/object:Gem::Version
|
|
67
65
|
version: '0'
|
|
68
66
|
requirements: []
|
|
69
|
-
rubygems_version:
|
|
70
|
-
signing_key:
|
|
67
|
+
rubygems_version: 4.0.10
|
|
71
68
|
specification_version: 4
|
|
72
69
|
summary: A gem that provides a client interface for Proxmox
|
|
73
70
|
test_files: []
|