diff --git a/nova/cmd/manage.py b/nova/cmd/manage.py index dbb091766189..b2c0e3d41648 100644 --- a/nova/cmd/manage.py +++ b/nova/cmd/manage.py @@ -57,6 +57,7 @@ from __future__ import print_function import argparse import os import sys +import urllib import decorator import netaddr @@ -1212,7 +1213,7 @@ class CellCommands(object): is_parent = True values = {'name': name, 'is_parent': is_parent, - 'transport_url': str(transport_url), + 'transport_url': urllib.unquote(str(transport_url)), 'weight_offset': float(woffset), 'weight_scale': float(wscale)} ctxt = context.get_admin_context() diff --git a/nova/tests/unit/test_nova_manage.py b/nova/tests/unit/test_nova_manage.py index 1dfc5f0a9255..cb9986f04958 100644 --- a/nova/tests/unit/test_nova_manage.py +++ b/nova/tests/unit/test_nova_manage.py @@ -552,6 +552,29 @@ class CellCommandsTestCase(test.TestCase): 'weight_scale': 0.0} mock_db_cell_create.assert_called_once_with(ctxt, exp_values) + @mock.patch.object(context, 'get_admin_context') + @mock.patch.object(db, 'cell_create') + def test_create_broker_hosts_with_url_decoding_fix(self, + mock_db_cell_create, + mock_ctxt): + """Test the create function when broker_hosts is + passed + """ + cell_tp_url = "fake://the=user:the=password@127.0.0.1:5432/" + ctxt = mock.sentinel + mock_ctxt.return_value = mock.sentinel + self.commands.create("test", + broker_hosts='127.0.0.1:5432', + woffset=0, wscale=0, + username="the=user", + password="the=password") + exp_values = {'name': "test", + 'is_parent': False, + 'transport_url': cell_tp_url, + 'weight_offset': 0.0, + 'weight_scale': 0.0} + mock_db_cell_create.assert_called_once_with(ctxt, exp_values) + @mock.patch.object(context, 'get_admin_context') @mock.patch.object(db, 'cell_create') def test_create_hostname(self, mock_db_cell_create, mock_ctxt):