Исправлен bare except → except Exception с логированием ошибок Proxmox API
This commit is contained in:
@@ -30,12 +30,22 @@ def create_template(
|
|||||||
|
|
||||||
@router.get("/from-proxmox")
|
@router.get("/from-proxmox")
|
||||||
def list_proxmox_templates(_=Depends(require_admin)):
|
def list_proxmox_templates(_=Depends(require_admin)):
|
||||||
try: vm_tpls = pve.list_vm_templates()
|
"""Ищет VM и LXC шаблоны непосредственно на Proxmox-ноде."""
|
||||||
except: vm_tpls = []
|
try:
|
||||||
try: lxc_tpls = pve.list_lxc_templates()
|
vm_tpls = pve.list_vm_templates()
|
||||||
except: lxc_tpls = []
|
except Exception as exc:
|
||||||
|
import logging
|
||||||
|
logging.getLogger(__name__).warning("Ошибка получения VM-шаблонов из Proxmox: %s", exc)
|
||||||
|
vm_tpls = []
|
||||||
|
try:
|
||||||
|
lxc_tpls = pve.list_lxc_templates()
|
||||||
|
except Exception as exc:
|
||||||
|
import logging
|
||||||
|
logging.getLogger(__name__).warning("Ошибка получения LXC-шаблонов из Proxmox: %s", exc)
|
||||||
|
lxc_tpls = []
|
||||||
return {"vm_templates": vm_tpls, "lxc_templates": lxc_tpls}
|
return {"vm_templates": vm_tpls, "lxc_templates": lxc_tpls}
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/{template_id}")
|
@router.delete("/{template_id}")
|
||||||
def deactivate_template(
|
def deactivate_template(
|
||||||
template_id: int, db: Session = Depends(get_db), _=Depends(require_admin)
|
template_id: int, db: Session = Depends(get_db), _=Depends(require_admin)
|
||||||
|
|||||||
Reference in New Issue
Block a user