proxcli 0.7.2__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.2 → proxcli-0.8.0}/CHANGELOG.md +19 -0
  2. {proxcli-0.7.2 → proxcli-0.8.0}/PKG-INFO +1 -1
  3. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/vm.py +52 -13
  4. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/client/client.py +32 -23
  5. {proxcli-0.7.2 → proxcli-0.8.0}/pyproject.toml +1 -1
  6. {proxcli-0.7.2 → proxcli-0.8.0}/uv.lock +2 -2
  7. {proxcli-0.7.2 → proxcli-0.8.0}/.env.example +0 -0
  8. {proxcli-0.7.2 → proxcli-0.8.0}/.github/workflows/ci.yml +0 -0
  9. {proxcli-0.7.2 → proxcli-0.8.0}/.gitignore +0 -0
  10. {proxcli-0.7.2 → proxcli-0.8.0}/.python-version +0 -0
  11. {proxcli-0.7.2 → proxcli-0.8.0}/AGENTS.md +0 -0
  12. {proxcli-0.7.2 → proxcli-0.8.0}/PLAN.md +0 -0
  13. {proxcli-0.7.2 → proxcli-0.8.0}/PROJECT.md +0 -0
  14. {proxcli-0.7.2 → proxcli-0.8.0}/PROMPT.md +0 -0
  15. {proxcli-0.7.2 → proxcli-0.8.0}/README.md +0 -0
  16. {proxcli-0.7.2 → proxcli-0.8.0}/TODO.md +0 -0
  17. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/__init__.py +0 -0
  18. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/__init__.py +0 -0
  19. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/auth.py +0 -0
  20. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/cluster.py +0 -0
  21. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/completion.py +0 -0
  22. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/container.py +0 -0
  23. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/firewall_helpers.py +0 -0
  24. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/main.py +0 -0
  25. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/node.py +0 -0
  26. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/pool.py +0 -0
  27. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/storage.py +0 -0
  28. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/cli/tasks.py +0 -0
  29. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/client/__init__.py +0 -0
  30. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/client/auth.py +0 -0
  31. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/client/exceptions.py +0 -0
  32. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/config/__init__.py +0 -0
  33. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/config/config.py +0 -0
  34. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/config/models.py +0 -0
  35. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/output/__init__.py +0 -0
  36. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/output/formatter.py +0 -0
  37. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/output/json_fmt.py +0 -0
  38. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/output/table_fmt.py +0 -0
  39. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/output/yaml_fmt.py +0 -0
  40. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/utils/__init__.py +0 -0
  41. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/utils/helpers.py +0 -0
  42. {proxcli-0.7.2 → proxcli-0.8.0}/proxmox/utils/logging.py +0 -0
  43. {proxcli-0.7.2 → proxcli-0.8.0}/tests/__init__.py +0 -0
  44. {proxcli-0.7.2 → proxcli-0.8.0}/tests/conftest.py +0 -0
  45. {proxcli-0.7.2 → proxcli-0.8.0}/tests/test_auth.py +0 -0
  46. {proxcli-0.7.2 → proxcli-0.8.0}/tests/test_cli/__init__.py +0 -0
  47. {proxcli-0.7.2 → proxcli-0.8.0}/tests/test_cli/test_main.py +0 -0
  48. {proxcli-0.7.2 → proxcli-0.8.0}/tests/test_client.py +0 -0
  49. {proxcli-0.7.2 → proxcli-0.8.0}/tests/test_config.py +0 -0
  50. {proxcli-0.7.2 → proxcli-0.8.0}/tests/test_integration/__init__.py +0 -0
  51. {proxcli-0.7.2 → proxcli-0.8.0}/tests/test_output/__init__.py +0 -0
  52. {proxcli-0.7.2 → proxcli-0.8.0}/tests/test_output/test_formatter.py +0 -0
@@ -7,6 +7,24 @@ 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
+
10
28
  ## [0.7.2] - 2026-06-20
11
29
 
12
30
  ### Added
@@ -100,6 +118,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
100
118
  - CSRF ticket auto-refresh on 401.
101
119
  - AI-agent-friendly: default JSON output, strict exit codes, `--dry-run` mode.
102
120
 
121
+ [0.8.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.8.0
103
122
  [0.7.2]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.2
104
123
  [0.7.1]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.1
105
124
  [0.7.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxcli
3
- Version: 0.7.2
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
@@ -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.2"
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 = [
@@ -1,5 +1,5 @@
1
1
  version = 1
2
- revision = 3
2
+ revision = 2
3
3
  requires-python = ">=3.10"
4
4
 
5
5
  [[package]]
@@ -254,7 +254,7 @@ wheels = [
254
254
 
255
255
  [[package]]
256
256
  name = "proxcli"
257
- version = "0.7.2"
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
File without changes
File without changes