]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr: use set_uri hook from dashboard+restful modules
authorJohn Spray <john.spray@redhat.com>
Thu, 27 Jul 2017 17:49:27 +0000 (13:49 -0400)
committerJohn Spray <john.spray@redhat.com>
Wed, 1 Nov 2017 12:20:20 +0000 (08:20 -0400)
No more guessing the URL!

Signed-off-by: John Spray <john.spray@redhat.com>
src/pybind/mgr/dashboard/module.py
src/pybind/mgr/restful/module.py

index e2c40a01adfcbee33f3d77d71ec69ba10a046bec..72a31de1658d2c9eff87f59118c160ae2bb7be0d 100644 (file)
@@ -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": {
index 1bb6f6e0fb354ce2690edee4458fbee2b66772a3..6ce610b881f4d06d98ae0e25fca3e84721dfeb47 100644 (file)
@@ -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,