conf: remove *_topic config opts

All RPC topic opts were deprecated in Ocata.
This patch removes all *_topic opts from the code.

Change-Id: I41a6be48380999c49d6db3ee5221174a41014002
Implements: blueprint centralize-config-options-pike
This commit is contained in:
Stephen Finucane 2017-06-30 15:12:04 +01:00 committed by Mike Perez
parent 247f9b8120
commit 6ef30d5078
29 changed files with 69 additions and 144 deletions

View File

@ -21,6 +21,7 @@ import webob.exc
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova import compute
from nova.compute import rpcapi as compute_rpcapi
import nova.conf
from nova.i18n import _
from nova.policies import instance_usage_audit_log as iual_policies
@ -72,7 +73,7 @@ class InstanceUsageAuditLogController(wsgi.Controller):
begin, end)
# We do this in this way to include disabled compute services,
# which can have instances on them. (mdragon)
filters = {'topic': CONF.compute_topic}
filters = {'topic': compute_rpcapi.RPC_TOPIC}
services = self.host_api.service_get_all(context, filters=filters)
hosts = set(serv['host'] for serv in services)
seen_hosts = set()

View File

@ -30,6 +30,7 @@ from nova.cells import messaging
from nova.cells import rpc_driver as cells_rpc_driver
from nova.cells import state as cells_state
from nova.cells import utils as cells_utils
from nova.compute import rpcapi as compute_rpcapi
import nova.conf
from nova import context
from nova import exception
@ -312,7 +313,7 @@ class CellsManager(manager.Manager):
@oslo_messaging.expected_exceptions(exception.CellRoutingInconsistency)
def proxy_rpc_to_manager(self, ctxt, topic, rpc_message, call, timeout):
"""Proxy an RPC message as-is to a manager."""
compute_topic = CONF.compute_topic
compute_topic = compute_rpcapi.RPC_TOPIC
cell_and_host = topic[len(compute_topic) + 1:]
cell_name, host_name = cells_utils.split_cell_and_item(cell_and_host)
response = self.msg_runner.proxy_rpc_to_manager(ctxt, cell_name,

View File

@ -25,6 +25,7 @@ from oslo_privsep import priv_context
from oslo_reports import guru_meditation_report as gmr
from nova.cmd import common as cmd_common
from nova.compute import rpcapi as compute_rpcapi
from nova.conductor import rpcapi as conductor_rpcapi
import nova.conf
from nova import config
@ -53,6 +54,6 @@ def main():
objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()
server = service.Service.create(binary='nova-compute',
topic=CONF.compute_topic)
topic=compute_rpcapi.RPC_TOPIC)
service.serve(server)
service.wait()

View File

@ -22,6 +22,7 @@ from oslo_log import log as logging
from oslo_reports import guru_meditation_report as gmr
from nova import config
from nova.console import rpcapi as console_rpcapi
from nova import objects
from nova import service
from nova import version
@ -37,6 +38,6 @@ def main():
gmr.TextGuruMeditation.setup_autorun(version)
server = service.Service.create(binary='nova-console',
topic=CONF.console_topic)
topic=console_rpcapi.RPC_TOPIC)
service.serve(server)
service.wait()

View File

@ -22,6 +22,7 @@ from oslo_reports import guru_meditation_report as gmr
import nova.conf
from nova import config
from nova.consoleauth import rpcapi
from nova import objects
from nova import service
from nova import version
@ -37,6 +38,6 @@ def main():
gmr.TextGuruMeditation.setup_autorun(version)
server = service.Service.create(binary='nova-consoleauth',
topic=CONF.consoleauth_topic)
topic=rpcapi.RPC_TOPIC)
service.serve(server)
service.wait()

View File

@ -25,6 +25,7 @@ from nova.cmd import common as cmd_common
from nova.conductor import rpcapi as conductor_rpcapi
import nova.conf
from nova import config
from nova.network import rpcapi as network_rpcapi
from nova import objects
from nova.objects import base as objects_base
from nova import service
@ -55,7 +56,7 @@ def main():
LOG.warning('Nova network is deprecated and will be removed '
'in the future')
server = service.Service.create(binary='nova-network',
topic=CONF.network_topic,
topic=network_rpcapi.RPC_TOPIC,
manager=CONF.network_manager)
service.serve(server)
service.wait()

View File

@ -24,6 +24,7 @@ from oslo_reports import guru_meditation_report as gmr
import nova.conf
from nova import config
from nova import objects
from nova.scheduler import rpcapi as scheduler_rpcapi
from nova import service
from nova import utils
from nova import version
@ -41,6 +42,6 @@ def main():
gmr.TextGuruMeditation.setup_autorun(version)
server = service.Service.create(binary='nova-scheduler',
topic=CONF.scheduler_topic)
topic=scheduler_rpcapi.RPC_TOPIC)
service.serve(server)
service.wait()

View File

@ -67,6 +67,7 @@ from nova.compute.utils import wrap_instance_event
from nova.compute import vm_states
from nova import conductor
import nova.conf
from nova.console import rpcapi as console_rpcapi
import nova.context
from nova import exception
from nova import exception_wrapper
@ -1178,7 +1179,7 @@ class ComputeManager(manager.Manager):
"""
# TODO(mdragon): perhaps make this variable by console_type?
return '%s.%s' % (CONF.console_topic, CONF.console_host)
return '%s.%s' % (console_rpcapi.RPC_TOPIC, CONF.console_host)
@wrap_exception()
def get_console_pool_info(self, context, console_type):

View File

@ -31,6 +31,7 @@ from nova import profiler
from nova import rpc
CONF = nova.conf.CONF
RPC_TOPIC = "compute"
LOG = logging.getLogger(__name__)
LAST_VERSION = None
@ -341,7 +342,7 @@ class ComputeAPI(object):
def __init__(self):
super(ComputeAPI, self).__init__()
target = messaging.Target(topic=CONF.compute_topic, version='4.0')
target = messaging.Target(topic=RPC_TOPIC, version='4.0')
upgrade_level = CONF.upgrade_levels.compute
if upgrade_level == 'auto':
version_cap = self._determine_version_cap(target)

View File

@ -1050,28 +1050,6 @@ Related options:
""")
]
rpcapi_opts = [
cfg.StrOpt("compute_topic",
default="compute",
deprecated_for_removal=True,
deprecated_since="15.0.0",
deprecated_reason="""
There is no need to let users choose the RPC topic for all services - there
is little gain from this. Furthermore, it makes it really easy to break Nova
by using this option.
""",
help="""
This is the message queue topic that the compute service 'listens' on. It is
used when the compute service is started up to configure the queue, and
whenever an RPC call to the compute service is made.
Possible values:
* Any string, but there is almost never any reason to ever change this value
from its default of 'compute'.
"""),
]
db_opts = [
cfg.StrOpt('osapi_compute_unique_server_name_scope',
default='',
@ -1149,7 +1127,6 @@ ALL_OPTS = (compute_opts +
timeout_opts +
running_deleted_opts +
instance_cleaning_opts +
rpcapi_opts +
db_opts)

View File

@ -25,28 +25,6 @@ Note: in configuration of every compute is a ``console_host`` option,
which allows to select the console proxy service to connect to.
""")
default_opts = [
cfg.StrOpt('console_topic',
default='console',
deprecated_for_removal=True,
deprecated_since='15.0.0',
deprecated_reason="""
There is no need to let users choose the RPC topic for all services - there
is little gain from this. Furthermore, it makes it really easy to break Nova
by using this option.
""",
help="""
Represents the message queue topic name used by nova-console
service when communicating via the AMQP server. The Nova API uses a message
queue to communicate with nova-console to retrieve a console URL for that
host.
Possible values:
* A string representing topic exchange name
""")
]
console_opts = [
cfg.ListOpt('allowed_origins',
default=[],
@ -69,11 +47,9 @@ Possible values:
def register_opts(conf):
conf.register_group(console_group)
conf.register_opts(console_opts, group=console_group)
conf.register_opts(default_opts)
def list_opts():
return {
console_group: console_opts,
'DEFAULT': default_opts,
}

View File

@ -16,29 +16,6 @@
from oslo_config import cfg
default_opts = [
cfg.StrOpt('consoleauth_topic',
default='consoleauth',
deprecated_for_removal=True,
deprecated_since='15.0.0',
deprecated_reason="""
There is no need to let users choose the RPC topic for all services - there
is little gain from this. Furthermore, it makes it really easy to break Nova
by using this option.
""",
help="""
This option allows you to change the message topic used by nova-consoleauth
service when communicating via the AMQP server. Nova Console Authentication
server authenticates nova consoles. Users can then access their instances
through VNC clients. The Nova API service uses a message queue to
communicate with nova-consoleauth to get a VNC console.
Possible Values:
* 'consoleauth' (default) or Any string representing topic exchange name.
"""),
]
consoleauth_group = cfg.OptGroup(
name='consoleauth',
title='Console auth options')
@ -60,12 +37,9 @@ considered expired. Expired tokens are then deleted.
def register_opts(conf):
conf.register_opts(default_opts)
conf.register_group(consoleauth_group)
conf.register_opts(consoleauth_opts, group=consoleauth_group)
def list_opts():
return {'DEFAULT': default_opts,
consoleauth_group: consoleauth_opts}
return {consoleauth_group: consoleauth_opts}

View File

@ -1185,16 +1185,6 @@ Related options:
]
rpcapi_opts = [
cfg.StrOpt('network_topic',
default='network',
deprecated_for_removal=True,
deprecated_since='15.0.0',
deprecated_reason="""
There is no need to let users choose the RPC topic for all services - there
is little gain from this. Furthermore, it makes it really easy to break Nova
by using this option.
""",
help='The topic network nodes listen on'),
cfg.BoolOpt('multi_host',
default=False,
deprecated_for_removal=True,

View File

@ -15,29 +15,6 @@
from oslo_config import cfg
default_opts = [
cfg.StrOpt("scheduler_topic",
default="scheduler",
deprecated_for_removal=True,
deprecated_since="15.0.0",
deprecated_reason="""
There is no need to let users choose the RPC topic for all services - there
is little gain from this. Furthermore, it makes it really easy to break Nova
by using this option.
""",
help="""
Scheduler message queue topic.
This is the message queue topic that the scheduler 'listens' on. It is used
when the scheduler service is started up to configure the queue, and whenever
an RPC call to the scheduler is made. There is almost never any reason to ever
change this value.
Possible values:
* A valid AMQP topic name
"""),
]
scheduler_group = cfg.OptGroup(name="scheduler",
title="Scheduler configuration")
@ -922,8 +899,6 @@ Related options:
def register_opts(conf):
conf.register_opts(default_opts)
conf.register_group(scheduler_group)
conf.register_opts(scheduler_opts, group=scheduler_group)

View File

@ -36,7 +36,7 @@ class API(base.Base):
def delete_console(self, context, instance_uuid, console_uuid):
console = self.db.console_get(context, console_uuid, instance_uuid)
rpcapi = console_rpcapi.ConsoleAPI(topic=CONF.console_topic,
rpcapi = console_rpcapi.ConsoleAPI(topic=console_rpcapi.RPC_TOPIC,
server=console['pool']['host'])
rpcapi.remove_console(context, console['id'])

View File

@ -23,6 +23,7 @@ from nova import profiler
from nova import rpc
CONF = nova.conf.CONF
RPC_TOPIC = "console"
@profiler.trace_cls("rpc")
@ -61,7 +62,7 @@ class ConsoleAPI(object):
def __init__(self, topic=None, server=None):
super(ConsoleAPI, self).__init__()
topic = topic if topic else CONF.console_topic
topic = topic if topic else RPC_TOPIC
target = messaging.Target(topic=topic, server=server, version='2.0')
version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.console,
CONF.upgrade_levels.console)

View File

@ -23,6 +23,7 @@ from nova import profiler
from nova import rpc
CONF = nova.conf.CONF
RPC_TOPIC = 'consoleauth'
@profiler.trace_cls("rpc")
@ -68,7 +69,7 @@ class ConsoleAuthAPI(object):
def __init__(self):
super(ConsoleAuthAPI, self).__init__()
target = messaging.Target(topic=CONF.consoleauth_topic, version='2.1')
target = messaging.Target(topic=RPC_TOPIC, version='2.1')
version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.consoleauth,
CONF.upgrade_levels.consoleauth)
self.client = rpc.get_client(target, version_cap=version_cap)

View File

@ -27,6 +27,7 @@ from nova import rpc
CONF = nova.conf.CONF
RPC_TOPIC = 'network'
@profiler.trace_cls("rpc")
@ -128,7 +129,7 @@ class NetworkAPI(object):
def __init__(self, topic=None):
super(NetworkAPI, self).__init__()
topic = topic or CONF.network_topic
topic = topic or RPC_TOPIC
target = messaging.Target(topic=topic, version='1.0')
version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.network,
CONF.upgrade_levels.network)

View File

@ -21,6 +21,7 @@ Chance (Random) Scheduler implementation
import random
from nova.compute import rpcapi as compute_rpcapi
import nova.conf
from nova import exception
from nova.i18n import _
@ -67,7 +68,8 @@ class ChanceScheduler(driver.Scheduler):
# and limiting the destination scope to a single requested cell
dests = []
for i in range(num_instances):
host = self._schedule(context, CONF.compute_topic, spec_obj)
host = self._schedule(context, compute_rpcapi.RPC_TOPIC,
spec_obj)
host_state = self.host_manager.host_state_cls(host, None, None)
dests.append(host_state)

View File

@ -24,6 +24,7 @@ from nova import profiler
from nova import rpc
CONF = nova.conf.CONF
RPC_TOPIC = "scheduler"
@profiler.trace_cls("rpc")
@ -112,7 +113,7 @@ class SchedulerAPI(object):
def __init__(self):
super(SchedulerAPI, self).__init__()
target = messaging.Target(topic=CONF.scheduler_topic, version='4.0')
target = messaging.Target(topic=RPC_TOPIC, version='4.0')
version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.scheduler,
CONF.upgrade_levels.scheduler)
serializer = objects_base.NovaObjectSerializer()

View File

@ -24,6 +24,7 @@ from six.moves import range
from nova.cells import messaging
from nova.cells import utils as cells_utils
from nova.compute import rpcapi as compute_rpcapi
import nova.conf
from nova import context
from nova import objects
@ -388,7 +389,7 @@ class CellsManagerClassTestCase(test.NoDBTestCase):
'proxy_rpc_to_manager')
fake_response = self._get_fake_response()
cell_and_host = cells_utils.cell_with_item('fake-cell', 'fake-host')
topic = "%s.%s" % (CONF.compute_topic, cell_and_host)
topic = "%s.%s" % (compute_rpcapi.RPC_TOPIC, cell_and_host)
self.msg_runner.proxy_rpc_to_manager(self.ctxt, 'fake-cell',
'fake-host', topic, 'fake-rpc-msg',
True, -1).AndReturn(fake_response)

View File

@ -112,7 +112,8 @@ class ComputeRpcAPITestCase(test.NoDBTestCase):
rpcapi = kwargs.pop('rpcapi_class', compute_rpcapi.ComputeAPI)()
self.assertIsNotNone(rpcapi.router)
self.assertEqual(rpcapi.router.target.topic, CONF.compute_topic)
self.assertEqual(rpcapi.router.target.topic,
compute_rpcapi.RPC_TOPIC)
# This test wants to run the real prepare function, so must use
# a real client object

View File

@ -17,14 +17,11 @@ Unit Tests for nova.console.rpcapi
"""
import mock
from oslo_config import cfg
from nova.console import rpcapi as console_rpcapi
from nova import context
from nova import test
CONF = cfg.CONF
class ConsoleRpcAPITestCase(test.NoDBTestCase):
def _test_console_api(self, method, rpc_method, **kwargs):
@ -32,7 +29,8 @@ class ConsoleRpcAPITestCase(test.NoDBTestCase):
rpcapi = console_rpcapi.ConsoleAPI()
self.assertIsNotNone(rpcapi.client)
self.assertEqual(rpcapi.client.target.topic, CONF.console_topic)
self.assertEqual(rpcapi.client.target.topic,
console_rpcapi.RPC_TOPIC)
orig_prepare = rpcapi.client.prepare

View File

@ -17,14 +17,11 @@ Unit Tests for nova.consoleauth.rpcapi
"""
import mock
from oslo_config import cfg
from nova.consoleauth import rpcapi as consoleauth_rpcapi
from nova import context
from nova import test
CONF = cfg.CONF
class ConsoleAuthRpcAPITestCase(test.NoDBTestCase):
DROPPED_ARG = object()
@ -36,7 +33,8 @@ class ConsoleAuthRpcAPITestCase(test.NoDBTestCase):
rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
self.assertIsNotNone(rpcapi.client)
self.assertEqual(rpcapi.client.target.topic, CONF.consoleauth_topic)
self.assertEqual(rpcapi.client.target.topic,
consoleauth_rpcapi.RPC_TOPIC)
orig_prepare = rpcapi.client.prepare

View File

@ -49,6 +49,7 @@ from sqlalchemy import sql
from sqlalchemy import Table
from nova import block_device
from nova.compute import rpcapi as compute_rpcapi
from nova.compute import task_states
from nova.compute import vm_states
import nova.conf
@ -7832,8 +7833,8 @@ class ComputeNodeTestCase(test.TestCase, ModelsObjectComparatorMixin):
super(ComputeNodeTestCase, self).setUp()
self.ctxt = context.get_admin_context()
self.service_dict = dict(host='host1', binary='nova-compute',
topic=CONF.compute_topic, report_count=1,
disabled=False)
topic=compute_rpcapi.RPC_TOPIC,
report_count=1, disabled=False)
self.service = db.service_create(self.ctxt, self.service_dict)
self.compute_node_dict = dict(vcpus=2, memory_mb=1024, local_gb=2048,
uuid=uuidutils.generate_uuid(),
@ -7898,8 +7899,8 @@ class ComputeNodeTestCase(test.TestCase, ModelsObjectComparatorMixin):
def test_compute_node_get_all_by_pagination(self):
service_dict = dict(host='host2', binary='nova-compute',
topic=CONF.compute_topic, report_count=1,
disabled=False)
topic=compute_rpcapi.RPC_TOPIC,
report_count=1, disabled=False)
service = db.service_create(self.ctxt, service_dict)
compute_node_dict = dict(vcpus=2, memory_mb=1024, local_gb=2048,
uuid=uuidsentinel.fake_compute_node,
@ -8156,8 +8157,8 @@ class ComputeNodeTestCase(test.TestCase, ModelsObjectComparatorMixin):
def test_compute_node_statistics(self):
service_dict = dict(host='hostA', binary='nova-compute',
topic=CONF.compute_topic, report_count=1,
disabled=False)
topic=compute_rpcapi.RPC_TOPIC,
report_count=1, disabled=False)
service = db.service_create(self.ctxt, service_dict)
# Define the various values for the new compute node
new_vcpus = 4
@ -8234,7 +8235,7 @@ class ComputeNodeTestCase(test.TestCase, ModelsObjectComparatorMixin):
def test_compute_node_statistics_disabled_service(self):
serv = db.service_get_by_host_and_topic(
self.ctxt, 'host1', CONF.compute_topic)
self.ctxt, 'host1', compute_rpcapi.RPC_TOPIC)
db.service_update(self.ctxt, serv['id'], {'disabled': True})
stats = db.compute_node_statistics(self.ctxt)
self.assertEqual(stats.pop('count'), 0)

View File

@ -45,7 +45,8 @@ class NetworkRpcAPITestCase(test.NoDBTestCase):
rpcapi = network_rpcapi.NetworkAPI()
self.assertIsNotNone(rpcapi.client)
self.assertEqual(CONF.network_topic, rpcapi.client.target.topic)
self.assertEqual(network_rpcapi.RPC_TOPIC,
rpcapi.client.target.topic)
expected_retval = 'foo' if rpc_method == 'call' else None
expected_version = kwargs.pop('version', None)

View File

@ -35,7 +35,8 @@ class SchedulerRpcAPITestCase(test.NoDBTestCase):
rpcapi = scheduler_rpcapi.SchedulerAPI()
self.assertIsNotNone(rpcapi.client)
self.assertEqual(rpcapi.client.target.topic, CONF.scheduler_topic)
self.assertEqual(rpcapi.client.target.topic,
scheduler_rpcapi.RPC_TOPIC)
expected_retval = 'foo' if rpc_method == 'call' else None
expected_version = kwargs.pop('version', None)

View File

@ -19,6 +19,7 @@ Test the base rpc API.
"""
from nova import baserpc
from nova.compute import rpcapi as compute_rpcapi
import nova.conf
from nova import context
from nova import test
@ -36,7 +37,7 @@ class BaseAPITestCase(test.TestCase):
self.project_id)
self.conductor = self.start_service('conductor')
self.compute = self.start_service('compute')
self.base_rpcapi = baserpc.BaseAPI(CONF.compute_topic)
self.base_rpcapi = baserpc.BaseAPI(compute_rpcapi.RPC_TOPIC)
def test_ping(self):
res = self.base_rpcapi.ping(self.context, 'foo')

View File

@ -0,0 +1,16 @@
---
upgrade:
- |
Configuration options related to RPC topics were deprecated in the past
releases and are now completly removed from nova. There was no need to
let users choose the RPC topics for all services. There was little
benefit from this and it made it really easy to break Nova by changing
the value of topic options.
The following options are removed:
- ``compute_topic``
- ``console_topic``
- ``consoleauth_topic``
- ``scheduler_topic``
- ``network_topic``