api: Add missing functools.wraps

To preserve function signature.

Change-Id: I1238dff20d6fcce3e3c74b446b547052f297d8b5
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane
2024-02-21 11:03:27 +00:00
parent 3d296ed3d6
commit 91a5db818b

View File

@@ -15,6 +15,8 @@
"""The hosts admin extension."""
import functools
from oslo_config import cfg
from oslo_log import log as logging
from oslo_log import versionutils
@@ -74,13 +76,14 @@ def _list_hosts(req, service=None):
return hosts
def check_host(fn):
def check_host(f):
"""Makes sure that the host exists."""
@functools.wraps(f)
def wrapped(self, req, id, service=None, *args, **kwargs):
listed_hosts = _list_hosts(req, service)
hosts = [h["host_name"] for h in listed_hosts]
if id in hosts:
return fn(self, req, id, *args, **kwargs)
return f(self, req, id, *args, **kwargs)
raise exception.HostNotFound(host=id)
return wrapped