Логирование вынесено в top-level import
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import logging
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
@@ -7,6 +8,8 @@ from .. import models, schemas, proxmox_client as pve
|
|||||||
from ..database import get_db
|
from ..database import get_db
|
||||||
from ..deps import get_current_user, require_admin
|
from ..deps import get_current_user, require_admin
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
router = APIRouter(prefix="/templates", tags=["templates"])
|
router = APIRouter(prefix="/templates", tags=["templates"])
|
||||||
|
|
||||||
|
|
||||||
@@ -34,14 +37,12 @@ def list_proxmox_templates(_=Depends(require_admin)):
|
|||||||
try:
|
try:
|
||||||
vm_tpls = pve.list_vm_templates()
|
vm_tpls = pve.list_vm_templates()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
import logging
|
logger.warning("Ошибка получения VM-шаблонов из Proxmox: %s", exc)
|
||||||
logging.getLogger(__name__).warning("Ошибка получения VM-шаблонов из Proxmox: %s", exc)
|
|
||||||
vm_tpls = []
|
vm_tpls = []
|
||||||
try:
|
try:
|
||||||
lxc_tpls = pve.list_lxc_templates()
|
lxc_tpls = pve.list_lxc_templates()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
import logging
|
logger.warning("Ошибка получения LXC-шаблонов из Proxmox: %s", exc)
|
||||||
logging.getLogger(__name__).warning("Ошибка получения LXC-шаблонов из Proxmox: %s", exc)
|
|
||||||
lxc_tpls = []
|
lxc_tpls = []
|
||||||
return {"vm_templates": vm_tpls, "lxc_templates": lxc_tpls}
|
return {"vm_templates": vm_tpls, "lxc_templates": lxc_tpls}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user