knife-proxmox-ve 0.1.0 → 0.1.2
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/helpers/proxmox_vm_provision.rb +10 -7
- 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: bff2fdcc58a1aeadf186e297e838ddb91510536f7cf0169ccb25a3091c590931
|
|
4
|
+
data.tar.gz: 9cdc6b30bfe1a9d8da2feb3f8cf622973dbb0ab553c13c10a3a9729ea444a46a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 118d4dd196b869f226c11801b728b4d71661c9aa9756210b3857bf6f629c45515199a9b2e0b9b0f27b07bbf1cee995de81eaa1e1e8102a228d415eae7a94a460
|
|
7
|
+
data.tar.gz: b2b0d7b679086f772f7d844c22635c9a749110405362788ece0e7de99a23eec68a97c1e7e18ddfdad30500a5bfb606e8f8ed4b396a61faa9a32a0a1a4f2226ae
|
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.
|
|
@@ -13,9 +13,11 @@ class Chef
|
|
|
13
13
|
# cloud-init auth and plants it on the guest, but never touches the bootstrap connection.
|
|
14
14
|
# The bootstrap command layers that on by overriding #apply_provision_auth!.
|
|
15
15
|
module ProxmoxVmProvision
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
|
|
16
|
+
# A bridge is any Linux network interface: a classic bridge (vmbr0), an SDN VNet
|
|
17
|
+
# (arbitrary name, e.g. "mail"), an OVS bridge, a bond, etc. We only enforce what the
|
|
18
|
+
# kernel itself does on an interface name — 1..15 chars, no whitespace, no "/", and not
|
|
19
|
+
# "." or "..". IP/gateway validation is handled separately by IPAddr below.
|
|
20
|
+
BRIDGE_PATTERN = %r{\A(?!\.{1,2}\z)[^\s/]{1,15}\z}
|
|
19
21
|
|
|
20
22
|
# A pasted PRIVATE key must never travel as an authorized public key.
|
|
21
23
|
PRIVATE_KEY_MARKER = /-----BEGIN [A-Z ]*PRIVATE KEY-----/
|
|
@@ -73,8 +75,8 @@ class Chef
|
|
|
73
75
|
# --- Networking -------------------------------------------------------
|
|
74
76
|
|
|
75
77
|
option :bridge,
|
|
76
|
-
long: "--bridge
|
|
77
|
-
description: "Network bridge for net0 (e.g. vmbr0)."
|
|
78
|
+
long: "--bridge NAME",
|
|
79
|
+
description: "Network bridge for net0 (e.g. vmbr0 or an SDN VNet name)."
|
|
78
80
|
|
|
79
81
|
option :vlan,
|
|
80
82
|
long: "--vlan TAG",
|
|
@@ -193,9 +195,10 @@ class Chef
|
|
|
193
195
|
def validate_bridge!
|
|
194
196
|
bridge = config[:bridge]
|
|
195
197
|
return if bridge.nil?
|
|
196
|
-
return if
|
|
198
|
+
return if BRIDGE_PATTERN.match?(bridge)
|
|
197
199
|
|
|
198
|
-
ui.fatal!("--bridge #{bridge.inspect} is not a valid
|
|
200
|
+
ui.fatal!("--bridge #{bridge.inspect} is not a valid interface name " \
|
|
201
|
+
"(1-15 chars, no whitespace or '/'; e.g. vmbr0 or an SDN VNet name)")
|
|
199
202
|
end
|
|
200
203
|
|
|
201
204
|
def validate_ip!
|
|
@@ -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.2
|
|
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: []
|