proxcli 0.7.1__tar.gz → 0.8.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.
Files changed (52) hide show
  1. {proxcli-0.7.1 → proxcli-0.8.0}/CHANGELOG.md +27 -0
  2. {proxcli-0.7.1 → proxcli-0.8.0}/PKG-INFO +18 -1
  3. {proxcli-0.7.1 → proxcli-0.8.0}/README.md +17 -0
  4. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/main.py +55 -1
  5. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/vm.py +52 -13
  6. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/client/client.py +32 -23
  7. {proxcli-0.7.1 → proxcli-0.8.0}/pyproject.toml +1 -1
  8. {proxcli-0.7.1 → proxcli-0.8.0}/uv.lock +1 -1
  9. {proxcli-0.7.1 → proxcli-0.8.0}/.env.example +0 -0
  10. {proxcli-0.7.1 → proxcli-0.8.0}/.github/workflows/ci.yml +0 -0
  11. {proxcli-0.7.1 → proxcli-0.8.0}/.gitignore +0 -0
  12. {proxcli-0.7.1 → proxcli-0.8.0}/.python-version +0 -0
  13. {proxcli-0.7.1 → proxcli-0.8.0}/AGENTS.md +0 -0
  14. {proxcli-0.7.1 → proxcli-0.8.0}/PLAN.md +0 -0
  15. {proxcli-0.7.1 → proxcli-0.8.0}/PROJECT.md +0 -0
  16. {proxcli-0.7.1 → proxcli-0.8.0}/PROMPT.md +0 -0
  17. {proxcli-0.7.1 → proxcli-0.8.0}/TODO.md +0 -0
  18. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/__init__.py +0 -0
  19. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/__init__.py +0 -0
  20. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/auth.py +0 -0
  21. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/cluster.py +0 -0
  22. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/completion.py +0 -0
  23. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/container.py +0 -0
  24. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/firewall_helpers.py +0 -0
  25. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/node.py +0 -0
  26. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/pool.py +0 -0
  27. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/storage.py +0 -0
  28. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/cli/tasks.py +0 -0
  29. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/client/__init__.py +0 -0
  30. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/client/auth.py +0 -0
  31. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/client/exceptions.py +0 -0
  32. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/config/__init__.py +0 -0
  33. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/config/config.py +0 -0
  34. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/config/models.py +0 -0
  35. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/output/__init__.py +0 -0
  36. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/output/formatter.py +0 -0
  37. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/output/json_fmt.py +0 -0
  38. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/output/table_fmt.py +0 -0
  39. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/output/yaml_fmt.py +0 -0
  40. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/utils/__init__.py +0 -0
  41. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/utils/helpers.py +0 -0
  42. {proxcli-0.7.1 → proxcli-0.8.0}/proxmox/utils/logging.py +0 -0
  43. {proxcli-0.7.1 → proxcli-0.8.0}/tests/__init__.py +0 -0
  44. {proxcli-0.7.1 → proxcli-0.8.0}/tests/conftest.py +0 -0
  45. {proxcli-0.7.1 → proxcli-0.8.0}/tests/test_auth.py +0 -0
  46. {proxcli-0.7.1 → proxcli-0.8.0}/tests/test_cli/__init__.py +0 -0
  47. {proxcli-0.7.1 → proxcli-0.8.0}/tests/test_cli/test_main.py +0 -0
  48. {proxcli-0.7.1 → proxcli-0.8.0}/tests/test_client.py +0 -0
  49. {proxcli-0.7.1 → proxcli-0.8.0}/tests/test_config.py +0 -0
  50. {proxcli-0.7.1 → proxcli-0.8.0}/tests/test_integration/__init__.py +0 -0
  51. {proxcli-0.7.1 → proxcli-0.8.0}/tests/test_output/__init__.py +0 -0
  52. {proxcli-0.7.1 → proxcli-0.8.0}/tests/test_output/test_formatter.py +0 -0
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.8.0] - 2026-06-20
11
+
12
+ ### Fixed
13
+ - **vm create** now works against real Proxmox 9.x clusters. The `--ostemplate`
14
+ flag has been renamed to `--cdrom` (``ostemplate`` is an LXC parameter, not
15
+ QEMU). The handler now builds a raw form-encoded body to avoid httpx
16
+ double-encoding ``%`` characters in IDE and network configuration strings.
17
+
18
+ ### Changed
19
+ - **vm create** ``--net`` now uses ``action="append"`` so you can repeat it
20
+ for multiple NICs (net0, net1, …).
21
+
22
+ ### Added
23
+ - **vm create** gains new optional flags: ``--scsihw``, ``--bios``,
24
+ ``--machine``, ``--boot``, ``--disk``.
25
+ - ``ProxmoxClient.request()`` now accepts a ``content`` keyword argument
26
+ for sending a pre-encoded raw body instead of ``data``.
27
+
28
+ ## [0.7.2] - 2026-06-20
29
+
30
+ ### Added
31
+ - Helpful hint when global flags are placed after the resource subcommand.
32
+ Running `proxmox vm list --output table` now shows:
33
+ `Error: Global flag '--output' must come before the resource. Try: proxmox --output vm list ...`
34
+
10
35
  ## [0.7.1] - 2026-06-20
11
36
 
12
37
  ### Fixed
@@ -93,6 +118,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
93
118
  - CSRF ticket auto-refresh on 401.
94
119
  - AI-agent-friendly: default JSON output, strict exit codes, `--dry-run` mode.
95
120
 
121
+ [0.8.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.8.0
122
+ [0.7.2]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.2
96
123
  [0.7.1]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.1
97
124
  [0.7.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.0
98
125
  [0.6.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.6.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxcli
3
- Version: 0.7.1
3
+ Version: 0.8.0
4
4
  Summary: A CLI tool to interact with Proxmox VE nodes and clusters via the REST API
5
5
  Author-email: Xabi Ezpeleta <xezpeleta@gmail.com>
6
6
  License: MIT
@@ -108,6 +108,23 @@ proxmox vm list --username root@pam --url https://pve:8006
108
108
  proxmox --insecure vm list
109
109
  ```
110
110
 
111
+ ### Manual config file
112
+
113
+ If you prefer to hand-edit credentials, create `~/.config/proxmox-cli/credentials.json` (chmod 600):
114
+
115
+ ```json
116
+ {
117
+ "url": "https://192.168.1.10:8006",
118
+ "username": "root@pam",
119
+ "auth_method": "api_token",
120
+ "api_token_id": "my-token",
121
+ "api_token_secret": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
122
+ "verify_tls": false
123
+ }
124
+ ```
125
+
126
+ For password auth, use `"auth_method": "password"` with a `"password"` field instead of `api_token_id` / `api_token_secret`.
127
+
111
128
  ## Command Reference
112
129
 
113
130
  ### Global flags
@@ -85,6 +85,23 @@ proxmox vm list --username root@pam --url https://pve:8006
85
85
  proxmox --insecure vm list
86
86
  ```
87
87
 
88
+ ### Manual config file
89
+
90
+ If you prefer to hand-edit credentials, create `~/.config/proxmox-cli/credentials.json` (chmod 600):
91
+
92
+ ```json
93
+ {
94
+ "url": "https://192.168.1.10:8006",
95
+ "username": "root@pam",
96
+ "auth_method": "api_token",
97
+ "api_token_id": "my-token",
98
+ "api_token_secret": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
99
+ "verify_tls": false
100
+ }
101
+ ```
102
+
103
+ For password auth, use `"auth_method": "password"` with a `"password"` field instead of `api_token_id` / `api_token_secret`.
104
+
88
105
  ## Command Reference
89
106
 
90
107
  ### Global flags
@@ -193,10 +193,64 @@ def _print_command_help(args: argparse.Namespace) -> None:
193
193
  )
194
194
 
195
195
 
196
+ GLOBAL_FLAGS = {
197
+ "--url", "--username", "--password", "--password-stdin", "--api-token",
198
+ "--output", "--dry-run", "--insecure", "--timeout", "--verbose", "--version",
199
+ "-h", "--help",
200
+ }
201
+
202
+ # Flags that take a value (the value follows the flag)
203
+ GLOBAL_FLAGS_WITH_VALUE = {"--url", "--username", "--password", "--api-token", "--output", "--timeout"}
204
+
205
+
206
+ def _hint_global_flags_order(argv: list[str]) -> None:
207
+ """If user placed global flags after the resource, show a helpful hint."""
208
+ resource_pos = -1
209
+ resources = {"auth", "vm", "node", "pool", "container", "storage", "cluster", "completion", "task"}
210
+ for i, arg in enumerate(argv):
211
+ if arg in resources:
212
+ resource_pos = i
213
+ break
214
+ if resource_pos < 0:
215
+ return
216
+ # Check if any global flag (with or without value) appears after the resource
217
+ for i in range(resource_pos, len(argv)):
218
+ arg = argv[i]
219
+ if arg in GLOBAL_FLAGS:
220
+ # Build a corrected example
221
+ resource_part = argv[resource_pos:]
222
+ flags_before = []
223
+ for j in range(resource_pos):
224
+ if argv[j] in GLOBAL_FLAGS or (j > 0 and argv[j-1] in GLOBAL_FLAGS_WITH_VALUE):
225
+ flags_before.append(argv[j])
226
+ example = f"proxmox {arg} {' '.join(resource_part[:2])} ..."
227
+ log_error(
228
+ f"Global flag '{arg}' must come before the resource. "
229
+ f"Try: {example}"
230
+ )
231
+ return
232
+ # Check if this arg is the value of a previous global flag
233
+ if i > 0 and argv[i-1] in GLOBAL_FLAGS_WITH_VALUE and i-1 > resource_pos:
234
+ log_error(
235
+ f"Global flag '{argv[i-1]}' must come before the resource. "
236
+ f"Try: proxmox {argv[i-1]} {arg} {' '.join(argv[resource_pos:resource_pos+2])} ..."
237
+ )
238
+ return
239
+
240
+
196
241
  def main(argv: list[str] | None = None) -> None:
197
242
  """Main entry point."""
198
243
  parser = build_root_parser()
199
- args = parser.parse_args(argv)
244
+
245
+ effective_argv = argv if argv is not None else sys.argv[1:]
246
+
247
+ try:
248
+ args = parser.parse_args(effective_argv)
249
+ except SystemExit as e:
250
+ # If argparse rejected the args, check for global flags placed after resource
251
+ if effective_argv:
252
+ _hint_global_flags_order(effective_argv)
253
+ sys.exit(e.code if isinstance(e.code, int) else 1)
200
254
 
201
255
  # --help or no subcommand: just show help
202
256
  if args.resource is None:
@@ -31,10 +31,19 @@ def register_vm_parser(subparsers: argparse._SubParsersAction) -> None:
31
31
  vm_create.add_argument("--vmid", type=vmid_type, default=None, help="VM ID (auto-assigned if omitted)")
32
32
  vm_create.add_argument("--memory", type=int, required=True, help="Memory in MB")
33
33
  vm_create.add_argument("--cores", type=int, default=1, help="CPU cores (default: 1)")
34
- vm_create.add_argument("--net", default=None, help="Network config (e.g. model=virtio,bridge=vmbr0)")
34
+ vm_create.add_argument(
35
+ "--net", default=None, action="append", dest="net_ifaces",
36
+ help="Network config (e.g. virtio=MAC,bridge=vmbr0). Repeat for multiple NICs."
37
+ )
35
38
  vm_create.add_argument("--storage", default=None, help="Storage for the VM disk")
36
- vm_create.add_argument("--ostemplate", default=None, help="OS template/ISO")
39
+ vm_create.add_argument("--cdrom", default=None, help="ISO volume for install (e.g. local:iso/debian.iso)")
37
40
  vm_create.add_argument("--name", default=None, help="VM name")
41
+ vm_create.add_argument("--scsihw", default=None, choices=["lsi", "lsi53c810", "virtio-scsi-pci", "virtio-scsi-single", "megasas", "pvscsi"],
42
+ help="SCSI controller type")
43
+ vm_create.add_argument("--bios", default=None, choices=["seabios", "ovmf"], help="BIOS type")
44
+ vm_create.add_argument("--machine", default=None, help="Machine type (e.g. q35)")
45
+ vm_create.add_argument("--boot", default=None, help="Boot order (e.g. order=cd;net)")
46
+ vm_create.add_argument("--disk", default=None, help="Disk size (e.g. 32G). Uses --storage if set, else local-lvm.")
38
47
  vm_create.set_defaults(func=_vm_create)
39
48
 
40
49
  # --- vm start ---
@@ -215,21 +224,51 @@ def _vm_show(args: argparse.Namespace, client: ProxmoxClient) -> dict:
215
224
 
216
225
 
217
226
  def _vm_create(args: argparse.Namespace, client: ProxmoxClient) -> dict:
227
+ vmid = resolve_vmid(client, args.vmid)
218
228
  data: dict = {
219
- "vmid": resolve_vmid(client, args.vmid),
220
- "memory": args.memory,
221
- "cores": args.cores,
229
+ "vmid": str(vmid),
230
+ "memory": str(args.memory),
231
+ "cores": str(args.cores),
222
232
  }
223
- if args.net:
224
- data["net0"] = args.net
225
233
  if args.name:
226
234
  data["name"] = args.name
227
- if args.ostemplate:
228
- data["ostemplate"] = args.ostemplate
229
- if args.storage:
230
- data["storage"] = args.storage
231
-
232
- result = client.post(f"/nodes/{args.node}/qemu", data=data)
235
+ if args.bios:
236
+ data["bios"] = args.bios
237
+ if args.machine:
238
+ data["machine"] = args.machine
239
+ if args.scsihw:
240
+ data["scsihw"] = args.scsihw
241
+ if args.boot:
242
+ data["boot"] = args.boot
243
+
244
+ # Network interfaces: net0, net1, ...
245
+ if args.net_ifaces:
246
+ for i, net_cfg in enumerate(args.net_ifaces):
247
+ # Pre-encode the net config for form body: = → %3D, : → %3A, , → %2C
248
+ encoded = net_cfg.replace("=", "%3D").replace(":", "%3A").replace(",", "%2C")
249
+ data[f"net{i}"] = encoded
250
+
251
+ # CD-ROM / ISO
252
+ if args.cdrom:
253
+ # Build: file=storage:iso/file.iso,media=cdrom
254
+ # Pre-encode: = → %3D, : → %3A, , → %2C
255
+ ide_raw = f"file={args.cdrom},media=cdrom"
256
+ data["ide2"] = ide_raw.replace("=", "%3D").replace(":", "%3A").replace(",", "%2C")
257
+
258
+ # Disk
259
+ if args.disk:
260
+ storage = args.storage or "local-lvm"
261
+ if ":" not in args.disk:
262
+ disk_raw = f"{storage}:{args.disk}"
263
+ else:
264
+ disk_raw = args.disk
265
+ data["scsi0"] = disk_raw.replace("=", "%3D").replace(":", "%3A").replace(",", "%2C")
266
+
267
+ # Build form-encoded body manually — httpx's data= would double-encode %
268
+ from urllib.parse import urlencode
269
+ body = urlencode(data, safe="%") # safe="%" means don't re-encode existing %XX
270
+
271
+ result = client.request("POST", f"/nodes/{args.node}/qemu", content=body)
233
272
  return result if isinstance(result, dict) else {"data": result}
234
273
 
235
274
 
@@ -58,23 +58,29 @@ class ProxmoxClient:
58
58
  *,
59
59
  params: dict[str, Any] | None = None,
60
60
  data: dict[str, Any] | None = None,
61
+ content: str | None = None,
61
62
  ) -> dict[str, Any] | list[Any]:
62
63
  """Send an HTTP request and unwrap the Proxmox JSON envelope.
63
64
 
64
65
  Returns ``response.json()["data"]`` on success.
66
+
67
+ Set ``content`` to send a raw string body (e.g. pre-encoded form data)
68
+ instead of ``data`` which gets form-encoded by httpx.
65
69
  """
66
70
  path = self._normalise_path(path)
67
71
  full_url = f"{self._base_url}/api2/json{path}"
68
72
 
69
73
  self._debug(f"{method} {full_url}")
70
- if data:
74
+ if content:
75
+ self._debug(f" content: {content[:200]}")
76
+ elif data:
71
77
  self._debug(f" body: {data}")
72
78
 
73
79
  if self._dry_run:
74
- self._print_dry_run(method, full_url, data)
80
+ self._print_dry_run(method, full_url, data or {"content": content})
75
81
  return {}
76
82
 
77
- return self._send_with_retry(method, full_url, params, data)
83
+ return self._send_with_retry(method, full_url, params, data, content)
78
84
 
79
85
  def get(self, path: str, *, params: dict[str, Any] | None = None) -> dict[str, Any] | list[Any]:
80
86
  return self.request("GET", path, params=params)
@@ -186,12 +192,13 @@ class ProxmoxClient:
186
192
  url: str,
187
193
  params: dict[str, Any] | None,
188
194
  data: dict[str, Any] | None,
195
+ content: str | None = None,
189
196
  ) -> dict[str, Any] | list[Any]:
190
197
  last_exc: Exception | None = None
191
198
 
192
199
  for attempt in range(self._max_retries + 1):
193
200
  try:
194
- return self._send_one(method, url, params, data)
201
+ return self._send_one(method, url, params, data, content)
195
202
  except AuthError:
196
203
  raise # don't retry auth errors
197
204
  except ProxmoxAPIError as exc:
@@ -219,19 +226,27 @@ class ProxmoxClient:
219
226
  url: str,
220
227
  params: dict[str, Any] | None,
221
228
  data: dict[str, Any] | None,
229
+ content: str | None = None,
222
230
  ) -> dict[str, Any] | list[Any]:
223
231
  headers = self._auth.get_headers()
224
232
 
233
+ # Build the httpx kwargs
234
+ httpx_kwargs: dict[str, Any] = dict(
235
+ method=method,
236
+ url=url,
237
+ params=params,
238
+ headers=headers,
239
+ timeout=self._timeout,
240
+ verify=self._verify_tls,
241
+ )
242
+ if content is not None:
243
+ httpx_kwargs["content"] = content
244
+ httpx_kwargs["headers"] = {**headers, "Content-Type": "application/x-www-form-urlencoded"}
245
+ else:
246
+ httpx_kwargs["data"] = data
247
+
225
248
  try:
226
- resp = httpx.request(
227
- method=method,
228
- url=url,
229
- params=params,
230
- data=data,
231
- headers=headers,
232
- timeout=self._timeout,
233
- verify=self._verify_tls,
234
- )
249
+ resp = httpx.request(**httpx_kwargs)
235
250
  except httpx.TimeoutException:
236
251
  raise
237
252
  except httpx.RequestError as exc:
@@ -247,16 +262,10 @@ class ProxmoxClient:
247
262
  # Auto-refresh ticket once
248
263
  self._debug(" 🔄 re-authenticating ...")
249
264
  self.authenticate()
250
- headers = self._auth.get_headers()
251
- resp = httpx.request(
252
- method=method,
253
- url=url,
254
- params=params,
255
- data=data,
256
- headers=headers,
257
- timeout=self._timeout,
258
- verify=self._verify_tls,
259
- )
265
+ retry_headers = self._auth.get_headers()
266
+ retry_kwargs = dict(httpx_kwargs)
267
+ retry_kwargs["headers"] = retry_headers
268
+ resp = httpx.request(**retry_kwargs)
260
269
 
261
270
  if not (200 <= resp.status_code < 300):
262
271
  try:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "proxcli"
3
- version = "0.7.1"
3
+ version = "0.8.0"
4
4
  description = "A CLI tool to interact with Proxmox VE nodes and clusters via the REST API"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -254,7 +254,7 @@ wheels = [
254
254
 
255
255
  [[package]]
256
256
  name = "proxcli"
257
- version = "0.7.1"
257
+ version = "0.8.0"
258
258
  source = { editable = "." }
259
259
  dependencies = [
260
260
  { name = "httpx" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes