From 089e105dd7ec762572ac06794caa7f5543075001 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 27 Jul 2017 13:49:27 -0400 Subject: [PATCH] pybind/mgr: use set_uri hook from dashboard+restful modules No more guessing the URL! Signed-off-by: John Spray --- src/pybind/mgr/dashboard/module.py | 8 ++++++++ src/pybind/mgr/restful/module.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index e2c40a01adfcb..72a31de1658d2 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -22,6 +22,7 @@ import json import sys import time import threading +import socket import cherrypy import jinja2 @@ -894,6 +895,13 @@ class Module(MgrModule): osdmap = self.get_osdmap() log.info("latest osdmap is %d" % osdmap.get_epoch()) + # Publish the URI that others may use to access the service we're + # about to start serving + self.set_uri("http://{0}:{1}/".format( + socket.gethostname() if server_addr == "::" else server_addr, + server_port + )) + static_dir = os.path.join(current_dir, 'static') conf = { "/static": { diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index 1bb6f6e0fb354..6ce610b881f4d 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -10,6 +10,7 @@ import inspect import tempfile import threading import traceback +import socket import common @@ -308,6 +309,13 @@ class Module(MgrModule): if not os.path.isfile(pkey_fname): raise CannotServe('private key %s does not exist' % pkey_fname) + # Publish the URI that others may use to access the service we're + # about to start serving + self.set_uri("https://{0}:{1}/".format( + socket.gethostname() if server_addr == "::" else server_addr, + server_port + )) + # Create the HTTPS werkzeug server serving pecan app self.server = make_server( host=server_addr, -- 2.39.5