diff options
author | Michael H Wilson <geekinutah@gmail.com> | 2012-10-16 15:47:52 -0600 |
---|---|---|
committer | Michael H Wilson <geekinutah@gmail.com> | 2012-10-25 23:51:48 -0600 |
commit | 0bf28bec6097d128aa439b288b249fafcac7dbc0 (patch) | |
tree | 348bde399a5efd964741470af9264195899c228e /nova/scheduler | |
parent | 5d677e204c99fbcf86e0c721ad2fd327a03c35c2 (diff) | |
download | nova-0bf28bec6097d128aa439b288b249fafcac7dbc0.tar.gz nova-0bf28bec6097d128aa439b288b249fafcac7dbc0.tar.xz nova-0bf28bec6097d128aa439b288b249fafcac7dbc0.zip |
Fix hardcoded topic strings with constants.
Replace hardcoded topic strings like 'volume' or 'compute'
with config constants like FLAGS.volume_topic, etc. See
bug #1057831 and bug #1061628.
Change-Id: I817ecc3cbe3245b51a0c047be58d17edfec8a838
Diffstat (limited to 'nova/scheduler')
-rw-r--r-- | nova/scheduler/chance.py | 6 | ||||
-rw-r--r-- | nova/scheduler/driver.py | 8 | ||||
-rw-r--r-- | nova/scheduler/filter_scheduler.py | 11 | ||||
-rw-r--r-- | nova/scheduler/filters/compute_filter.py | 4 | ||||
-rw-r--r-- | nova/scheduler/filters/core_filter.py | 2 | ||||
-rw-r--r-- | nova/scheduler/host_manager.py | 2 |
6 files changed, 18 insertions, 15 deletions
diff --git a/nova/scheduler/chance.py b/nova/scheduler/chance.py index 65806d4d5..e0f351a78 100644 --- a/nova/scheduler/chance.py +++ b/nova/scheduler/chance.py @@ -65,8 +65,8 @@ class ChanceScheduler(driver.Scheduler): for num, instance_uuid in enumerate(instance_uuids): request_spec['instance_properties']['launch_index'] = num try: - host = self._schedule(context, 'compute', request_spec, - filter_properties) + host = self._schedule(context, FLAGS.compute_topic, + request_spec, filter_properties) updated_instance = driver.instance_update_db(context, instance_uuid) self.compute_rpcapi.run_instance(context, @@ -88,7 +88,7 @@ class ChanceScheduler(driver.Scheduler): filter_properties, instance, instance_type, reservations): """Select a target for resize.""" - host = self._schedule(context, 'compute', request_spec, + host = self._schedule(context, FLAGS.compute_topic, request_spec, filter_properties) self.compute_rpcapi.prep_resize(context, image, instance, instance_type, host, reservations) diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 2c2f95e2d..5cbe925c5 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -96,7 +96,7 @@ def cast_to_volume_host(context, host, method, **kwargs): db.volume_update(context, volume_id, {'host': host, 'scheduled_at': now}) rpc.cast(context, - rpc.queue_get_for(context, 'volume', host), + rpc.queue_get_for(context, FLAGS.volume_topic, host), {"method": method, "args": kwargs}) LOG.debug(_("Casted '%(method)s' to volume '%(host)s'") % locals()) @@ -119,7 +119,7 @@ def cast_to_compute_host(context, host, method, **kwargs): instance_update_db(context, instance_uuid) rpc.cast(context, - rpc.queue_get_for(context, 'compute', host), + rpc.queue_get_for(context, FLAGS.compute_topic, host), {"method": method, "args": kwargs}) LOG.debug(_("Casted '%(method)s' to compute '%(host)s'") % locals()) @@ -128,8 +128,8 @@ def cast_to_host(context, topic, host, method, **kwargs): """Generic cast to host""" topic_mapping = { - "compute": cast_to_compute_host, - "volume": cast_to_volume_host} + FLAGS.compute_topic: cast_to_compute_host, + FLAGS.volume_topic: cast_to_volume_host} func = topic_mapping.get(topic) if func: diff --git a/nova/scheduler/filter_scheduler.py b/nova/scheduler/filter_scheduler.py index 7b13ab215..789f252b0 100644 --- a/nova/scheduler/filter_scheduler.py +++ b/nova/scheduler/filter_scheduler.py @@ -69,8 +69,9 @@ class FilterScheduler(driver.Scheduler): notifier.notify(context, notifier.publisher_id("scheduler"), 'scheduler.run_instance.start', notifier.INFO, payload) - weighted_hosts = self._schedule(context, "compute", request_spec, - filter_properties, instance_uuids) + weighted_hosts = self._schedule(context, FLAGS.compute_topic, + request_spec, filter_properties, + instance_uuids) # NOTE(comstud): Make sure we do not pass this through. It # contains an instance of RpcContext that cannot be serialized. @@ -115,7 +116,7 @@ class FilterScheduler(driver.Scheduler): the prep_resize operation to it. """ - hosts = self._schedule(context, 'compute', request_spec, + hosts = self._schedule(context, FLAGS.compute_topic, request_spec, filter_properties, [instance['uuid']]) if not hosts: raise exception.NoValidHost(reason="") @@ -219,7 +220,7 @@ class FilterScheduler(driver.Scheduler): ordered by their fitness. """ elevated = context.elevated() - if topic != "compute": + if topic != FLAGS.compute_topic: msg = _("Scheduler only understands Compute nodes (for now)") raise NotImplementedError(msg) @@ -299,7 +300,7 @@ class FilterScheduler(driver.Scheduler): """ if topic is None: # Schedulers only support compute right now. - topic = "compute" + topic = FLAGS.compute_topic if topic in self.cost_function_cache: return self.cost_function_cache[topic] diff --git a/nova/scheduler/filters/compute_filter.py b/nova/scheduler/filters/compute_filter.py index 2d7c898d6..4af71c7b4 100644 --- a/nova/scheduler/filters/compute_filter.py +++ b/nova/scheduler/filters/compute_filter.py @@ -13,10 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. +from nova import flags from nova.openstack.common import log as logging from nova.scheduler import filters from nova import utils +FLAGS = flags.FLAGS LOG = logging.getLogger(__name__) @@ -27,7 +29,7 @@ class ComputeFilter(filters.BaseHostFilter): def host_passes(self, host_state, filter_properties): """Returns True for only active compute nodes""" instance_type = filter_properties.get('instance_type') - if host_state.topic != 'compute' or not instance_type: + if host_state.topic != FLAGS.compute_topic or not instance_type: return True capabilities = host_state.capabilities service = host_state.service diff --git a/nova/scheduler/filters/core_filter.py b/nova/scheduler/filters/core_filter.py index 98b0930d9..0c4a67dcc 100644 --- a/nova/scheduler/filters/core_filter.py +++ b/nova/scheduler/filters/core_filter.py @@ -37,7 +37,7 @@ class CoreFilter(filters.BaseHostFilter): def host_passes(self, host_state, filter_properties): """Return True if host has sufficient CPU cores.""" instance_type = filter_properties.get('instance_type') - if host_state.topic != 'compute' or not instance_type: + if host_state.topic != FLAGS.compute_topic or not instance_type: return True if not host_state.vcpus_total: diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py index 7ae7a64b8..4727c4706 100644 --- a/nova/scheduler/host_manager.py +++ b/nova/scheduler/host_manager.py @@ -337,7 +337,7 @@ class HostManager(object): with the instance (in case the InstanceType changed since the instance was created).""" - if topic != 'compute': + if topic != FLAGS.compute_topic: raise NotImplementedError(_( "host_manager only implemented for 'compute'")) |