Code tracing in Nova Scheduler (Kilo)
Nova Scheduler in Kilo
We started from nova/nova/scheduler/manage.py
and its function select_destinations
,
that is the beginning of the nova-schduler.
Here is the an example for quick understanding the RabbitMQ Server Side that compared the section of reference for oslo.messaging
in this Blog.
And the Client side is from nova-conductor
.
And the nova/nova/scheduler/manage.py
is here.
class SchedulerManager(manager.Manager):
"""Chooses a host to run instances on."""
target = messaging.Target(version='4.2')
def __init__(self, scheduler_driver=None, *args, **kwargs):
if not scheduler_driver:
scheduler_driver = CONF.scheduler_driver
self.driver = importutils.import_object(scheduler_driver)
super(SchedulerManager, self).__init__(service_name='scheduler',
*args, **kwargs)
self.additional_endpoints.append(_SchedulerManagerV3Proxy(self))
@messaging.expected_exceptions(exception.NoValidHost)
def select_destinations(self, context, request_spec, filter_properties):
This is the result of tracing nova scheduler code.
Adding more filter, you can put it on /schedule/filters
and reconfig nova.conf
to add the new filter you put.
Reference for oslo.messaging
http://www.cinlk.com/2015/12/04/rabbitmq/
import oslo.messaging
from oslo.config import cfg
class TestEndpoint(object):
target = oslo.messaging.Target(namespace='test', version='2.0')
def __init__(self, server):
self.server = server
def foo(self, ctx, id):
return id
oslo.messaging.set_transport_defaults('myexchange')
transport = oslo.messaging.get_transport(cfg.CONF)
target = oslo.messaging.Target(topic='myroutingkey', server='myserver')
endpoints = [TestEndpoint(None)]
server = oslo.messaging.get_rpc_server(transport, target, endpoints,
executor='blocking')
server.start()
server.wait()
No comments:
Post a Comment