mirror of
https://github.com/TimInTech/proxmox-manager.git
synced 2026-11-20 19:22:53 +03:00
fix: prepare v2.14.1 with SPICE, inventory and terminal fixes
This commit is contained in:
1 parent
c9168107c8
commit
34045b8784
12 files changed
+440
-158
No files matched your search
@@ -34,6 +34,9 @@ jobs:
|
||||
echo "No shell scripts found."
|
||||
exit 0
|
||||
fi
|
||||
for file in "${files[@]}" maintenance/pman-maintenance; do
|
||||
bash -n "$file"
|
||||
done
|
||||
shellcheck -x "${files[@]}" maintenance/pman-maintenance
|
||||
|
||||
- name: Download, verify, and run shfmt
|
||||
@@ -53,7 +56,11 @@ jobs:
|
||||
"${shfmt_path}" -d proxmox-manager.sh install_dependencies.sh maintenance/pman-maintenance tools/build-release.sh
|
||||
|
||||
- name: Run tests
|
||||
run: bash tests/run.sh
|
||||
run: |
|
||||
set -euo pipefail
|
||||
bash tests/run.sh
|
||||
bash tests/test_inventory.sh
|
||||
bash tests/test_spice.sh
|
||||
|
||||
maintenance:
|
||||
name: Maintenance Python ${{ matrix.python }}
|
||||
|
||||
@@ -23,8 +23,31 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Build core and optional module assets
|
||||
run: bash tools/build-release.sh dist
|
||||
- name: Verify release tag matches core version
|
||||
run: |
|
||||
set -euo pipefail
|
||||
version=$(bash proxmox-manager.sh --version | awk '{print $2}')
|
||||
if [[ "$GITHUB_REF_NAME" != "v$version" ]]; then
|
||||
printf 'Release tag %s does not match core version v%s\n' "$GITHUB_REF_NAME" "$version" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run Bash integration tests
|
||||
run: |
|
||||
set -euo pipefail
|
||||
bash tests/run.sh
|
||||
bash tests/test_inventory.sh
|
||||
bash tests/test_spice.sh
|
||||
|
||||
- name: Run maintenance tests
|
||||
run: python3 -B -m unittest discover -s tests/maintenance -v
|
||||
|
||||
- name: Build and verify core and optional module assets
|
||||
run: |
|
||||
set -euo pipefail
|
||||
bash tools/build-release.sh dist
|
||||
cd dist
|
||||
sha256sum --check --strict SHA256SUMS
|
||||
|
||||
- name: Create GitHub Release
|
||||
env:
|
||||
|
||||
+37
-22
@@ -6,29 +6,21 @@ Versions follow [Semantic Versioning](https://semver.org/).
|
||||
|
||||
---
|
||||
|
||||
## [2.14.0] - 2026-10-28
|
||||
|
||||
### Maintenance module 1.0.3
|
||||
|
||||
- Refine the optional maintenance TUI with responsive action/detail views,
|
||||
clearer status and contextual keys, safe confirmation paging, and terminal
|
||||
restoration coverage.
|
||||
- Check community source metadata before confirmation; pinned hashes and a
|
||||
second live check remain required immediately before launch.
|
||||
- Fix community back-entry details and discard keys queued while a worker runs.
|
||||
|
||||
- Add an optional Python/curses storage and maintenance module with a small Bash
|
||||
dispatcher (`--maintenance`, main-menu `m`, and guest-menu `m`).
|
||||
- Add host storage/SMART diagnostics, scoped CT/VM adapters, confirmed TRIM and
|
||||
Debian/Ubuntu CT package-cache cleanup. No automatic guest starts or broad cleanup.
|
||||
- Install the module independently with versioned atomic deployment and rollback;
|
||||
base installation no longer installs unrelated optional packages automatically.
|
||||
- Track declared Community Scripts reference revisions with a daily metadata-only
|
||||
checker. Execute native local adapters, never downloaded upstream code.
|
||||
- Add independent module bundles/checksums and Python/installer regression tests.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
Planned core version: **2.14.1** (prepared 2026-11-08; not published).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Configure SPICE through QXL only, preserve VGA properties and request authenticated
|
||||
connection files through the Proxmox proxy instead of inventing ports.
|
||||
- Report failed VM/CT inventory queries with a nonzero exit status instead of
|
||||
returning an empty or partial successful listing.
|
||||
- Discard stale worker input before displaying maintenance results, so fresh input
|
||||
after a cancelled diagnostic is retained.
|
||||
- Isolate the Bash test viewer marker in its temporary test directory.
|
||||
- Gate releases on Bash/Python tests, tag/core-version agreement and asset checksums.
|
||||
|
||||
### Maintenance module 1.0.5
|
||||
|
||||
- Add a display language choice: German (default) or English. The installer asks
|
||||
@@ -59,6 +51,28 @@ Versions follow [Semantic Versioning](https://semver.org/).
|
||||
(ASCII glyphs) and `PMAN_HYPERLINKS=0|1` (OSC 8 links, plain URL is always
|
||||
shown) are supported. Golden snapshot tests cover 80x24, 120x40 and `NO_COLOR`.
|
||||
|
||||
## [2.14.0] - 2026-10-28
|
||||
|
||||
### Maintenance module 1.0.3
|
||||
|
||||
- Refine the optional maintenance TUI with responsive action/detail views,
|
||||
clearer status and contextual keys, safe confirmation paging, and terminal
|
||||
restoration coverage.
|
||||
- Check community source metadata before confirmation; pinned hashes and a
|
||||
second live check remain required immediately before launch.
|
||||
- Fix community back-entry details and discard keys queued while a worker runs.
|
||||
|
||||
- Add an optional Python/curses storage and maintenance module with a small Bash
|
||||
dispatcher (`--maintenance`, main-menu `m`, and guest-menu `m`).
|
||||
- Add host storage/SMART diagnostics, scoped CT/VM adapters, confirmed TRIM and
|
||||
Debian/Ubuntu CT package-cache cleanup. No automatic guest starts or broad cleanup.
|
||||
- Install the module independently with versioned atomic deployment and rollback;
|
||||
base installation no longer installs unrelated optional packages automatically.
|
||||
- Track declared Community Scripts reference revisions with a daily metadata-only
|
||||
checker. Native adapters run locally; selected community tools download and
|
||||
execute pinned upstream scripts after source and hash verification.
|
||||
- Add independent module bundles/checksums and Python/installer regression tests.
|
||||
|
||||
## [2.13.2] - 2026-10-21
|
||||
|
||||
### Fixed
|
||||
@@ -345,7 +359,8 @@ rewrite.
|
||||
|
||||
---
|
||||
|
||||
[Unreleased]: https://github.com/TimInTech/proxmox-manager/compare/v2.13.2...HEAD
|
||||
[Unreleased]: https://github.com/TimInTech/proxmox-manager/compare/v2.14.0...HEAD
|
||||
[2.14.0]: https://github.com/TimInTech/proxmox-manager/compare/v2.13.2...v2.14.0
|
||||
[2.13.2]: https://github.com/TimInTech/proxmox-manager/compare/v2.13.1...v2.13.2
|
||||
[2.13.1]: https://github.com/TimInTech/proxmox-manager/compare/v2.13.0...v2.13.1
|
||||
[2.13.0]: https://github.com/TimInTech/proxmox-manager/compare/v2.12.1...v2.13.0
|
||||
|
||||
+4
-1
@@ -20,7 +20,10 @@ Thanks for your interest in improving `proxmox-manager`!
|
||||
4. **Testing**
|
||||
- Exercise the script on a Proxmox test host or mock environment when
|
||||
possible.
|
||||
- Add automated tests once the project includes test harnesses.
|
||||
- Run `bash tests/run.sh`, `bash tests/test_inventory.sh`,
|
||||
`bash tests/test_spice.sh` and
|
||||
`python3 -B -m unittest discover -s tests/maintenance -v` locally.
|
||||
- Add regression coverage to the existing test harnesses for behavior changes.
|
||||
- Document manual testing steps in the pull request description.
|
||||
|
||||
5. **Commit standards**
|
||||
|
||||
@@ -7,6 +7,10 @@ Bash-Skript. Die optionale Speicher- und Wartungsoberfläche verwendet Python 3
|
||||
und die Standardbibliothek; der Bash-Kern kann ohne sie installiert werden. Die
|
||||
vollständige Befehls- und Konfigurationsreferenz steht im [englischen README](README.md).
|
||||
|
||||
**Geplant für v2.14.1:** Fehlermeldungen bei Inventarabfragen, authentifizierte
|
||||
SPICE-Verbindungen und Korrekturen der Eingabebehandlung im Wartungsmodul.
|
||||
Siehe [Changelog](CHANGELOG.md).
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/demo/out/proxmox-manager-demo.gif" alt="Proxmox Manager Live Demo" width="820">
|
||||
</p>
|
||||
@@ -16,6 +20,18 @@ vollständige Befehls- und Konfigurationsreferenz steht im [englischen README](R
|
||||
<small>Headless PTY-Pipeline mit In-Stream-Pseudonymisierung · <a href="docs/demo/index.html">Interaktiver Web-Vektor-Player ▶</a> · <a href="docs/demo/README.md">Pipeline-Details →</a></small>
|
||||
</p>
|
||||
|
||||
## Community & Tutorials
|
||||
|
||||
Externe Veröffentlichungen über `proxmox-manager`:
|
||||
|
||||
- **[Proxmox Manager – Co to jest, jak działa, instalacja i obsługa](https://blog.askomputer.pl/proxmox-manager-timintech-co-to-jest-jak-dziala-instalacja-i-obsluga/)**
|
||||
Anleitung und Vorstellung von askomputer.pl mit Beispielen und Screenshots (Polnisch).
|
||||
- **[Stop Wrestling Proxmox GUIs: Meet the Single-Bash TUI That Changes Everything](https://prompts.brightcoding.dev/blog/stop-wrestling-proxmox-guis-meet-the-single-bash-tui-that-changes-everything)**
|
||||
Überblick von Bright Coding über Installation, TUI und VM-/Container-Verwaltung (Englisch).
|
||||
- **[This Lightweight Proxmox Tool Makes CLI Management Faster](https://www.virtualizationhowto.com/2026/05/this-lightweight-proxmox-tool-makes-cli-management-faster/)**
|
||||
Praxistest von Brandon Lee zu Installation, VM-/LXC-Verwaltung, Snapshots,
|
||||
Konsolenzugriff und Einsatz im Homelab (Englisch).
|
||||
|
||||
## Installation
|
||||
|
||||
Auf einem Proxmox-Host als Administrator aus einem passenden Checkout:
|
||||
@@ -119,6 +135,8 @@ mit:
|
||||
```bash
|
||||
python3 -B -m unittest discover -s tests/maintenance
|
||||
bash tests/run.sh
|
||||
bash tests/test_inventory.sh
|
||||
bash tests/test_spice.sh
|
||||
```
|
||||
|
||||
Die echten Proxmox-Aktionen brauchen einen Testhost. Siehe [Wartungsdokumentation](docs/maintenance.md).
|
||||
@@ -129,3 +147,15 @@ Die echten Proxmox-Aktionen brauchen einen Testhost. Siehe [Wartungsdokumentatio
|
||||
Bestand aus. `pman --health` zeigt den Zustand und `pman --check` führt den
|
||||
optionalen Alarm-Check aus. Konfiguration, Befehle und Beispiele erläutert das
|
||||
[englische README](README.md). Lizenz: [MIT](LICENSE).
|
||||
|
||||
### SPICE
|
||||
|
||||
„Enable SPICE“ setzt den VGA-Typ auf QXL und erhält benannte VGA-Eigenschaften.
|
||||
Vorhandene QXL-Mehrmonitor-Konfigurationen bleiben erhalten. Die Änderung benötigt
|
||||
ein vollständiges Herunterfahren und Starten; pman startet die VM nicht automatisch neu.
|
||||
„SPICE info“ fordert für eine laufende VM mit QXL eine authentifizierte `.vv`-Datei
|
||||
über die Proxmox-API an. `remote-viewer` (Paket `virt-viewer`) öffnet sie bei
|
||||
vorhandener grafischer Sitzung. Der Desktop muss den Proxy auf TCP 3128 erreichen.
|
||||
`PROXMOX_MANAGER_SPICE_ADDR` bezeichnet dessen erreichbaren Hostnamen oder IP,
|
||||
nicht eine VM-Bind-Adresse. Die private Datei enthält ein kurzlebiges Ticket;
|
||||
zeitnah öffnen und ungenutzte Dateien löschen.
|
||||
@@ -34,6 +34,9 @@ The core needs no daemon or guest agent installation and no dependencies beyond
|
||||
|
||||
</div>
|
||||
|
||||
**Planned v2.14.1:** inventory error reporting, authenticated SPICE connections,
|
||||
and maintenance TUI input handling fixes. See [CHANGELOG](CHANGELOG.md).
|
||||
|
||||
**New in v2.14.0:** optional storage and maintenance TUI (Python standard library),
|
||||
installed separately with `--with-maintenance`. See [maintenance module](docs/maintenance.md).
|
||||
|
||||
@@ -52,6 +55,11 @@ Check out how others are using `proxmox-manager`:
|
||||
obsługa](https://blog.askomputer.pl/proxmox-manager-timintech-co-to-jest-jak-dziala-instalacja-i-obsluga/)**
|
||||
*A detailed walkthrough and review by askomputer.pl featuring usage examples
|
||||
and screenshots (in Polish).*
|
||||
- **[Stop Wrestling Proxmox GUIs: Meet the Single-Bash TUI That Changes Everything](https://prompts.brightcoding.dev/blog/stop-wrestling-proxmox-guis-meet-the-single-bash-tui-that-changes-everything)**
|
||||
*An English-language overview by Bright Coding covering installation, the TUI,
|
||||
and common VM and container management workflows.*
|
||||
- **[This Lightweight Proxmox Tool Makes CLI Management Faster](https://www.virtualizationhowto.com/2026/05/this-lightweight-proxmox-tool-makes-cli-management-faster/)**
|
||||
*Hands-on review by Brandon Lee covering installation, VM/LXC management, snapshots, console access, and practical homelab testing.*
|
||||
|
||||
## 📸 Screenshots
|
||||
|
||||
@@ -91,7 +99,7 @@ Check out how others are using `proxmox-manager`:
|
||||
| 🖥️ | **Console Access** | LXC shell via `pct enter` or QEMU terminal via `qm terminal`. Verifies running state before entering |
|
||||
| 🌐 | **IP Address Lookup** | Shows current IPv4 addresses for running VMs and CTs — VM via QEMU Guest Agent, CT via `pct exec` |
|
||||
| 📦 | **Snapshot Management** | List, create, rollback, delete — with name validation and snapshot preview before destructive actions |
|
||||
| 🖱️ | **SPICE Integration** | Enable SPICE for VMs and retrieve `.vv` connection files. Auto-launches `virt-viewer` when installed |
|
||||
| 🖱️ | **SPICE Integration** | Enable SPICE for VMs and retrieve `.vv` connection files. Auto-launches `remote-viewer` in a graphical session |
|
||||
| 🤖 | **Automation-Ready** | `--json` output, `--filter` by status, `--name` ERE filter, `--force` mode, structured logging via `LOG_FILE` |
|
||||
| ⚙️ | **Config File** | Persistent allowlisted defaults via `/etc/pmanrc` or `~/.pmanrc` — CLI flags always win |
|
||||
|
||||
@@ -335,19 +343,26 @@ pman --json | jq '.[] | select(.status == "running")'
|
||||
|
||||
### SPICE remote desktop
|
||||
|
||||
The SPICE integration generates a `.vv` connection file for any VM. If
|
||||
[`virt-viewer`](https://virt-manager.org/) is installed, it is launched
|
||||
automatically:
|
||||
For a running VM with a QXL display, SPICE info requests an authenticated
|
||||
`.vv` connection file from the Proxmox `spiceproxy` API using `pvesh` and Python 3
|
||||
on the host. If `remote-viewer`
|
||||
(from [`virt-viewer`](https://virt-manager.org/)) is installed and a graphical
|
||||
session is available, it is launched automatically:
|
||||
|
||||
```bash
|
||||
# Install virt-viewer (Debian / Proxmox host)
|
||||
apt install virt-viewer
|
||||
```
|
||||
|
||||
When `virt-viewer` is **not** installed, the path to the generated `.vv` file is
|
||||
printed together with the install hint. The SPICE bind address defaults to
|
||||
`127.0.0.1` and can be overridden via `PROXMOX_MANAGER_SPICE_ADDR` (env var or
|
||||
`~/.pmanrc`).
|
||||
Otherwise, the path to the private `.vv` file is printed. Open it promptly with
|
||||
`remote-viewer` on a desktop that can reach the Proxmox proxy on TCP 3128; it
|
||||
contains a short-lived ticket and TLS trust information. Delete unused connection
|
||||
files. `PROXMOX_MANAGER_SPICE_ADDR` (environment or `~/.pmanrc`) selects the
|
||||
client-reachable proxy hostname/IP; it does not change the VM bind address.
|
||||
|
||||
Enable SPICE sets only the VGA type to QXL and preserves named VGA properties.
|
||||
Existing QXL multi-monitor settings remain intact. Applying a display hardware
|
||||
change requires a full shutdown and start; pman does not restart the VM automatically.
|
||||
|
||||
### Health monitoring & alerts
|
||||
|
||||
@@ -535,7 +550,7 @@ CLI flags are applied last and always win over config file values.
|
||||
# ~/.pmanrc — example
|
||||
STOP_TIMEOUT=120 # shutdown timeout before force stop (default: 60)
|
||||
LOG_FILE="/var/log/proxmox-manager.log" # structured log file (empty = disabled)
|
||||
PROXMOX_MANAGER_SPICE_ADDR="spice.example.invalid" # SPICE bind address
|
||||
PROXMOX_MANAGER_SPICE_ADDR="spice.example.invalid" # Client-reachable SPICE proxy hostname/IP
|
||||
HEALTH_MEM_WARN=80 # health thresholds, see "Health monitoring & alerts"
|
||||
NTFY_URL="https://ntfy.sh/pman-alerts-CHANGE-ME"
|
||||
```
|
||||
@@ -642,10 +657,15 @@ cp completions/pman.zsh ~/.zsh/completions/_pman
|
||||
shellcheck proxmox-manager.sh
|
||||
|
||||
# Unit tests (no real Proxmox needed — uses mock stubs)
|
||||
tests/run.sh
|
||||
bash tests/run.sh
|
||||
bash tests/test_inventory.sh
|
||||
bash tests/test_spice.sh
|
||||
|
||||
# Optional maintenance module tests (no real Proxmox needed)
|
||||
python3 -B -m unittest discover -s tests/maintenance -v
|
||||
```
|
||||
|
||||
141 tests covering `validate_vmid`, `validate_snapshot_name`, `ip_info`,
|
||||
The core suite covers `validate_vmid`, `validate_snapshot_name`, `ip_info`,
|
||||
`--filter`, CLI flags, config parsing, the health view, the `--check` engine and
|
||||
notifications (mocked `pvesh`, `curl`, `sendmail`; no network, no root).
|
||||
|
||||
|
||||
@@ -284,6 +284,22 @@ def _screen(screen, ctx):
|
||||
status = (_('Abgebrochen') if cancel.is_set() else _('Fehlgeschlagen')) if kind == 'error' else _('Erfolgreich')
|
||||
except queue.Empty:
|
||||
pass
|
||||
# Drop stale worker input before publishing the result/confirmation.
|
||||
if flush_confirmation:
|
||||
flush_confirmation = False
|
||||
try:
|
||||
curses.flushinp()
|
||||
except curses.error:
|
||||
confirming = bool(pending or pending_community)
|
||||
pending = None
|
||||
pending_community = None
|
||||
detail_mode = True
|
||||
if confirming:
|
||||
output = [_('Eingabepuffer konnte nicht geleert werden; Bestätigung abgebrochen.')]
|
||||
else:
|
||||
output += ['', _('Eingabepuffer konnte nicht geleert werden. Ergebnis oben beachten.')]
|
||||
status = _('Eingabefehler')
|
||||
continue
|
||||
screen.erase()
|
||||
height, width = screen.getmaxyx()
|
||||
frame = view.render(build_model(height), height, width, ascii_only)
|
||||
@@ -303,21 +319,6 @@ def _screen(screen, ctx):
|
||||
if signature != last_links:
|
||||
last_links = signature
|
||||
emit_links(frame)
|
||||
if flush_confirmation:
|
||||
flush_confirmation = False
|
||||
try:
|
||||
curses.flushinp()
|
||||
except curses.error:
|
||||
confirming = bool(pending or pending_community)
|
||||
pending = None
|
||||
pending_community = None
|
||||
detail_mode = True
|
||||
if confirming:
|
||||
output = [_('Eingabepuffer konnte nicht geleert werden; Bestätigung abgebrochen.')]
|
||||
else:
|
||||
output += ['', _('Eingabepuffer konnte nicht geleert werden. Ergebnis oben beachten.')]
|
||||
status = _('Eingabefehler')
|
||||
continue
|
||||
key = screen.getch()
|
||||
if key == -1:
|
||||
continue
|
||||
|
||||
+129
-78
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Proxmox VM/CT Management Tool
|
||||
# Version 2.14.0 — 2026-10-27
|
||||
# Version 2.14.1 — 2026-11-08
|
||||
# - fix: stop action runs qm/pct shutdown --timeout --forceStop 1 (clean shutdown, force stop only after the timeout) instead of qm/pct stop, which pulled the plug
|
||||
# - feat: health view (--health, menu key h) and cron checks (--check) with ntfy/e-mail alerts
|
||||
# - fix: action and snapshot menus draw a closed frame (right border, padded rows)
|
||||
@@ -772,6 +772,20 @@ vm_name_from_config() { qm config "$1" 2>/dev/null | awk -F': *' '/^name:/ {
|
||||
|
||||
# collect_instances — emit TAB-separated rows: ID TYPE STATUS SYMBOL NAME
|
||||
collect_instances() {
|
||||
# Capture both queries before emitting rows; a failed query is not an empty host.
|
||||
local ct_list='' vm_list=''
|
||||
if have pct; then
|
||||
ct_list="$(pct list)" || {
|
||||
err "Failed to list CT inventory (pct list)."
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
if have qm; then
|
||||
vm_list="$(qm list)" || {
|
||||
err "Failed to list VM inventory (qm list)."
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
if have pct; then
|
||||
while IFS= read -r line; do
|
||||
[[ -z "${line// /}" ]] && continue
|
||||
@@ -787,7 +801,7 @@ collect_instances() {
|
||||
[[ "$status" == "stopped" ]] && sym="$SYM_STOPPED"
|
||||
[[ "$status" == "paused" ]] && sym="$SYM_PAUSED"
|
||||
printf "%s\tCT\t%s\t%s\t%s\n" "$id" "$status" "$sym" "$name"
|
||||
done < <(pct list 2>/dev/null || true)
|
||||
done <<<"$ct_list"
|
||||
fi
|
||||
|
||||
if have qm; then
|
||||
@@ -804,24 +818,29 @@ collect_instances() {
|
||||
[[ "$status" == "stopped" ]] && sym="$SYM_STOPPED"
|
||||
[[ "$status" == "paused" ]] && sym="$SYM_PAUSED"
|
||||
printf "%s\tVM\t%s\t%s\t%s\n" "$id" "$status" "$sym" "$name"
|
||||
done < <(qm list 2>/dev/null || true)
|
||||
done <<<"$vm_list"
|
||||
fi
|
||||
}
|
||||
|
||||
# filtered_instances — wraps collect_instances; applies FILTER_STATUS and FILTER_NAME (AND logic).
|
||||
filtered_instances() {
|
||||
local inventory
|
||||
inventory="$(collect_instances)" || return 1
|
||||
local id ty st sym nm
|
||||
while IFS=$'\t' read -r id ty st sym nm; do
|
||||
[[ -z "$id" ]] && continue
|
||||
[[ -n "$FILTER_STATUS" && "$st" != "$FILTER_STATUS" ]] && continue
|
||||
if [[ -n "$FILTER_NAME" ]]; then
|
||||
[[ "$nm" =~ $FILTER_NAME ]] || continue
|
||||
fi
|
||||
printf "%s\t%s\t%s\t%s\t%s\n" "$id" "$ty" "$st" "$sym" "$nm"
|
||||
done < <(collect_instances)
|
||||
done <<<"$inventory"
|
||||
}
|
||||
|
||||
print_json() {
|
||||
mapfile -t rows < <(filtered_instances | sort -n -t$'\t' -k1,1)
|
||||
local inventory
|
||||
inventory="$(filtered_instances)" || return 1
|
||||
mapfile -t rows < <(printf '%s' "$inventory" | sort -n -t$'\t' -k1,1)
|
||||
if ((${#rows[@]} == 0)); then
|
||||
printf '[]\n'
|
||||
return 0
|
||||
@@ -1084,7 +1103,9 @@ print_table() {
|
||||
[[ "$MODE" == "interactive" ]] && draw_boxes=1
|
||||
|
||||
local -a rows=()
|
||||
mapfile -t rows < <(filtered_instances | sort -n -t$'\t' -k1,1)
|
||||
local inventory
|
||||
inventory="$(filtered_instances)" || return 2
|
||||
mapfile -t rows < <(printf '%s' "$inventory" | sort -n -t$'\t' -k1,1)
|
||||
|
||||
# NAME column grows with the longest name; boxed output is capped at the
|
||||
# terminal width and longer names are truncated.
|
||||
@@ -2657,7 +2678,10 @@ maintenance_open() {
|
||||
|
||||
main_menu() {
|
||||
header
|
||||
if ! print_table; then return 1; fi
|
||||
local table_rc=0
|
||||
print_table || table_rc=$?
|
||||
((table_rc == 2)) && return 1
|
||||
((table_rc != 0)) && return 0
|
||||
echo
|
||||
printf ' %b%s%b %s\n' "${BOLD}" "Keys:" "${NC}" \
|
||||
"<VMID> = open action menu ${BOLD}h${NC} = health ${BOLD}m${NC} = host maintenance ${BOLD}r${NC} = refresh ${BOLD}q${NC} = quit"
|
||||
@@ -2674,15 +2698,17 @@ main_menu() {
|
||||
if ! validate_vmid "$choice"; then
|
||||
return 0
|
||||
fi
|
||||
local sel_type='' sel_name='' found=0
|
||||
local sel_type='' sel_name='' found=0 inventory
|
||||
inventory="$(collect_instances)" || return 1
|
||||
while IFS=$'\t' read -r id ty _ _ nm; do
|
||||
[[ -z "$id" ]] && continue
|
||||
_type_cache["$id"]="$ty" # warm the cache for all listed instances
|
||||
if [[ "$id" == "$choice" ]]; then
|
||||
sel_type="$ty"
|
||||
sel_name="$nm"
|
||||
found=1
|
||||
fi
|
||||
done < <(collect_instances)
|
||||
done <<<"$inventory"
|
||||
if ((found == 1)); then
|
||||
action_menu "$choice" "$sel_type" "$sel_name"
|
||||
else
|
||||
@@ -2693,6 +2719,7 @@ main_menu() {
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
||||
action_menu() {
|
||||
@@ -3142,85 +3169,109 @@ _spice_has_gui_session() {
|
||||
[[ -n "${DISPLAY:-}" ]] || [[ -n "${WAYLAND_DISPLAY:-}" && -n "${XDG_RUNTIME_DIR:-}" ]]
|
||||
}
|
||||
|
||||
_spice_endpoint() {
|
||||
local id="$1"
|
||||
local monitor endpoint host='' port='' cfg_spice cfg_addr id_int
|
||||
|
||||
monitor="$(qm monitor "$id" <<<'info spice' 2>/dev/null || true)"
|
||||
endpoint="$(sed -n 's/^[[:space:]]*address:[[:space:]]*\([^[:space:]]*\).*/\1/p' <<<"$monitor" | head -1)"
|
||||
if [[ -n "$endpoint" ]]; then
|
||||
if [[ "$endpoint" == \[*\]:* ]]; then
|
||||
host="${endpoint%%]:*}"
|
||||
host="${host#[}"
|
||||
port="${endpoint##*:}"
|
||||
elif [[ "$endpoint" == *:* ]]; then
|
||||
host="${endpoint%:*}"
|
||||
port="${endpoint##*:}"
|
||||
fi
|
||||
fi
|
||||
|
||||
cfg_spice="$(qm config "$id" 2>/dev/null | sed -n 's/^spice: .*port=\([0-9]\+\).*/\1/p' | head -1)"
|
||||
cfg_addr="$(qm config "$id" 2>/dev/null | sed -n 's/^spice: .*addr=\([^,]*\).*/\1/p' | head -1)"
|
||||
[[ -z "$port" && -n "$cfg_spice" ]] && port="$cfg_spice"
|
||||
[[ -z "$host" && -n "$cfg_addr" ]] && host="$cfg_addr"
|
||||
|
||||
[[ -z "$host" ]] && host="${PROXMOX_MANAGER_SPICE_ADDR:-$(hostname -I 2>/dev/null | awk '{print $1}')}"
|
||||
id_int=$((10#$id))
|
||||
[[ -z "$port" ]] && port="$((61000 + id_int))"
|
||||
|
||||
printf '%s\t%s\n' "$host" "$port"
|
||||
}
|
||||
|
||||
# Proxmox supplies short-lived tickets, proxy routing and TLS trust material.
|
||||
# Never print the response or pass its credentials as process arguments.
|
||||
spice_info() {
|
||||
local id="$1" name="$2"
|
||||
local host port endpoint
|
||||
endpoint="$(_spice_endpoint "$id")"
|
||||
host="${endpoint%%$'\t'*}"
|
||||
port="${endpoint##*$'\t'}"
|
||||
|
||||
printf ' %bSPICE:%b spice://%s:%s\n' "${BOLD}${CYAN_BRIGHT}" "${NC}" "$host" "$port"
|
||||
umask 077
|
||||
local vv
|
||||
vv="$(mktemp -p "${TMPDIR:-/tmp}" "vm-${id}.XXXXXX.vv")" || {
|
||||
local id="$1" name="$2" node vv
|
||||
validate_vmid "$id" || return 1
|
||||
if ! have pvesh || ! have python3; then
|
||||
err "SPICE connection files require pvesh and python3."
|
||||
return 1
|
||||
fi
|
||||
node="$(_local_node)"
|
||||
[[ "$node" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]] || {
|
||||
err "Cannot determine the local Proxmox node."
|
||||
return 1
|
||||
}
|
||||
vv="$(
|
||||
umask 077
|
||||
mktemp -p "${TMPDIR:-/tmp}" "vm-${id}.XXXXXX.vv"
|
||||
)" || {
|
||||
err "mktemp failed"
|
||||
return 1
|
||||
}
|
||||
chmod 600 "$vv" || true
|
||||
cat >"$vv" <<EOF
|
||||
[virt-viewer]
|
||||
type=spice
|
||||
host=${host}
|
||||
port=${port}
|
||||
title=VM ${id} (${name})
|
||||
delete-this-file=1
|
||||
fullscreen=0
|
||||
EOF
|
||||
if have virt-viewer && _spice_has_gui_session; then
|
||||
virt-viewer "$vv" &
|
||||
ok "Launching virt-viewer for VM ${id}..."
|
||||
local -a proxy_args=()
|
||||
[[ -n "$PROXMOX_MANAGER_SPICE_ADDR" ]] && proxy_args=(--proxy "$PROXMOX_MANAGER_SPICE_ADDR")
|
||||
if ! pvesh create "/nodes/${node}/qemu/${id}/spiceproxy" --output-format json "${proxy_args[@]}" 2>/dev/null |
|
||||
python3 -c '
|
||||
import json, sys
|
||||
try:
|
||||
data = json.load(sys.stdin)
|
||||
required = ("type", "host", "proxy", "tls-port", "password", "ca", "host-subject")
|
||||
if not isinstance(data, dict) or any(not data.get(k) for k in required):
|
||||
raise ValueError()
|
||||
if data["type"] != "spice" or not 1 <= int(data["tls-port"]) <= 65535:
|
||||
raise ValueError()
|
||||
keys = required + ("secure-attention", "toggle-fullscreen", "release-cursor", "title")
|
||||
lines = ["[virt-viewer]"]
|
||||
for key in keys:
|
||||
if key not in data:
|
||||
continue
|
||||
value = str(data[key])
|
||||
if any(ord(c) < 32 or ord(c) == 127 for c in value):
|
||||
raise ValueError()
|
||||
lines.append(key + "=" + value)
|
||||
lines.append("delete-this-file=1")
|
||||
with open(sys.argv[1], "w", encoding="utf-8") as output:
|
||||
output.write("\n".join(lines) + "\n")
|
||||
except (ValueError, TypeError, OSError):
|
||||
sys.exit(1)
|
||||
' "$vv" 2>/dev/null; then
|
||||
rm -f -- "$vv"
|
||||
err "Could not obtain a valid SPICE connection file for VM ${id} (${name})."
|
||||
return 1
|
||||
fi
|
||||
if have remote-viewer && _spice_has_gui_session; then
|
||||
remote-viewer "$vv" &
|
||||
ok "Launching remote-viewer for VM ${id}..."
|
||||
else
|
||||
ok "SPICE connection file: ${vv}"
|
||||
if have virt-viewer; then
|
||||
note "No graphical session detected in this shell. Open the .vv file from a desktop session."
|
||||
else
|
||||
note "Install virt-viewer with: apt install virt-viewer"
|
||||
note "Open it promptly with remote-viewer from a desktop that can reach the Proxmox proxy (TCP 3128)."
|
||||
if ! have remote-viewer; then
|
||||
note "Install remote-viewer with: apt install virt-viewer"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
spice_enable() {
|
||||
local id="$1"
|
||||
local id_int port
|
||||
id_int=$((10#$id))
|
||||
port=$((61000 + id_int))
|
||||
local addr="${PROXMOX_MANAGER_SPICE_ADDR:-127.0.0.1}"
|
||||
qm set "$id" --vga qxl >/dev/null 2>&1 || true
|
||||
if qm set "$id" --spice "port=${port},addr=${addr}" >/dev/null 2>&1; then
|
||||
ok "SPICE enabled for VM ${id}. Port: ${port}. A restart is required."
|
||||
confirm "Restart VM ${id} now?" && do_action "$id" "VM" restart "VM-${id}"
|
||||
else
|
||||
err "Could not enable SPICE for VM ${id}."
|
||||
local id="$1" config vga='' digest='' part updated='' output
|
||||
validate_vmid "$id" || return 1
|
||||
if ! config="$(qm config "$id" 2>/dev/null)"; then
|
||||
err "Could not read VM ${id} configuration; SPICE was not changed."
|
||||
return 1
|
||||
fi
|
||||
while IFS= read -r part; do
|
||||
case "$part" in
|
||||
vga:*) vga="$(trim "${part#vga:}")" ;;
|
||||
digest:*) digest="$(trim "${part#digest:}")" ;;
|
||||
esac
|
||||
done <<<"$config"
|
||||
local -a properties=()
|
||||
IFS=, read -r -a properties <<<"$vga"
|
||||
for part in "${properties[@]}"; do
|
||||
case "$part" in
|
||||
qxl | qxl2 | qxl3 | qxl4 | type=qxl | type=qxl2 | type=qxl3 | type=qxl4)
|
||||
ok "SPICE display is already configured for VM ${id}."
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
updated='qxl'
|
||||
for part in "${properties[@]}"; do
|
||||
# Preserve named VGA subproperties (memory, clipboard, future options).
|
||||
if [[ "$part" == *=* && "$part" != type=* ]]; then
|
||||
updated+=",${part}"
|
||||
fi
|
||||
done
|
||||
local -a digest_args=()
|
||||
[[ -n "$digest" ]] && digest_args=(--digest "$digest")
|
||||
if ! output="$(qm set "$id" --vga "$updated" "${digest_args[@]}" 2>&1)"; then
|
||||
err "Could not enable SPICE for VM ${id}."
|
||||
_log_pve_err "$output"
|
||||
return 1
|
||||
fi
|
||||
ok "SPICE display enabled for VM ${id}. A full VM shutdown and start is required to apply display hardware changes."
|
||||
return 0
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
@@ -3426,7 +3477,7 @@ main() {
|
||||
fi
|
||||
;;
|
||||
json)
|
||||
print_json
|
||||
print_json || exit 1
|
||||
exit 0
|
||||
;;
|
||||
health | health_list)
|
||||
@@ -3451,7 +3502,7 @@ main() {
|
||||
;;
|
||||
interactive)
|
||||
while true; do
|
||||
main_menu || true
|
||||
main_menu || exit 1
|
||||
((RUN_ONCE == 1)) && break
|
||||
done
|
||||
;;
|
||||
|
||||
@@ -95,12 +95,7 @@ class TerminalPTYTest(unittest.TestCase):
|
||||
wait_for('Prüfung läuft'.encode())
|
||||
os.write(master, b'\x1b')
|
||||
wait_for(b'Abgebrochen')
|
||||
# The UI discards input queued while the result is drawn, so a 'q' sent in
|
||||
# the same instant can be dropped; repeat it like a user would.
|
||||
deadline = time.monotonic() + 4
|
||||
while process.poll() is None and time.monotonic() < deadline:
|
||||
time.sleep(.3)
|
||||
os.write(master, b'q')
|
||||
os.write(master, b'q')
|
||||
self.assertEqual(process.wait(timeout=5), 0)
|
||||
self.assertEqual(termios.tcgetattr(slave), original)
|
||||
finally:
|
||||
@@ -109,3 +104,46 @@ class TerminalPTYTest(unittest.TestCase):
|
||||
process.wait()
|
||||
os.close(master)
|
||||
os.close(slave)
|
||||
|
||||
|
||||
class ResultInputRaceTest(unittest.TestCase):
|
||||
def test_quit_entered_after_result_is_visible_is_not_discarded(self):
|
||||
"""A terminal reply to the new result must survive stale-input cleanup."""
|
||||
from unittest.mock import patch
|
||||
module_dir = Path(__file__).resolve().parents[2] / 'maintenance'
|
||||
sys.path.insert(0, str(module_dir))
|
||||
from pman_maintenance import ui
|
||||
from pman_maintenance.actions import Context
|
||||
|
||||
class ImmediateWorker:
|
||||
def __init__(self, target, **kwargs): self.target = target
|
||||
def start(self): self.target()
|
||||
def is_alive(self): return False
|
||||
|
||||
class Screen:
|
||||
def __init__(self):
|
||||
self.keys = [10]
|
||||
self.rows = []
|
||||
self.result_visible = False
|
||||
def keypad(self, enabled): pass
|
||||
def timeout(self, value): pass
|
||||
def erase(self): self.rows = []
|
||||
def getmaxyx(self): return (24, 80)
|
||||
def addnstr(self, row, col, value, *args): self.rows.append(value)
|
||||
def refresh(self):
|
||||
if not self.result_visible and any('diagnostic complete' in row for row in self.rows):
|
||||
self.result_visible = True
|
||||
self.keys.append(ord('q'))
|
||||
def getch(self):
|
||||
if not self.keys:
|
||||
raise AssertionError('quit entered after result was displayed was discarded')
|
||||
return self.keys.pop(0)
|
||||
|
||||
screen = Screen()
|
||||
with patch.object(ui.curses, 'curs_set'), \
|
||||
patch.object(ui.curses, 'flushinp', side_effect=screen.keys.clear), \
|
||||
patch.object(ui.curses, 'has_colors', return_value=False), \
|
||||
patch.object(ui.threading, 'Thread', ImmediateWorker), \
|
||||
patch.object(ui, 'execute', return_value='diagnostic complete'):
|
||||
ui._screen(screen, Context('host'))
|
||||
self.assertTrue(screen.result_visible)
|
||||
+5
-22
@@ -19,6 +19,7 @@ cd "$ROOT_DIR"
|
||||
TEST_TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TEST_TMP"' EXIT
|
||||
export HOME="$TEST_TMP/home"
|
||||
export HERMES_VIRT_VIEWER_MARKER="$TEST_TMP/virt-viewer-called"
|
||||
mkdir -p "$HOME"
|
||||
|
||||
PASS=0
|
||||
@@ -253,30 +254,12 @@ else
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Unit tests: spice_info()
|
||||
# SPICE regression tests use their own mocks and private ticket files.
|
||||
# ---------------------------------------------------------------------------
|
||||
rm -f /tmp/hermes-virt-viewer-called
|
||||
unset DISPLAY WAYLAND_DISPLAY XDG_RUNTIME_DIR
|
||||
_spice_exit=0
|
||||
_spice_out="$(spice_info 200 vm-one 2>&1)" || _spice_exit=$?
|
||||
_spice_vv="$(printf '%s\n' "$_spice_out" | sed -n 's/.*SPICE connection file: //p' | tail -1)"
|
||||
if [[ "$_spice_exit" == "0" ]] && printf '%s\n' "$_spice_out" | grep -q 'spice://127.0.0.1:61000'; then
|
||||
_pass "spice_info: URI uses monitor/config host and port"
|
||||
if bash "$ROOT_DIR/tests/test_spice.sh"; then
|
||||
_pass "SPICE: authenticated connection and display configuration regressions"
|
||||
else
|
||||
_fail "spice_info: URI did not use expected host/port"
|
||||
fi
|
||||
|
||||
if [[ -n "$_spice_vv" ]] && [[ -f "$_spice_vv" ]] && grep -q '^host=127.0.0.1$' "$_spice_vv"; then
|
||||
_pass "spice_info: .vv file uses actual SPICE bind host"
|
||||
else
|
||||
_fail "spice_info: .vv file did not use expected host"
|
||||
fi
|
||||
|
||||
if [[ -n "$_spice_vv" ]]; then rm -f "$_spice_vv"; fi
|
||||
if [[ ! -e /tmp/hermes-virt-viewer-called ]]; then
|
||||
_pass "spice_info: does not auto-launch virt-viewer without GUI session"
|
||||
else
|
||||
_fail "spice_info: auto-launched virt-viewer without GUI session"
|
||||
_fail "SPICE: authenticated connection or display configuration regression"
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
# Inventory failures must never look like a successful empty/partial listing.
|
||||
set -euo pipefail
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
TEST_TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TEST_TMP"' EXIT
|
||||
mkdir -p "$TEST_TMP/bin" "$TEST_TMP/home"
|
||||
for tool in pct qm; do
|
||||
cat >"$TEST_TMP/bin/$tool" <<'MOCK'
|
||||
#!/usr/bin/env bash
|
||||
if [[ "${1:-}" == list ]]; then
|
||||
if [[ "${0##*/}" == "${INVENTORY_FAIL_TOOL:-}" ]]; then
|
||||
echo '200 partial running 1024 10 1234'
|
||||
echo 'inventory unavailable' >&2
|
||||
exit 7
|
||||
fi
|
||||
echo 'VMID NAME STATUS'
|
||||
exit 0
|
||||
fi
|
||||
exit 0
|
||||
MOCK
|
||||
chmod +x "$TEST_TMP/bin/$tool"
|
||||
done
|
||||
export PATH="$TEST_TMP/bin:$ROOT_DIR/tests/mock-bin:$PATH"
|
||||
export HOME="$TEST_TMP/home" PROXMOX_MANAGER_ALLOW_NONROOT=1 NO_COLOR=1 TERM=dumb
|
||||
failures=0
|
||||
for tool in pct qm; do
|
||||
for mode in --json --list --once; do
|
||||
if INVENTORY_FAIL_TOOL="$tool" bash "$ROOT_DIR/proxmox-manager.sh" "$mode" </dev/null >"$TEST_TMP/out" 2>"$TEST_TMP/err"; then
|
||||
echo "FAIL $tool $mode: inventory error returned success" >&2
|
||||
failures=$((failures + 1))
|
||||
elif ! grep -q "$tool" "$TEST_TMP/err"; then
|
||||
echo "FAIL $tool $mode: no diagnostic identifying failed tool" >&2
|
||||
failures=$((failures + 1))
|
||||
elif grep -Eq 'partial|\[\]' "$TEST_TMP/out"; then
|
||||
echo "FAIL $tool $mode: misleading successful inventory output" >&2
|
||||
failures=$((failures + 1))
|
||||
else
|
||||
echo "PASS $tool $mode: inventory failure propagated"
|
||||
fi
|
||||
done
|
||||
done
|
||||
if output="$(bash "$ROOT_DIR/proxmox-manager.sh" --json)" && [[ "$output" == '[]' ]]; then
|
||||
echo 'PASS successful empty inventory remains valid JSON'
|
||||
else
|
||||
echo 'FAIL successful empty inventory' >&2
|
||||
failures=$((failures + 1))
|
||||
fi
|
||||
if bash "$ROOT_DIR/proxmox-manager.sh" --once </dev/null >"$TEST_TMP/out" 2>"$TEST_TMP/err"; then
|
||||
echo 'PASS interactive empty inventory remains a successful refresh'
|
||||
else
|
||||
echo 'FAIL interactive empty inventory refresh' >&2
|
||||
failures=$((failures + 1))
|
||||
fi
|
||||
exit "$((failures > 0))"
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
# Isolated regression checks: only mocked qm/pvesh, never a Proxmox host.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
python3 - <<'PY'
|
||||
import json, os, pathlib, subprocess, tempfile
|
||||
source = pathlib.Path('proxmox-manager.sh').read_text().rsplit('\nmain "$@"', 1)[0]
|
||||
fixture = {'type':'spice','host':'PVE_PROXY_TICKET','proxy':'http://pve.example:3128','tls-port':61000,'password':'SECRET_TICKET','ca':'CERT\\nLINE','host-subject':'CN=pve','delete-this-file':1}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
env = dict(os.environ, TMPDIR=td, SPICE_FIXTURE=json.dumps(fixture), CALL_LOG=td+'/calls')
|
||||
setup = r'''
|
||||
qm() {
|
||||
local IFS=" "
|
||||
if [[ "$1" == config ]]; then
|
||||
[[ "${CONFIG_FAIL:-0}" == 0 ]] || return 1
|
||||
printf '%s\n' "${VGA_CONFIG:-vga: virtio,memory=128,clipboard=vnc}"
|
||||
elif [[ "$1" == set ]]; then
|
||||
printf '%s\n' "$*" >>"$CALL_LOG"
|
||||
[[ "${SET_FAIL:-0}" == 0 ]]
|
||||
else return 1; fi
|
||||
}
|
||||
pvesh() { local IFS=" "; printf '%s\n' "$*" >>"$CALL_LOG"; [[ "${PROXY_FAIL:-0}" == 0 ]] || return 1; printf '%s\n' "$SPICE_FIXTURE"; }
|
||||
_local_node() { printf pve; }
|
||||
confirm() { return 1; }
|
||||
have() { [[ "$1" != virt-viewer && "$1" != remote-viewer ]]; }
|
||||
'''
|
||||
def run(body, **extra):
|
||||
pathlib.Path(env['CALL_LOG']).write_text('')
|
||||
p = subprocess.run(['bash','-c',source+'\n'+setup+'\n'+body],env=dict(env,**extra),capture_output=True,text=True)
|
||||
return p, pathlib.Path(env['CALL_LOG']).read_text()
|
||||
failures=[]
|
||||
def check(name, condition):
|
||||
print(('PASS ' if condition else 'FAIL ')+name)
|
||||
if not condition: failures.append(name)
|
||||
p, calls=run('spice_enable 999999')
|
||||
check('enable preserves VGA properties without inventing a port', 'set 999999 --vga qxl,memory=128,clipboard=vnc\n' == calls)
|
||||
p,calls=run('spice_enable 200',VGA_CONFIG='digest: abc123\nvga: virtio,memory=64')
|
||||
check('VGA update protects a supplied config digest',calls=='set 200 --vga qxl,memory=64 --digest abc123\n')
|
||||
p,calls=run('spice_enable 200', CONFIG_FAIL='1')
|
||||
check('failed config prevents mutation and returns failure',p.returncode!=0 and not calls)
|
||||
p,calls=run('spice_enable 200', SET_FAIL='1')
|
||||
check('failed VGA update returns failure',p.returncode!=0 and 'enabled' not in p.stdout)
|
||||
p,calls=run('spice_enable 200',VGA_CONFIG='vga: qxl2,memory=64')
|
||||
check('existing multi-monitor QXL remains unchanged',p.returncode==0 and not calls)
|
||||
p,calls=run('spice_info 200 vm-one',PROXMOX_MANAGER_SPICE_ADDR='pve.example')
|
||||
files=list(pathlib.Path(td).glob('vm-*.vv'))
|
||||
check('connect requests authenticated Proxmox spiceproxy',calls=='create /nodes/pve/qemu/200/spiceproxy --output-format json --proxy pve.example\n')
|
||||
check('connection ticket stays out of terminal', 'SECRET_TICKET' not in p.stdout+p.stderr and 'PVE_PROXY_TICKET' not in p.stdout+p.stderr)
|
||||
check('private vv carries TLS certificate, proxy and ticket',len(files)==1 and files[0].stat().st_mode & 0o777 == 0o600 and all(s in files[0].read_text() for s in ('tls-port=61000','password=SECRET_TICKET','proxy=http://pve.example:3128','ca=CERT\\nLINE','host-subject=CN=pve')))
|
||||
for f in files: f.unlink()
|
||||
p,calls=run('spice_info 200 vm-one',PROXY_FAIL='1')
|
||||
check('proxy failure leaves no connection file',p.returncode!=0 and not list(pathlib.Path(td).glob('vm-*.vv')))
|
||||
p,calls=run('spice_info 200 vm-one',SPICE_FIXTURE='{"type":"spice","password":"SECRET_TICKET"}')
|
||||
check('invalid proxy response fails without a ticket leak or file',p.returncode!=0 and 'SECRET_TICKET' not in p.stdout+p.stderr and not list(pathlib.Path(td).glob('vm-*.vv')))
|
||||
raise SystemExit(bool(failures))
|
||||
PY
|
||||
Reference in new issue
Block a user