proxcli 0.7.2__tar.gz → 0.8.1__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.
- {proxcli-0.7.2 → proxcli-0.8.1}/CHANGELOG.md +26 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/PKG-INFO +1 -1
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/vm.py +162 -13
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/client/client.py +32 -23
- {proxcli-0.7.2 → proxcli-0.8.1}/pyproject.toml +1 -1
- {proxcli-0.7.2 → proxcli-0.8.1}/uv.lock +1 -1
- {proxcli-0.7.2 → proxcli-0.8.1}/.env.example +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/.github/workflows/ci.yml +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/.gitignore +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/.python-version +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/AGENTS.md +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/PLAN.md +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/PROJECT.md +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/PROMPT.md +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/README.md +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/TODO.md +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/auth.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/cluster.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/completion.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/container.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/firewall_helpers.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/main.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/node.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/pool.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/storage.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/cli/tasks.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/client/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/client/auth.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/client/exceptions.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/config/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/config/config.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/config/models.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/output/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/output/formatter.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/output/json_fmt.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/output/table_fmt.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/output/yaml_fmt.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/utils/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/utils/helpers.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/proxmox/utils/logging.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/conftest.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/test_auth.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/test_cli/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/test_cli/test_main.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/test_client.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/test_config.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/test_integration/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/test_output/__init__.py +0 -0
- {proxcli-0.7.2 → proxcli-0.8.1}/tests/test_output/test_formatter.py +0 -0
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.8.1] - 2026-06-20
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **vm snapshot** management: ``list``, ``create``, ``show``, ``rollback``,
|
|
14
|
+
``delete``. Wraps ``/nodes/{node}/qemu/{vmid}/snapshot`` endpoints.
|
|
15
|
+
|
|
16
|
+
## [0.8.0] - 2026-06-20
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- **vm create** now works against real Proxmox 9.x clusters. The `--ostemplate`
|
|
20
|
+
flag has been renamed to `--cdrom` (``ostemplate`` is an LXC parameter, not
|
|
21
|
+
QEMU). The handler now builds a raw form-encoded body to avoid httpx
|
|
22
|
+
double-encoding ``%`` characters in IDE and network configuration strings.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- **vm create** ``--net`` now uses ``action="append"`` so you can repeat it
|
|
26
|
+
for multiple NICs (net0, net1, …).
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
- **vm create** gains new optional flags: ``--scsihw``, ``--bios``,
|
|
30
|
+
``--machine``, ``--boot``, ``--disk``.
|
|
31
|
+
- ``ProxmoxClient.request()`` now accepts a ``content`` keyword argument
|
|
32
|
+
for sending a pre-encoded raw body instead of ``data``.
|
|
33
|
+
|
|
10
34
|
## [0.7.2] - 2026-06-20
|
|
11
35
|
|
|
12
36
|
### Added
|
|
@@ -100,6 +124,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
100
124
|
- CSRF ticket auto-refresh on 401.
|
|
101
125
|
- AI-agent-friendly: default JSON output, strict exit codes, `--dry-run` mode.
|
|
102
126
|
|
|
127
|
+
[0.8.1]: https://github.com/xezpeleta/proxcli/releases/tag/v0.8.1
|
|
128
|
+
[0.8.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.8.0
|
|
103
129
|
[0.7.2]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.2
|
|
104
130
|
[0.7.1]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.1
|
|
105
131
|
[0.7.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.0
|
|
@@ -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(
|
|
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("--
|
|
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 ---
|
|
@@ -75,6 +84,46 @@ def register_vm_parser(subparsers: argparse._SubParsersAction) -> None:
|
|
|
75
84
|
vm_delete.add_argument("--purge", action="store_true", help="Purge VM from all configurations")
|
|
76
85
|
vm_delete.set_defaults(func=_vm_delete)
|
|
77
86
|
|
|
87
|
+
# --- snapshot ---
|
|
88
|
+
snap = vm_sub.add_parser("snapshot", help="Manage VM snapshots")
|
|
89
|
+
snap_sub = snap.add_subparsers(dest="snap_action", title="snapshot actions", required=True)
|
|
90
|
+
|
|
91
|
+
snap_list = snap_sub.add_parser("list", help="List snapshots")
|
|
92
|
+
snap_list.add_argument("vmid", type=vmid_type, help="VM ID")
|
|
93
|
+
snap_list.add_argument("--node", help="Node name (auto-detected if omitted)")
|
|
94
|
+
snap_list.set_defaults(func=_vm_snapshot_list)
|
|
95
|
+
|
|
96
|
+
snap_create = snap_sub.add_parser("create", help="Create a snapshot")
|
|
97
|
+
snap_create.add_argument("vmid", type=vmid_type, help="VM ID")
|
|
98
|
+
snap_create.add_argument("snapname", help="Snapshot name")
|
|
99
|
+
snap_create.add_argument("--node", help="Node name (auto-detected if omitted)")
|
|
100
|
+
snap_create.add_argument("--description", default=None, help="Snapshot description")
|
|
101
|
+
snap_create.add_argument("--vmstate", type=int, choices=[0, 1], default=0,
|
|
102
|
+
help="Include RAM state (1=yes, 0=no, default: 0)")
|
|
103
|
+
snap_create.set_defaults(func=_vm_snapshot_create)
|
|
104
|
+
|
|
105
|
+
snap_show = snap_sub.add_parser("show", help="Show snapshot details")
|
|
106
|
+
snap_show.add_argument("vmid", type=vmid_type, help="VM ID")
|
|
107
|
+
snap_show.add_argument("snapname", help="Snapshot name")
|
|
108
|
+
snap_show.add_argument("--node", help="Node name (auto-detected if omitted)")
|
|
109
|
+
snap_show.set_defaults(func=_vm_snapshot_show)
|
|
110
|
+
|
|
111
|
+
snap_rollback = snap_sub.add_parser("rollback", help="Rollback to a snapshot")
|
|
112
|
+
snap_rollback.add_argument("vmid", type=vmid_type, help="VM ID")
|
|
113
|
+
snap_rollback.add_argument("snapname", help="Snapshot name")
|
|
114
|
+
snap_rollback.add_argument("--node", help="Node name (auto-detected if omitted)")
|
|
115
|
+
snap_rollback.add_argument("--start", type=int, choices=[0, 1], default=0,
|
|
116
|
+
help="Start VM after rollback (1=yes, 0=no, default: 0)")
|
|
117
|
+
snap_rollback.set_defaults(func=_vm_snapshot_rollback)
|
|
118
|
+
|
|
119
|
+
snap_delete = snap_sub.add_parser("delete", help="Delete a snapshot")
|
|
120
|
+
snap_delete.add_argument("vmid", type=vmid_type, help="VM ID")
|
|
121
|
+
snap_delete.add_argument("snapname", help="Snapshot name")
|
|
122
|
+
snap_delete.add_argument("--node", help="Node name (auto-detected if omitted)")
|
|
123
|
+
snap_delete.add_argument("--force", type=int, choices=[0, 1], default=0,
|
|
124
|
+
help="Force removal (1=yes, 0=no, default: 0)")
|
|
125
|
+
snap_delete.set_defaults(func=_vm_snapshot_delete)
|
|
126
|
+
|
|
78
127
|
# --- firewall ---
|
|
79
128
|
fw = vm_sub.add_parser("firewall", help="Manage VM firewall")
|
|
80
129
|
fw_sub = fw.add_subparsers(dest="fw_resource", title="resources", required=True)
|
|
@@ -215,21 +264,51 @@ def _vm_show(args: argparse.Namespace, client: ProxmoxClient) -> dict:
|
|
|
215
264
|
|
|
216
265
|
|
|
217
266
|
def _vm_create(args: argparse.Namespace, client: ProxmoxClient) -> dict:
|
|
267
|
+
vmid = resolve_vmid(client, args.vmid)
|
|
218
268
|
data: dict = {
|
|
219
|
-
"vmid":
|
|
220
|
-
"memory": args.memory,
|
|
221
|
-
"cores": args.cores,
|
|
269
|
+
"vmid": str(vmid),
|
|
270
|
+
"memory": str(args.memory),
|
|
271
|
+
"cores": str(args.cores),
|
|
222
272
|
}
|
|
223
|
-
if args.net:
|
|
224
|
-
data["net0"] = args.net
|
|
225
273
|
if args.name:
|
|
226
274
|
data["name"] = args.name
|
|
227
|
-
if args.
|
|
228
|
-
data["
|
|
229
|
-
if args.
|
|
230
|
-
data["
|
|
231
|
-
|
|
232
|
-
|
|
275
|
+
if args.bios:
|
|
276
|
+
data["bios"] = args.bios
|
|
277
|
+
if args.machine:
|
|
278
|
+
data["machine"] = args.machine
|
|
279
|
+
if args.scsihw:
|
|
280
|
+
data["scsihw"] = args.scsihw
|
|
281
|
+
if args.boot:
|
|
282
|
+
data["boot"] = args.boot
|
|
283
|
+
|
|
284
|
+
# Network interfaces: net0, net1, ...
|
|
285
|
+
if args.net_ifaces:
|
|
286
|
+
for i, net_cfg in enumerate(args.net_ifaces):
|
|
287
|
+
# Pre-encode the net config for form body: = → %3D, : → %3A, , → %2C
|
|
288
|
+
encoded = net_cfg.replace("=", "%3D").replace(":", "%3A").replace(",", "%2C")
|
|
289
|
+
data[f"net{i}"] = encoded
|
|
290
|
+
|
|
291
|
+
# CD-ROM / ISO
|
|
292
|
+
if args.cdrom:
|
|
293
|
+
# Build: file=storage:iso/file.iso,media=cdrom
|
|
294
|
+
# Pre-encode: = → %3D, : → %3A, , → %2C
|
|
295
|
+
ide_raw = f"file={args.cdrom},media=cdrom"
|
|
296
|
+
data["ide2"] = ide_raw.replace("=", "%3D").replace(":", "%3A").replace(",", "%2C")
|
|
297
|
+
|
|
298
|
+
# Disk
|
|
299
|
+
if args.disk:
|
|
300
|
+
storage = args.storage or "local-lvm"
|
|
301
|
+
if ":" not in args.disk:
|
|
302
|
+
disk_raw = f"{storage}:{args.disk}"
|
|
303
|
+
else:
|
|
304
|
+
disk_raw = args.disk
|
|
305
|
+
data["scsi0"] = disk_raw.replace("=", "%3D").replace(":", "%3A").replace(",", "%2C")
|
|
306
|
+
|
|
307
|
+
# Build form-encoded body manually — httpx's data= would double-encode %
|
|
308
|
+
from urllib.parse import urlencode
|
|
309
|
+
body = urlencode(data, safe="%") # safe="%" means don't re-encode existing %XX
|
|
310
|
+
|
|
311
|
+
result = client.request("POST", f"/nodes/{args.node}/qemu", content=body)
|
|
233
312
|
return result if isinstance(result, dict) else {"data": result}
|
|
234
313
|
|
|
235
314
|
|
|
@@ -286,6 +365,76 @@ def _vm_delete(args: argparse.Namespace, client: ProxmoxClient) -> dict:
|
|
|
286
365
|
return result if isinstance(result, dict) else {"data": result}
|
|
287
366
|
|
|
288
367
|
|
|
368
|
+
# ---------------------------------------------------------------------------
|
|
369
|
+
# VM snapshot handlers
|
|
370
|
+
# ---------------------------------------------------------------------------
|
|
371
|
+
|
|
372
|
+
def _vm_snapshot_list(args: argparse.Namespace, client: ProxmoxClient) -> dict | list:
|
|
373
|
+
node = _resolve_node(client, args.node, args.vmid)
|
|
374
|
+
if not node:
|
|
375
|
+
return {"error": f"VM {args.vmid} not found"}
|
|
376
|
+
result = client.get(f"/nodes/{node}/qemu/{args.vmid}/snapshot")
|
|
377
|
+
# Add _node for consistency
|
|
378
|
+
if isinstance(result, list):
|
|
379
|
+
for snap in result:
|
|
380
|
+
if isinstance(snap, dict):
|
|
381
|
+
snap["_node"] = node
|
|
382
|
+
snap["_vmid"] = args.vmid
|
|
383
|
+
return result
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
def _vm_snapshot_create(args: argparse.Namespace, client: ProxmoxClient) -> dict:
|
|
387
|
+
node = _resolve_node(client, args.node, args.vmid)
|
|
388
|
+
if not node:
|
|
389
|
+
return {"error": f"VM {args.vmid} not found"}
|
|
390
|
+
data: dict = {"snapname": args.snapname}
|
|
391
|
+
if args.description:
|
|
392
|
+
data["description"] = args.description
|
|
393
|
+
if args.vmstate:
|
|
394
|
+
data["vmstate"] = args.vmstate
|
|
395
|
+
result = client.post(f"/nodes/{node}/qemu/{args.vmid}/snapshot", data=data)
|
|
396
|
+
return result if isinstance(result, dict) else {"data": result}
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
def _vm_snapshot_show(args: argparse.Namespace, client: ProxmoxClient) -> dict:
|
|
400
|
+
node = _resolve_node(client, args.node, args.vmid)
|
|
401
|
+
if not node:
|
|
402
|
+
return {"error": f"VM {args.vmid} not found"}
|
|
403
|
+
result = client.get(f"/nodes/{node}/qemu/{args.vmid}/snapshot/{args.snapname}")
|
|
404
|
+
if isinstance(result, dict):
|
|
405
|
+
result["_node"] = node
|
|
406
|
+
result["_vmid"] = args.vmid
|
|
407
|
+
return result
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def _vm_snapshot_rollback(args: argparse.Namespace, client: ProxmoxClient) -> dict:
|
|
411
|
+
node = _resolve_node(client, args.node, args.vmid)
|
|
412
|
+
if not node:
|
|
413
|
+
return {"error": f"VM {args.vmid} not found"}
|
|
414
|
+
data: dict = {}
|
|
415
|
+
if args.start:
|
|
416
|
+
data["start"] = args.start
|
|
417
|
+
result = client.post(
|
|
418
|
+
f"/nodes/{node}/qemu/{args.vmid}/snapshot/{args.snapname}/rollback",
|
|
419
|
+
data=data or None,
|
|
420
|
+
)
|
|
421
|
+
return result if isinstance(result, dict) else {"data": result}
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def _vm_snapshot_delete(args: argparse.Namespace, client: ProxmoxClient) -> dict:
|
|
425
|
+
node = _resolve_node(client, args.node, args.vmid)
|
|
426
|
+
if not node:
|
|
427
|
+
return {"error": f"VM {args.vmid} not found"}
|
|
428
|
+
params: dict = {}
|
|
429
|
+
if args.force:
|
|
430
|
+
params["force"] = args.force
|
|
431
|
+
result = client.delete(
|
|
432
|
+
f"/nodes/{node}/qemu/{args.vmid}/snapshot/{args.snapname}",
|
|
433
|
+
params=params or None,
|
|
434
|
+
)
|
|
435
|
+
return result if isinstance(result, dict) else {"data": result}
|
|
436
|
+
|
|
437
|
+
|
|
289
438
|
# ---------------------------------------------------------------------------
|
|
290
439
|
# VM firewall handlers
|
|
291
440
|
# ---------------------------------------------------------------------------
|
|
@@ -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
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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:
|
|
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
|
|
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
|