Merge "Let nova-manage cell_v2 commands use transport_url from CONF" into stable/newton
This commit is contained in:
commit
c6743ca709
|
@ -1201,12 +1201,16 @@ class CellCommands(object):
|
|||
class CellV2Commands(object):
|
||||
"""Commands for managing cells v2."""
|
||||
|
||||
# TODO(melwitt): Remove this when the oslo.messaging function
|
||||
# for assembling a transport url from ConfigOpts is available
|
||||
@args('--transport-url', metavar='<transport url>', required=True,
|
||||
dest='transport_url',
|
||||
def _validate_transport_url(self, transport_url):
|
||||
transport_url = transport_url or CONF.transport_url
|
||||
if not transport_url:
|
||||
print('Must specify --transport-url if [DEFAULT]/transport_url '
|
||||
'is not set in the configuration file.')
|
||||
return transport_url
|
||||
|
||||
@args('--transport-url', metavar='<transport url>', dest='transport_url',
|
||||
help='The transport url for the cell message queue')
|
||||
def simple_cell_setup(self, transport_url):
|
||||
def simple_cell_setup(self, transport_url=None):
|
||||
"""Simple cellsv2 setup.
|
||||
|
||||
This simplified command is for use by existing non-cells users to
|
||||
|
@ -1218,6 +1222,9 @@ class CellV2Commands(object):
|
|||
if CONF.cells.enable:
|
||||
print('CellsV1 users cannot use this simplified setup command')
|
||||
return 2
|
||||
transport_url = self._validate_transport_url(transport_url)
|
||||
if not transport_url:
|
||||
return 1
|
||||
ctxt = context.RequestContext()
|
||||
try:
|
||||
cell0_mapping = self.map_cell0()
|
||||
|
@ -1430,10 +1437,8 @@ class CellV2Commands(object):
|
|||
|
||||
nova-manage cell_v2 map_cell_and_hosts --config-file <cell nova.conf>
|
||||
"""
|
||||
transport_url = CONF.transport_url or transport_url
|
||||
transport_url = self._validate_transport_url(transport_url)
|
||||
if not transport_url:
|
||||
print('Must specify --transport-url if [DEFAULT]/transport_url '
|
||||
'is not set in the configuration file.')
|
||||
return 1
|
||||
self._map_cell_and_hosts(transport_url, name, verbose)
|
||||
# online_data_migrations established a pattern of 0 meaning everything
|
||||
|
|
|
@ -1348,3 +1348,23 @@ class CellV2CommandsTestCase(test.TestCase):
|
|||
mock_cell_mapping_get_by_uuid.assert_not_called()
|
||||
mock_cell_mapping_get_all.assert_called_once_with(
|
||||
test.MatchType(context.RequestContext))
|
||||
|
||||
def test_validate_transport_url_in_conf(self):
|
||||
from_conf = 'fake://user:pass@host:port/'
|
||||
self.flags(transport_url=from_conf)
|
||||
self.assertEqual(from_conf,
|
||||
self.commands._validate_transport_url(None))
|
||||
|
||||
def test_validate_transport_url_on_command_line(self):
|
||||
from_cli = 'fake://user:pass@host:port/'
|
||||
self.assertEqual(from_cli,
|
||||
self.commands._validate_transport_url(from_cli))
|
||||
|
||||
def test_validate_transport_url_missing(self):
|
||||
self.assertIsNone(self.commands._validate_transport_url(None))
|
||||
|
||||
def test_validate_transport_url_favors_command_line(self):
|
||||
self.flags(transport_url='fake://user:pass@host:port/')
|
||||
from_cli = 'fake://otheruser:otherpass@otherhost:otherport'
|
||||
self.assertEqual(from_cli,
|
||||
self.commands._validate_transport_url(from_cli))
|
||||
|
|
Loading…
Reference in New Issue