Merge "Move config 'base_url' to controller node"

This commit is contained in:
Zuul 2018-04-24 07:07:22 +00:00 committed by Gerrit Code Review
commit a78a4bbf66
5 changed files with 21 additions and 21 deletions

View File

@ -147,22 +147,6 @@ Install and configure components
Replace ZUN_PASS with the password you chose for the zun user in the
Identity service.
* In the ``[websocket_proxy]`` section, configure the URL of the websocket
proxy. This URL must match the websocket configuration in controller
node:
.. code-block:: ini
[websocket_proxy]
...
base_url = ws://controller:6784/
.. note::
This URL will be used by end users to access the console of their
containers so make sure this URL is accessible from your intended
users.
* In the ``[oslo_concurrency]`` section, configure the ``lock_path``:
.. code-block:: ini

View File

@ -301,6 +301,13 @@ Install and configure components
...
wsproxy_host = 10.0.0.11
wsproxy_port = 6784
base_url = ws://controller:6784/
.. note::
This ``base_url`` will be used by end users to access the console of
their containers so make sure this URL is accessible from your
intended users and the port ``6784`` is not blocked by firewall.
Replace ``10.0.0.11`` with the management interface IP address
of the controller node if different.

View File

@ -146,7 +146,10 @@ class API(object):
return self.rpcapi.container_update(context, container, *args)
def container_attach(self, context, container):
return self.rpcapi.container_attach(context, container)
token = self.rpcapi.container_attach(context, container)
access_url = '%s?token=%s&uuid=%s' % (
CONF.websocket_proxy.base_url, token, container.uuid)
return access_url
def container_resize(self, context, container, *args):
return self.rpcapi.container_resize(context, container, *args)

View File

@ -800,12 +800,10 @@ class Manager(periodic_task.PeriodicTasks):
try:
url = self.driver.get_websocket_url(context, container)
token = uuidutils.generate_uuid()
access_url = '%s?token=%s&uuid=%s' % (
CONF.websocket_proxy.base_url, token, container.uuid)
container.websocket_url = url
container.websocket_token = token
container.save(context)
return access_url
return token
except Exception as e:
LOG.error("Error occurred while calling "
"get websocket url function: %s",

View File

@ -18,11 +18,15 @@ from zun.common import consts
from zun.common import exception
from zun.compute import api
from zun.compute import container_actions
import zun.conf
from zun import objects
from zun.tests import base
from zun.tests.unit.db import utils
CONF = zun.conf.CONF
class TestAPI(base.TestCase):
def setUp(self):
@ -282,16 +286,20 @@ class TestAPI(base.TestCase):
@mock.patch('zun.objects.ZunService.list_by_binary')
def test_container_attach(self, mock_srv_list,
mock_srv_up, mock_call):
mock_call.return_value = 'fake-token'
container = self.container
srv = objects.ZunService(
self.context,
**utils.get_test_zun_service(host=container.host))
mock_srv_list.return_value = [srv]
mock_srv_up.return_value = True
self.compute_api.container_attach(self.context, container)
url = self.compute_api.container_attach(self.context, container)
mock_call.assert_called_once_with(
container.host, "container_attach",
container=container)
expected_url = '%s?token=%s&uuid=%s' % (
CONF.websocket_proxy.base_url, 'fake-token', container.uuid)
self.assertEqual(expected_url, url)
@mock.patch('zun.compute.rpcapi.API._call')
@mock.patch('zun.api.servicegroup.ServiceGroup.service_is_up')