knife-proxmox-ve 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 +0 -24
- data/README.md +3 -1
- data/lib/chef/knife/helpers/proxmox_base.rb +36 -0
- data/lib/chef/knife/proxmox_template_list.rb +11 -0
- data/lib/chef/knife/proxmox_vm_list.rb +10 -0
- data/lib/knife-proxmox-ve/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2bfa352b40db68621f19322cdb1dfc060c37ac3faafa423d37b76c9ccd7d544f
|
|
4
|
+
data.tar.gz: 1f819e5625acbb197012847d54d15e6bace8b71108d3ad867b9fbb2ee0b8944e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e185dc631d2d81abdfa6a0e5e1a3772bc66b8db9096f1fc4a358aa910b52c549f8a3c3b1bde159509b7b7dcc8decbc1433fbc10e56731428b69ce764d1162ea1
|
|
7
|
+
data.tar.gz: 26bf397b78eb7e03f832e506ff34ca026e370c416fb5ec2f1a7c2e4428c915229f851a68e404cec34ceb801f1fd8ee9790bdaec0673480e15f53405d45661453
|
data/CHANGELOG.md
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project are documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [Unreleased]
|
|
9
|
-
|
|
10
|
-
## [0.1.0] - 2026-06-04
|
|
11
|
-
|
|
12
|
-
### Added
|
|
13
|
-
|
|
14
|
-
- `knife proxmox vm create` — create a VM on Proxmox VE by cloning a prepared
|
|
15
|
-
template and configuring CPU/RAM/network/cloud-init.
|
|
16
|
-
- `knife proxmox vm bootstrap` — create a VM and automatically bootstrap it with
|
|
17
|
-
Chef/CINC in a single command, waiting for the VM to boot first.
|
|
18
|
-
- Read-only helpers: `knife proxmox cluster list`, `knife proxmox template list`
|
|
19
|
-
and `knife proxmox vm list`.
|
|
20
|
-
- Support for multiple Proxmox clusters defined in `~/.cinc/config.rb`.
|
|
21
|
-
- Authentication via Proxmox VE API tokens.
|
|
22
|
-
|
|
23
|
-
[Unreleased]: https://github.com/pwojcieszonek/knife-proxmox-ve/compare/v0.1.0...HEAD
|
|
24
|
-
[0.1.0]: https://github.com/pwojcieszonek/knife-proxmox-ve/releases/tag/v0.1.0
|
data/README.md
CHANGED
|
@@ -202,7 +202,9 @@ Lists the qemu templates on the selected cluster (name, VMID, node, disk, memory
|
|
|
202
202
|
Lists the cluster's qemu VMs (name, VMID, node, status, memory, uptime). `--node` filters
|
|
203
203
|
client-side.
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
Disk, memory and uptime are rendered human-readable (e.g. `10 GiB`, `1h`) in the default
|
|
206
|
+
table output. All read commands honour `--format json|yaml` for scripting, where these fields
|
|
207
|
+
stay raw (bytes / seconds).
|
|
206
208
|
|
|
207
209
|
## Development
|
|
208
210
|
|
|
@@ -53,6 +53,42 @@ class Chef
|
|
|
53
53
|
ui.info("#{ui.color(label, color)}: #{value}") if value && !value.to_s.empty?
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
+
# Binary byte units, lowest first. Proxmox reports sizes in bytes against a 1024 base,
|
|
57
|
+
# so render in IEC units (KiB, MiB, ...) to match the values shown in the Proxmox UI.
|
|
58
|
+
BYTE_UNITS = %w{B KiB MiB GiB TiB PiB}.freeze
|
|
59
|
+
|
|
60
|
+
# Render a byte count as a human-readable IEC size (e.g. 10_737_418_240 -> "10 GiB").
|
|
61
|
+
# Passes nil through untouched so absent fields (a template has no live size) stay nil
|
|
62
|
+
# rather than becoming a misleading "0 B".
|
|
63
|
+
def human_bytes(value)
|
|
64
|
+
return value if value.nil?
|
|
65
|
+
|
|
66
|
+
size = value.to_f
|
|
67
|
+
unit = 0
|
|
68
|
+
while size >= 1024 && unit < BYTE_UNITS.length - 1
|
|
69
|
+
size /= 1024
|
|
70
|
+
unit += 1
|
|
71
|
+
end
|
|
72
|
+
format("%g %s", size.round(2), BYTE_UNITS[unit])
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Render a second count as a compact duration (e.g. 3600 -> "1h", 90_061 -> "1d 1h 1m 1s").
|
|
76
|
+
# nil passes through (a stopped/template VM reports no uptime); 0 renders as "0s".
|
|
77
|
+
def human_duration(seconds)
|
|
78
|
+
return seconds if seconds.nil?
|
|
79
|
+
|
|
80
|
+
days, rest = seconds.to_i.divmod(86_400)
|
|
81
|
+
hours, rest = rest.divmod(3_600)
|
|
82
|
+
minutes, secs = rest.divmod(60)
|
|
83
|
+
|
|
84
|
+
parts = []
|
|
85
|
+
parts << "#{days}d" if days > 0
|
|
86
|
+
parts << "#{hours}h" if hours > 0
|
|
87
|
+
parts << "#{minutes}m" if minutes > 0
|
|
88
|
+
parts << "#{secs}s" if secs > 0 || parts.empty?
|
|
89
|
+
parts.join(" ")
|
|
90
|
+
end
|
|
91
|
+
|
|
56
92
|
# Whether a token secret resolves for the given cluster (symbol-keyed hash), using the
|
|
57
93
|
# same precedence as #resolve_token_secret but without fatal-ing. Lets `cluster list`
|
|
58
94
|
# report secret presence from a single source of truth.
|
|
@@ -37,8 +37,19 @@ class Chef
|
|
|
37
37
|
}
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
# Keep raw numbers for json/yaml (scripting); humanize only the rendered table.
|
|
41
|
+
rows = rows.map { |row| humanize(row) } unless ui.interchange?
|
|
40
42
|
ui.output(format_for_display(rows))
|
|
41
43
|
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def humanize(row)
|
|
48
|
+
row.merge(
|
|
49
|
+
maxdisk: human_bytes(row[:maxdisk]),
|
|
50
|
+
maxmem: human_bytes(row[:maxmem])
|
|
51
|
+
)
|
|
52
|
+
end
|
|
42
53
|
end
|
|
43
54
|
end
|
|
44
55
|
end
|
|
@@ -33,6 +33,8 @@ class Chef
|
|
|
33
33
|
|
|
34
34
|
rows = proxmox_api.list_resources(template: false)
|
|
35
35
|
rows = filter_by_node(rows)
|
|
36
|
+
# Keep raw numbers for json/yaml (scripting); humanize only the rendered table.
|
|
37
|
+
rows = rows.map { |row| humanize(row) } unless ui.interchange?
|
|
36
38
|
ui.output(format_for_display(rows))
|
|
37
39
|
end
|
|
38
40
|
|
|
@@ -44,6 +46,14 @@ class Chef
|
|
|
44
46
|
|
|
45
47
|
rows.select { |row| row[:node] == node }
|
|
46
48
|
end
|
|
49
|
+
|
|
50
|
+
def humanize(row)
|
|
51
|
+
row.merge(
|
|
52
|
+
maxmem: human_bytes(row[:maxmem]),
|
|
53
|
+
maxdisk: human_bytes(row[:maxdisk]),
|
|
54
|
+
uptime: human_duration(row[:uptime])
|
|
55
|
+
)
|
|
56
|
+
end
|
|
47
57
|
end
|
|
48
58
|
end
|
|
49
59
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: knife-proxmox-ve
|
|
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
|
- Piotr Wojcieszonek
|
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
77
77
|
- !ruby/object:Gem::Version
|
|
78
78
|
version: '0'
|
|
79
79
|
requirements: []
|
|
80
|
-
rubygems_version:
|
|
80
|
+
rubygems_version: 4.0.10
|
|
81
81
|
specification_version: 4
|
|
82
82
|
summary: Knife plugin to create and automatically bootstrap Proxmox VE VMs with Chef/CINC.
|
|
83
83
|
test_files: []
|