pxinv 0.3.0__tar.gz

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.
pxinv-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,272 @@
1
+ Metadata-Version: 2.4
2
+ Name: pxinv
3
+ Version: 0.3.0
4
+ Summary: Proxmox VM & container inventory CLI
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/yourusername/pxinv
7
+ Project-URL: Issues, https://github.com/yourusername/pxinv/issues
8
+ Keywords: proxmox,homelab,cli,inventory,devops
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: System Administrators
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: System :: Systems Administration
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: click>=8.0
22
+ Requires-Dist: proxmoxer>=2.0
23
+ Requires-Dist: requests>=2.28
24
+ Requires-Dist: rich>=13.0
25
+ Requires-Dist: pyyaml>=6.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Requires-Dist: ruff>=0.4; extra == "dev"
29
+ Requires-Dist: pip-audit>=2.0; extra == "dev"
30
+
31
+ # pxinv
32
+
33
+ [![CI](https://github.com/thetechiejourney/pxinv/actions/workflows/ci.yml/badge.svg)](https://github.com/thetechiejourney/pxinv/actions/workflows/ci.yml)
34
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
35
+
36
+ A fast CLI for inventorying and managing VMs and containers on your Proxmox homelab.
37
+
38
+ ```
39
+ $ pxinv list
40
+
41
+ VMID NAME NODE TYPE STATUS CPU RAM DISK UPTIME TAGS
42
+ ──────────────────────────────────────────────────────────────────────────────────────────────────────
43
+ 100 homeassistant pve-01 VM running 5.2% 1.0GB/4.0GB 10.0GB/32.0GB 3d homelab
44
+ 101 pihole pve-01 CT running 0.8% 128.0MB/512.0MB 1.0GB/8.0GB 14d dns
45
+ 200 talos-cp-01 pve-02 VM stopped — —/8.0GB —/64.0GB — k8s
46
+
47
+ 3 resource(s) — 2 running, 1 stopped
48
+ ```
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ pip install pxinv
54
+ ```
55
+
56
+ Or install from source:
57
+
58
+ ```bash
59
+ git clone https://github.com/thetechiejourney/pxinv
60
+ cd pxinv
61
+ pip install -e .
62
+ ```
63
+
64
+ ## Authentication
65
+
66
+ `pxinv` uses Proxmox API tokens (recommended over username/password).
67
+
68
+ **Create a token in Proxmox:**
69
+ 1. Go to Datacenter → Permissions → API Tokens
70
+ 2. Add a token for your user (e.g. `root@pam`, token name: `pxinv`)
71
+ 3. Copy the token value — it's only shown once
72
+
73
+ **Required permissions:** `VM.Audit` and `Sys.Audit` on `/` (or per-node).
74
+
75
+ ## Configuration
76
+
77
+ Credentials can be provided in three ways (in order of precedence):
78
+
79
+ ### 1. CLI flags
80
+ ```bash
81
+ pxinv --host 192.168.1.10 --token-name pxinv --token-value <secret> list
82
+ ```
83
+
84
+ ### 2. Environment variables
85
+ ```bash
86
+ export PXINV_HOST=192.168.1.10
87
+ export PXINV_TOKEN_NAME=pxinv
88
+ export PXINV_TOKEN_VALUE=<secret>
89
+ export PXINV_VERIFY_SSL=false # optional, for self-signed certs
90
+
91
+ pxinv list
92
+ ```
93
+
94
+ ### 3. Config file
95
+
96
+ `~/.config/pxinv/config.yaml`:
97
+ ```yaml
98
+ host: 192.168.1.10
99
+ user: root@pam
100
+ token_name: pxinv
101
+ token_value: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
102
+ verify_ssl: false
103
+ ```
104
+
105
+ ## Commands
106
+
107
+ ### `pxinv list`
108
+
109
+ List all VMs and containers.
110
+
111
+ ```bash
112
+ # All guests
113
+ pxinv list
114
+
115
+ # Filter by node
116
+ pxinv list --node pve-01
117
+
118
+ # Only running containers
119
+ pxinv list --type ct --status running
120
+
121
+ # Filter by tag
122
+ pxinv list --tags k8s
123
+ pxinv list --tags homelab --status running
124
+
125
+ # JSON output (pipe to jq, etc.)
126
+ pxinv list --output json | jq '.[] | select(.cpu_usage > 50)'
127
+
128
+ # YAML output
129
+ pxinv list --output yaml
130
+ ```
131
+
132
+ ### `pxinv watch`
133
+
134
+ Live-refresh the VM/container list directly in the terminal. No flickering — powered by `rich.Live`. Press `Ctrl+C` to exit.
135
+
136
+ ```bash
137
+ # Refresh every 5 seconds (default)
138
+ pxinv watch
139
+
140
+ # Custom interval
141
+ pxinv watch --interval 10
142
+
143
+ # Combinable with all list filters
144
+ pxinv watch --status running
145
+ pxinv watch --tags k8s --interval 3
146
+ pxinv watch --node pve-01
147
+ ```
148
+
149
+ The panel header shows the refresh interval and the timestamp of the last update.
150
+
151
+ ### `pxinv summary`
152
+
153
+ Show cluster-wide resource totals and node status.
154
+
155
+ ```bash
156
+ pxinv summary
157
+ pxinv summary --output json
158
+ ```
159
+
160
+ ### `pxinv start <vmid>`
161
+
162
+ Start a VM or container by VMID.
163
+
164
+ ```bash
165
+ pxinv start 100
166
+
167
+ # Wait until the VM is fully running before returning
168
+ pxinv start 100 --wait
169
+
170
+ # Custom timeout (default: 60s)
171
+ pxinv start 100 --wait --timeout 120
172
+ ```
173
+
174
+ ### `pxinv stop <vmid>`
175
+
176
+ Gracefully shut down a VM or container by VMID.
177
+
178
+ ```bash
179
+ pxinv stop 100
180
+
181
+ # Wait until the VM is fully stopped before returning
182
+ pxinv stop 100 --wait
183
+ ```
184
+
185
+ ### `pxinv ansible-inventory`
186
+
187
+ Export the inventory in Ansible dynamic inventory JSON format. Hosts are automatically grouped by status (`running`, `stopped`) and by Proxmox tag (`tag_homelab`, `tag_k8s`, etc.).
188
+
189
+ ```bash
190
+ # Basic inventory (no IPs)
191
+ pxinv ansible-inventory
192
+
193
+ # Fetch IPs via QEMU guest agent (requires qemu-guest-agent installed in VMs)
194
+ pxinv ansible-inventory --with-ips
195
+
196
+ # Only include running guests
197
+ pxinv ansible-inventory --running-only
198
+
199
+ # Use directly with ansible
200
+ ansible -i <(pxinv ansible-inventory) all -m ping
201
+
202
+ # Target a specific group
203
+ ansible -i <(pxinv ansible-inventory) tag_homelab -m ping
204
+ ansible -i <(pxinv ansible-inventory) running -m setup
205
+ ```
206
+
207
+ Example output:
208
+
209
+ ```json
210
+ {
211
+ "all": {
212
+ "hosts": ["homeassistant", "pihole"],
213
+ "children": ["running", "stopped", "tag_homelab", "tag_dns"]
214
+ },
215
+ "running": { "hosts": ["homeassistant", "pihole"] },
216
+ "stopped": { "hosts": [] },
217
+ "tag_homelab": { "hosts": ["homeassistant"] },
218
+ "tag_dns": { "hosts": ["pihole"] },
219
+ "_meta": {
220
+ "hostvars": {
221
+ "homeassistant": {
222
+ "ansible_host": "192.168.1.100",
223
+ "proxmox_vmid": 100,
224
+ "proxmox_node": "pve-01",
225
+ "proxmox_type": "vm",
226
+ "proxmox_status": "running",
227
+ "proxmox_tags": ["homelab"]
228
+ }
229
+ }
230
+ }
231
+ }
232
+ ```
233
+
234
+ > `ansible_host` is only populated when using `--with-ips` and the VM has `qemu-guest-agent` running.
235
+
236
+ ## Tags
237
+
238
+ Proxmox supports tagging VMs and containers via the UI (VM → Options → Tags). `pxinv` shows tags as a column in `pxinv list` and lets you filter by them:
239
+
240
+ ```bash
241
+ pxinv list --tags homelab
242
+ pxinv list --tags k8s --status running
243
+ ```
244
+
245
+ Tag matching is case-insensitive. Multiple tags per VM are supported — filtering matches any VM that contains the specified tag.
246
+
247
+ ## Self-signed certificates
248
+
249
+ If your Proxmox uses the default self-signed cert, disable verification:
250
+
251
+ ```bash
252
+ pxinv --no-verify-ssl list
253
+ # or
254
+ export PXINV_VERIFY_SSL=false
255
+ ```
256
+
257
+ ## Contributing
258
+
259
+ PRs welcome. To set up a dev environment:
260
+
261
+ ```bash
262
+ git clone https://github.com/thetechiejourney/pxinv
263
+ cd pxinv
264
+ python3 -m venv .venv
265
+ source .venv/bin/activate
266
+ pip install -e ".[dev]"
267
+ pytest
268
+ ```
269
+
270
+ ## License
271
+
272
+ MIT
pxinv-0.3.0/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # pxinv
2
+
3
+ [![CI](https://github.com/thetechiejourney/pxinv/actions/workflows/ci.yml/badge.svg)](https://github.com/thetechiejourney/pxinv/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
+
6
+ A fast CLI for inventorying and managing VMs and containers on your Proxmox homelab.
7
+
8
+ ```
9
+ $ pxinv list
10
+
11
+ VMID NAME NODE TYPE STATUS CPU RAM DISK UPTIME TAGS
12
+ ──────────────────────────────────────────────────────────────────────────────────────────────────────
13
+ 100 homeassistant pve-01 VM running 5.2% 1.0GB/4.0GB 10.0GB/32.0GB 3d homelab
14
+ 101 pihole pve-01 CT running 0.8% 128.0MB/512.0MB 1.0GB/8.0GB 14d dns
15
+ 200 talos-cp-01 pve-02 VM stopped — —/8.0GB —/64.0GB — k8s
16
+
17
+ 3 resource(s) — 2 running, 1 stopped
18
+ ```
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install pxinv
24
+ ```
25
+
26
+ Or install from source:
27
+
28
+ ```bash
29
+ git clone https://github.com/thetechiejourney/pxinv
30
+ cd pxinv
31
+ pip install -e .
32
+ ```
33
+
34
+ ## Authentication
35
+
36
+ `pxinv` uses Proxmox API tokens (recommended over username/password).
37
+
38
+ **Create a token in Proxmox:**
39
+ 1. Go to Datacenter → Permissions → API Tokens
40
+ 2. Add a token for your user (e.g. `root@pam`, token name: `pxinv`)
41
+ 3. Copy the token value — it's only shown once
42
+
43
+ **Required permissions:** `VM.Audit` and `Sys.Audit` on `/` (or per-node).
44
+
45
+ ## Configuration
46
+
47
+ Credentials can be provided in three ways (in order of precedence):
48
+
49
+ ### 1. CLI flags
50
+ ```bash
51
+ pxinv --host 192.168.1.10 --token-name pxinv --token-value <secret> list
52
+ ```
53
+
54
+ ### 2. Environment variables
55
+ ```bash
56
+ export PXINV_HOST=192.168.1.10
57
+ export PXINV_TOKEN_NAME=pxinv
58
+ export PXINV_TOKEN_VALUE=<secret>
59
+ export PXINV_VERIFY_SSL=false # optional, for self-signed certs
60
+
61
+ pxinv list
62
+ ```
63
+
64
+ ### 3. Config file
65
+
66
+ `~/.config/pxinv/config.yaml`:
67
+ ```yaml
68
+ host: 192.168.1.10
69
+ user: root@pam
70
+ token_name: pxinv
71
+ token_value: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
72
+ verify_ssl: false
73
+ ```
74
+
75
+ ## Commands
76
+
77
+ ### `pxinv list`
78
+
79
+ List all VMs and containers.
80
+
81
+ ```bash
82
+ # All guests
83
+ pxinv list
84
+
85
+ # Filter by node
86
+ pxinv list --node pve-01
87
+
88
+ # Only running containers
89
+ pxinv list --type ct --status running
90
+
91
+ # Filter by tag
92
+ pxinv list --tags k8s
93
+ pxinv list --tags homelab --status running
94
+
95
+ # JSON output (pipe to jq, etc.)
96
+ pxinv list --output json | jq '.[] | select(.cpu_usage > 50)'
97
+
98
+ # YAML output
99
+ pxinv list --output yaml
100
+ ```
101
+
102
+ ### `pxinv watch`
103
+
104
+ Live-refresh the VM/container list directly in the terminal. No flickering — powered by `rich.Live`. Press `Ctrl+C` to exit.
105
+
106
+ ```bash
107
+ # Refresh every 5 seconds (default)
108
+ pxinv watch
109
+
110
+ # Custom interval
111
+ pxinv watch --interval 10
112
+
113
+ # Combinable with all list filters
114
+ pxinv watch --status running
115
+ pxinv watch --tags k8s --interval 3
116
+ pxinv watch --node pve-01
117
+ ```
118
+
119
+ The panel header shows the refresh interval and the timestamp of the last update.
120
+
121
+ ### `pxinv summary`
122
+
123
+ Show cluster-wide resource totals and node status.
124
+
125
+ ```bash
126
+ pxinv summary
127
+ pxinv summary --output json
128
+ ```
129
+
130
+ ### `pxinv start <vmid>`
131
+
132
+ Start a VM or container by VMID.
133
+
134
+ ```bash
135
+ pxinv start 100
136
+
137
+ # Wait until the VM is fully running before returning
138
+ pxinv start 100 --wait
139
+
140
+ # Custom timeout (default: 60s)
141
+ pxinv start 100 --wait --timeout 120
142
+ ```
143
+
144
+ ### `pxinv stop <vmid>`
145
+
146
+ Gracefully shut down a VM or container by VMID.
147
+
148
+ ```bash
149
+ pxinv stop 100
150
+
151
+ # Wait until the VM is fully stopped before returning
152
+ pxinv stop 100 --wait
153
+ ```
154
+
155
+ ### `pxinv ansible-inventory`
156
+
157
+ Export the inventory in Ansible dynamic inventory JSON format. Hosts are automatically grouped by status (`running`, `stopped`) and by Proxmox tag (`tag_homelab`, `tag_k8s`, etc.).
158
+
159
+ ```bash
160
+ # Basic inventory (no IPs)
161
+ pxinv ansible-inventory
162
+
163
+ # Fetch IPs via QEMU guest agent (requires qemu-guest-agent installed in VMs)
164
+ pxinv ansible-inventory --with-ips
165
+
166
+ # Only include running guests
167
+ pxinv ansible-inventory --running-only
168
+
169
+ # Use directly with ansible
170
+ ansible -i <(pxinv ansible-inventory) all -m ping
171
+
172
+ # Target a specific group
173
+ ansible -i <(pxinv ansible-inventory) tag_homelab -m ping
174
+ ansible -i <(pxinv ansible-inventory) running -m setup
175
+ ```
176
+
177
+ Example output:
178
+
179
+ ```json
180
+ {
181
+ "all": {
182
+ "hosts": ["homeassistant", "pihole"],
183
+ "children": ["running", "stopped", "tag_homelab", "tag_dns"]
184
+ },
185
+ "running": { "hosts": ["homeassistant", "pihole"] },
186
+ "stopped": { "hosts": [] },
187
+ "tag_homelab": { "hosts": ["homeassistant"] },
188
+ "tag_dns": { "hosts": ["pihole"] },
189
+ "_meta": {
190
+ "hostvars": {
191
+ "homeassistant": {
192
+ "ansible_host": "192.168.1.100",
193
+ "proxmox_vmid": 100,
194
+ "proxmox_node": "pve-01",
195
+ "proxmox_type": "vm",
196
+ "proxmox_status": "running",
197
+ "proxmox_tags": ["homelab"]
198
+ }
199
+ }
200
+ }
201
+ }
202
+ ```
203
+
204
+ > `ansible_host` is only populated when using `--with-ips` and the VM has `qemu-guest-agent` running.
205
+
206
+ ## Tags
207
+
208
+ Proxmox supports tagging VMs and containers via the UI (VM → Options → Tags). `pxinv` shows tags as a column in `pxinv list` and lets you filter by them:
209
+
210
+ ```bash
211
+ pxinv list --tags homelab
212
+ pxinv list --tags k8s --status running
213
+ ```
214
+
215
+ Tag matching is case-insensitive. Multiple tags per VM are supported — filtering matches any VM that contains the specified tag.
216
+
217
+ ## Self-signed certificates
218
+
219
+ If your Proxmox uses the default self-signed cert, disable verification:
220
+
221
+ ```bash
222
+ pxinv --no-verify-ssl list
223
+ # or
224
+ export PXINV_VERIFY_SSL=false
225
+ ```
226
+
227
+ ## Contributing
228
+
229
+ PRs welcome. To set up a dev environment:
230
+
231
+ ```bash
232
+ git clone https://github.com/thetechiejourney/pxinv
233
+ cd pxinv
234
+ python3 -m venv .venv
235
+ source .venv/bin/activate
236
+ pip install -e ".[dev]"
237
+ pytest
238
+ ```
239
+
240
+ ## License
241
+
242
+ MIT
@@ -0,0 +1,3 @@
1
+ """pxinv — Proxmox VM & container inventory CLI."""
2
+
3
+ __version__ = "0.3.0"