aboutsummaryrefslogtreecommitdiffstats
path: root/api/server.py
diff options
context:
space:
mode:
Diffstat (limited to 'api/server.py')
-rw-r--r--api/server.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/api/server.py b/api/server.py
index 344874c77..c1548ca10 100644
--- a/api/server.py
+++ b/api/server.py
@@ -10,6 +10,7 @@ from __future__ import absolute_import
import inspect
import logging
+import socket
from six.moves import filter
from flasgger import Swagger
@@ -24,6 +25,12 @@ from api.urls import urlpatterns
from api import ApiResource
from yardstick import _init_logging
from yardstick.common import utils
+from yardstick.common import constants as consts
+
+try:
+ from urlparse import urljoin
+except ImportError:
+ from urllib.parse import urljoin
logger = logging.getLogger(__name__)
@@ -64,8 +71,13 @@ def app_wrapper(*args, **kwargs):
return app(*args, **kwargs)
+def get_endpoint(url):
+ ip = socket.gethostbyname(socket.gethostname())
+ return urljoin('http://{}:{}'.format(ip, consts.API_PORT), url)
+
+
for u in urlpatterns:
- api.add_resource(get_resource(u.endpoint), u.url, endpoint=u.endpoint)
+ api.add_resource(get_resource(u.target), u.url, endpoint=get_endpoint(u.url))
if __name__ == '__main__':