Make update_service_capabilities() accept a list of capabilities
This makes it possible to send multiple capabilites by single RPC. Change-Id: I7c1b75eada17181c4fe08c55992b34d66276f498
This commit is contained in:
parent
37df2052d7
commit
d6c89b5d8b
@ -255,8 +255,5 @@ class SchedulerDependentManager(Manager):
|
||||
"""
|
||||
if self.last_capabilities:
|
||||
LOG.debug(_('Notifying Schedulers of capabilities ...'))
|
||||
for capability_item in self.last_capabilities:
|
||||
self.scheduler_rpcapi.update_service_capabilities(context,
|
||||
self.service_name, self.host, capability_item)
|
||||
# TODO(NTTdocomo): Make update_service_capabilities() accept a list
|
||||
# of capabilities
|
||||
self.scheduler_rpcapi.update_service_capabilities(context,
|
||||
self.service_name, self.host, self.last_capabilities)
|
||||
|
@ -54,7 +54,7 @@ QUOTAS = quota.QUOTAS
|
||||
class SchedulerManager(manager.Manager):
|
||||
"""Chooses a host to run instances on."""
|
||||
|
||||
RPC_API_VERSION = '2.3'
|
||||
RPC_API_VERSION = '2.4'
|
||||
|
||||
def __init__(self, scheduler_driver=None, *args, **kwargs):
|
||||
if not scheduler_driver:
|
||||
@ -72,10 +72,13 @@ class SchedulerManager(manager.Manager):
|
||||
def update_service_capabilities(self, context, service_name,
|
||||
host, capabilities):
|
||||
"""Process a capability update from a service node."""
|
||||
if capabilities is None:
|
||||
capabilities = {}
|
||||
self.driver.update_service_capabilities(service_name, host,
|
||||
capabilities)
|
||||
if not isinstance(capabilities, list):
|
||||
capabilities = [capabilities]
|
||||
for capability in capabilities:
|
||||
if capability is None:
|
||||
capability = {}
|
||||
self.driver.update_service_capabilities(service_name, host,
|
||||
capability)
|
||||
|
||||
def create_volume(self, context, volume_id, snapshot_id,
|
||||
reservations=None, image_id=None):
|
||||
|
@ -47,6 +47,8 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
||||
2.1 - Add image_id to create_volume()
|
||||
2.2 - Remove reservations argument to create_volume()
|
||||
2.3 - Remove create_volume()
|
||||
2.4 - Change update_service_capabilities()
|
||||
- accepts a list of capabilities
|
||||
'''
|
||||
|
||||
#
|
||||
@ -100,4 +102,5 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
||||
capabilities):
|
||||
self.fanout_cast(ctxt, self.make_msg('update_service_capabilities',
|
||||
service_name=service_name, host=host,
|
||||
capabilities=capabilities))
|
||||
capabilities=capabilities),
|
||||
version='2.4')
|
||||
|
@ -82,4 +82,5 @@ class SchedulerRpcAPITestCase(test.TestCase):
|
||||
def test_update_service_capabilities(self):
|
||||
self._test_scheduler_api('update_service_capabilities',
|
||||
rpc_method='fanout_cast', service_name='fake_name',
|
||||
host='fake_host', capabilities='fake_capabilities')
|
||||
host='fake_host', capabilities='fake_capabilities',
|
||||
version='2.4')
|
||||
|
@ -87,6 +87,28 @@ class SchedulerManagerTestCase(test.TestCase):
|
||||
service_name=service_name, host=host,
|
||||
capabilities=capabilities)
|
||||
|
||||
def test_update_service_multiple_capabilities(self):
|
||||
service_name = 'fake_service'
|
||||
host = 'fake_host'
|
||||
|
||||
self.mox.StubOutWithMock(self.manager.driver,
|
||||
'update_service_capabilities')
|
||||
|
||||
capab1 = {'fake_capability': 'fake_value1'},
|
||||
capab2 = {'fake_capability': 'fake_value2'},
|
||||
capab3 = None
|
||||
self.manager.driver.update_service_capabilities(
|
||||
service_name, host, capab1)
|
||||
self.manager.driver.update_service_capabilities(
|
||||
service_name, host, capab2)
|
||||
# None is converted to {}
|
||||
self.manager.driver.update_service_capabilities(
|
||||
service_name, host, {})
|
||||
self.mox.ReplayAll()
|
||||
self.manager.update_service_capabilities(self.context,
|
||||
service_name=service_name, host=host,
|
||||
capabilities=[capab1, capab2, capab3])
|
||||
|
||||
def test_show_host_resources(self):
|
||||
host = 'fake_host'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user