Skip to content

Commit 7954b27

Browse files
committed
Remove 'nova-manage cell' commands
These are no longer necessary with the removal of cells v1. A check for cells v1 in 'nova-manage cell_v2 simple_cell_setup' is also removed, meaning this can no longer return the '2' exit code. Part of blueprint remove-cells-v1 Change-Id: I8c2bfb31224300bc639d5089c4dfb62143d04b7f Signed-off-by: Stephen Finucane <[email protected]>
1 parent 025e929 commit 7954b27

File tree

4 files changed

+13
-316
lines changed

4 files changed

+13
-316
lines changed

doc/source/cli/nova-manage.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,11 @@ Nova Cells v2
184184
~~~~~~~~~~~~~
185185

186186
``nova-manage cell_v2 simple_cell_setup [--transport-url <transport_url>]``
187-
Setup a fresh cells v2 environment; this should not be used if you
188-
currently have a cells v1 environment. If a transport_url is not
187+
Setup a fresh cells v2 environment. If a ``transport_url`` is not
189188
specified, it will use the one defined by ``[DEFAULT]/transport_url``
190189
in the configuration file. Returns 0 if setup is completed
191190
(or has already been done), 1 if no hosts are reporting (and cannot be
192-
mapped), 1 if the transport url is missing or invalid, and 2 if run in a
193-
cells v1 environment.
191+
mapped) and 1 if the transport url is missing or invalid.
194192

195193
``nova-manage cell_v2 map_cell0 [--database_connection <database_connection>]``
196194
Create a cell mapping to the database connection for the cell0 database.

nova/cmd/manage.py

Lines changed: 3 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -891,159 +891,6 @@ def version(self):
891891
print(migration.db_version(database='api'))
892892

893893

894-
class CellCommands(object):
895-
"""Commands for managing cells v1 functionality."""
896-
897-
# TODO(stephenfin): Remove this when cells v1 is removed
898-
description = ('DEPRECATED: The cell commands, which configure cells v1 '
899-
'functionality, are deprecated as Cells v1 itself has '
900-
'been deprecated. They will be removed in an upcoming '
901-
'release.')
902-
903-
@staticmethod
904-
def _parse_server_string(server_str):
905-
"""Parses the given server_string and returns a tuple of host and port.
906-
If it's not a combination of host part and port, the port element is an
907-
empty string. If the input is invalid expression, return a tuple of two
908-
empty strings.
909-
"""
910-
try:
911-
# First of all, exclude pure IPv6 address (w/o port).
912-
if netaddr.valid_ipv6(server_str):
913-
return (server_str, '')
914-
915-
# Next, check if this is IPv6 address with a port number
916-
# combination.
917-
if server_str.find("]:") != -1:
918-
(address, port) = server_str.replace('[', '', 1).split(']:')
919-
return (address, port)
920-
921-
# Third, check if this is a combination of an address and a port
922-
if server_str.find(':') == -1:
923-
return (server_str, '')
924-
925-
# This must be a combination of an address and a port
926-
(address, port) = server_str.split(':')
927-
return (address, port)
928-
929-
except (ValueError, netaddr.AddrFormatError):
930-
print('Invalid server_string: %s' % server_str)
931-
return ('', '')
932-
933-
def _create_transport_hosts(self, username, password,
934-
broker_hosts=None, hostname=None, port=None):
935-
"""Returns a list of oslo.messaging.TransportHost objects."""
936-
transport_hosts = []
937-
# Either broker-hosts or hostname should be set
938-
if broker_hosts:
939-
hosts = broker_hosts.split(',')
940-
for host in hosts:
941-
host = host.strip()
942-
broker_hostname, broker_port = self._parse_server_string(host)
943-
if not broker_port:
944-
msg = _('Invalid broker_hosts value: %s. It should be'
945-
' in hostname:port format') % host
946-
raise ValueError(msg)
947-
try:
948-
broker_port = int(broker_port)
949-
except ValueError:
950-
msg = _('Invalid port value: %s. It should be '
951-
'an integer') % broker_port
952-
raise ValueError(msg)
953-
transport_hosts.append(
954-
messaging.TransportHost(
955-
hostname=broker_hostname,
956-
port=broker_port,
957-
username=username,
958-
password=password))
959-
else:
960-
try:
961-
port = int(port)
962-
except ValueError:
963-
msg = _("Invalid port value: %s. Should be an integer") % port
964-
raise ValueError(msg)
965-
transport_hosts.append(
966-
messaging.TransportHost(
967-
hostname=hostname,
968-
port=port,
969-
username=username,
970-
password=password))
971-
return transport_hosts
972-
973-
@args('--name', metavar='<name>', help='Name for the new cell')
974-
@args('--cell_type', metavar='<parent|api|child|compute>',
975-
help='Whether the cell is parent/api or child/compute')
976-
@args('--username', metavar='<username>',
977-
help='Username for the message broker in this cell')
978-
@args('--password', metavar='<password>',
979-
help='Password for the message broker in this cell')
980-
@args('--broker_hosts', metavar='<broker_hosts>',
981-
help='Comma separated list of message brokers in this cell. '
982-
'Each Broker is specified as hostname:port with both '
983-
'mandatory. This option overrides the --hostname '
984-
'and --port options (if provided). ')
985-
@args('--hostname', metavar='<hostname>',
986-
help='Address of the message broker in this cell')
987-
@args('--port', metavar='<number>',
988-
help='Port number of the message broker in this cell')
989-
@args('--virtual_host', metavar='<virtual_host>',
990-
help='The virtual host of the message broker in this cell')
991-
@args('--woffset', metavar='<float>')
992-
@args('--wscale', metavar='<float>')
993-
def create(self, name, cell_type='child', username=None, broker_hosts=None,
994-
password=None, hostname=None, port=None, virtual_host=None,
995-
woffset=None, wscale=None):
996-
997-
if cell_type not in ['parent', 'child', 'api', 'compute']:
998-
print("Error: cell type must be 'parent'/'api' or "
999-
"'child'/'compute'")
1000-
return 2
1001-
1002-
# Set up the transport URL
1003-
transport_hosts = self._create_transport_hosts(
1004-
username, password,
1005-
broker_hosts, hostname,
1006-
port)
1007-
transport_url = rpc.get_transport_url()
1008-
transport_url.hosts.extend(transport_hosts)
1009-
transport_url.virtual_host = virtual_host
1010-
1011-
is_parent = False
1012-
if cell_type in ['api', 'parent']:
1013-
is_parent = True
1014-
values = {'name': name,
1015-
'is_parent': is_parent,
1016-
'transport_url': urlparse.unquote(str(transport_url)),
1017-
'weight_offset': float(woffset),
1018-
'weight_scale': float(wscale)}
1019-
ctxt = context.get_admin_context()
1020-
db.cell_create(ctxt, values)
1021-
1022-
@args('--cell_name', metavar='<cell_name>',
1023-
help='Name of the cell to delete')
1024-
def delete(self, cell_name):
1025-
ctxt = context.get_admin_context()
1026-
db.cell_delete(ctxt, cell_name)
1027-
1028-
def list(self):
1029-
ctxt = context.get_admin_context()
1030-
cells = db.cell_get_all(ctxt)
1031-
fmt = "%3s %-10s %-6s %-10s %-15s %-5s %-10s"
1032-
print(fmt % ('Id', 'Name', 'Type', 'Username', 'Hostname',
1033-
'Port', 'VHost'))
1034-
print(fmt % ('-' * 3, '-' * 10, '-' * 6, '-' * 10, '-' * 15,
1035-
'-' * 5, '-' * 10))
1036-
for cell in cells:
1037-
url = rpc.get_transport_url(cell.transport_url)
1038-
host = url.hosts[0] if url.hosts else messaging.TransportHost()
1039-
print(fmt % (cell.id, cell.name,
1040-
'parent' if cell.is_parent else 'child',
1041-
host.username, host.hostname,
1042-
host.port, url.virtual_host))
1043-
print(fmt % ('-' * 3, '-' * 10, '-' * 6, '-' * 10, '-' * 15,
1044-
'-' * 5, '-' * 10))
1045-
1046-
1047894
class CellV2Commands(object):
1048895
"""Commands for managing cells v2."""
1049896

@@ -1085,14 +932,10 @@ def simple_cell_setup(self, transport_url=None):
1085932
"""Simple cellsv2 setup.
1086933
1087934
This simplified command is for use by existing non-cells users to
1088-
configure the default environment. If you are using CellsV1, this
1089-
will not work for you. Returns 0 if setup is completed (or has
1090-
already been done), 1 if no hosts are reporting (and this cannot
1091-
be mapped) and 2 if run in a CellsV1 environment.
935+
configure the default environment. Returns 0 if setup is completed (or
936+
has already been done) and 1 if no hosts are reporting (and this cannot
937+
be mapped).
1092938
"""
1093-
if CONF.cells.enable:
1094-
print('CellsV1 users cannot use this simplified setup command')
1095-
return 2
1096939
transport_url = self._validate_transport_url(transport_url)
1097940
if not transport_url:
1098941
return 1
@@ -2332,7 +2175,6 @@ def sync_aggregates(self, verbose=False):
23322175

23332176
CATEGORIES = {
23342177
'api_db': ApiDbCommands,
2335-
'cell': CellCommands,
23362178
'cell_v2': CellV2Commands,
23372179
'db': DbCommands,
23382180
'floating': FloatingIpCommands,

nova/tests/unit/test_nova_manage.py

Lines changed: 0 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -879,149 +879,6 @@ def test_sync(self, sqla_sync):
879879
version=4, database='api')
880880

881881

882-
class CellCommandsTestCase(test.NoDBTestCase):
883-
def setUp(self):
884-
super(CellCommandsTestCase, self).setUp()
885-
self.output = StringIO()
886-
self.useFixture(fixtures.MonkeyPatch('sys.stdout', self.output))
887-
self.commands = manage.CellCommands()
888-
889-
def test_create_transport_hosts_multiple(self):
890-
"""Test the _create_transport_hosts method
891-
when broker_hosts is set.
892-
"""
893-
brokers = "127.0.0.1:5672,127.0.0.2:5671"
894-
thosts = self.commands._create_transport_hosts(
895-
'guest', 'devstack',
896-
broker_hosts=brokers)
897-
self.assertEqual(2, len(thosts))
898-
self.assertEqual('127.0.0.1', thosts[0].hostname)
899-
self.assertEqual(5672, thosts[0].port)
900-
self.assertEqual('127.0.0.2', thosts[1].hostname)
901-
self.assertEqual(5671, thosts[1].port)
902-
903-
def test_create_transport_hosts_single(self):
904-
"""Test the _create_transport_hosts method when hostname is passed."""
905-
thosts = self.commands._create_transport_hosts('guest', 'devstack',
906-
hostname='127.0.0.1',
907-
port=80)
908-
self.assertEqual(1, len(thosts))
909-
self.assertEqual('127.0.0.1', thosts[0].hostname)
910-
self.assertEqual(80, thosts[0].port)
911-
912-
def test_create_transport_hosts_single_broker(self):
913-
"""Test the _create_transport_hosts method for single broker_hosts."""
914-
thosts = self.commands._create_transport_hosts(
915-
'guest', 'devstack',
916-
broker_hosts='127.0.0.1:5672')
917-
self.assertEqual(1, len(thosts))
918-
self.assertEqual('127.0.0.1', thosts[0].hostname)
919-
self.assertEqual(5672, thosts[0].port)
920-
921-
def test_create_transport_hosts_both(self):
922-
"""Test the _create_transport_hosts method when both broker_hosts
923-
and hostname/port are passed.
924-
"""
925-
thosts = self.commands._create_transport_hosts(
926-
'guest', 'devstack',
927-
broker_hosts='127.0.0.1:5672',
928-
hostname='127.0.0.2', port=80)
929-
self.assertEqual(1, len(thosts))
930-
self.assertEqual('127.0.0.1', thosts[0].hostname)
931-
self.assertEqual(5672, thosts[0].port)
932-
933-
def test_create_transport_hosts_wrong_val(self):
934-
"""Test the _create_transport_hosts method when broker_hosts
935-
is wrongly specified
936-
"""
937-
self.assertRaises(ValueError,
938-
self.commands._create_transport_hosts,
939-
'guest', 'devstack',
940-
broker_hosts='127.0.0.1:5672,127.0.0.1')
941-
942-
def test_create_transport_hosts_wrong_port_val(self):
943-
"""Test the _create_transport_hosts method when port in
944-
broker_hosts is wrongly specified
945-
"""
946-
self.assertRaises(ValueError,
947-
self.commands._create_transport_hosts,
948-
'guest', 'devstack',
949-
broker_hosts='127.0.0.1:')
950-
951-
def test_create_transport_hosts_wrong_port_arg(self):
952-
"""Test the _create_transport_hosts method when port
953-
argument is wrongly specified
954-
"""
955-
self.assertRaises(ValueError,
956-
self.commands._create_transport_hosts,
957-
'guest', 'devstack',
958-
hostname='127.0.0.1', port='ab')
959-
960-
@mock.patch.object(context, 'get_admin_context')
961-
@mock.patch.object(db, 'cell_create')
962-
def test_create_broker_hosts(self, mock_db_cell_create, mock_ctxt):
963-
"""Test the create function when broker_hosts is
964-
passed
965-
"""
966-
cell_tp_url = "fake://guest:[email protected]:5432"
967-
cell_tp_url += ",guest:[email protected]:9999/"
968-
ctxt = mock.sentinel
969-
mock_ctxt.return_value = mock.sentinel
970-
self.commands.create("test",
971-
broker_hosts='127.0.0.1:5432,127.0.0.2:9999',
972-
woffset=0, wscale=0,
973-
username="guest", password="devstack")
974-
exp_values = {'name': "test",
975-
'is_parent': False,
976-
'transport_url': cell_tp_url,
977-
'weight_offset': 0.0,
978-
'weight_scale': 0.0}
979-
mock_db_cell_create.assert_called_once_with(ctxt, exp_values)
980-
981-
@mock.patch.object(context, 'get_admin_context')
982-
@mock.patch.object(db, 'cell_create')
983-
def test_create_broker_hosts_with_url_decoding_fix(self,
984-
mock_db_cell_create,
985-
mock_ctxt):
986-
"""Test the create function when broker_hosts is
987-
passed
988-
"""
989-
cell_tp_url = "fake://the=user:[email protected]:5432/"
990-
ctxt = mock.sentinel
991-
mock_ctxt.return_value = mock.sentinel
992-
self.commands.create("test",
993-
broker_hosts='127.0.0.1:5432',
994-
woffset=0, wscale=0,
995-
username="the=user",
996-
password="the=password")
997-
exp_values = {'name': "test",
998-
'is_parent': False,
999-
'transport_url': cell_tp_url,
1000-
'weight_offset': 0.0,
1001-
'weight_scale': 0.0}
1002-
mock_db_cell_create.assert_called_once_with(ctxt, exp_values)
1003-
1004-
@mock.patch.object(context, 'get_admin_context')
1005-
@mock.patch.object(db, 'cell_create')
1006-
def test_create_hostname(self, mock_db_cell_create, mock_ctxt):
1007-
"""Test the create function when hostname and port is
1008-
passed
1009-
"""
1010-
cell_tp_url = "fake://guest:[email protected]:9999/"
1011-
ctxt = mock.sentinel
1012-
mock_ctxt.return_value = mock.sentinel
1013-
self.commands.create("test",
1014-
hostname='127.0.0.1', port="9999",
1015-
woffset=0, wscale=0,
1016-
username="guest", password="devstack")
1017-
exp_values = {'name': "test",
1018-
'is_parent': False,
1019-
'transport_url': cell_tp_url,
1020-
'weight_offset': 0.0,
1021-
'weight_scale': 0.0}
1022-
mock_db_cell_create.assert_called_once_with(ctxt, exp_values)
1023-
1024-
1025882
@ddt.ddt
1026883
class CellV2CommandsTestCase(test.NoDBTestCase):
1027884
USES_DB_SELF = True
@@ -1560,10 +1417,6 @@ def test_simple_command_multiple(self):
15601417
self._test_migrate_simple_command()
15611418
self._test_migrate_simple_command()
15621419

1563-
def test_simple_command_cellsv1(self):
1564-
self.flags(enable=True, group='cells')
1565-
self.assertEqual(2, self.commands.simple_cell_setup('foo'))
1566-
15671420
def test_instance_verify_no_mapping(self):
15681421
r = self.commands.verify_instance(uuidsentinel.instance)
15691422
self.assertEqual(1, r)

releasenotes/notes/remove-cells-v1-055028c270d06680.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
upgrade:
33
- |
44
The *cells v1* feature has been deprecated since the 16.0.0 Pike release
5-
and has now been removed. The ``nova-cells`` service has been removed. The
6-
*cells v1* specific REST APIs have been removed along with their related
7-
policy rules. Calling these APIs will now result in a ``410 (Gone)`` error
8-
response.
5+
and has now been removed. The ``nova-cells`` service and ``nova-manage
6+
cells`` commands have been removed, while the ``nova-manage cell_v2
7+
simple_cell_setup`` command will no longer check if cells v1 is enabled and
8+
therefore can no longer exit with ``2``.
9+
10+
The *cells v1* specific REST APIs have
11+
been removed along with their related policy rules. Calling these APIs will
12+
now result in a ``410 (Gone)`` error response.
913
1014
* ``GET /os-cells``
1115
* ``POST /os-cells``

0 commit comments

Comments
 (0)