1
# Copyright (c) 2011 OpenStack, LLC.
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
17
Handles all requests relating to schedulers.
20
from nova import flags
21
from nova import log as logging
25
LOG = logging.getLogger(__name__)
28
def _call_scheduler(method, context, params=None):
29
"""Generic handler for RPC calls to the scheduler.
31
:param params: Optional dictionary of arguments to be passed to the
34
:retval: Result returned by scheduler worker
38
queue = FLAGS.scheduler_topic
39
kwargs = {'method': method, 'args': params}
40
return rpc.call(context, queue, kwargs)
43
def get_host_list(context):
44
"""Return a list of hosts associated with this zone."""
45
return _call_scheduler('get_host_list', context)
48
def get_service_capabilities(context):
49
"""Return aggregated capabilities for all services."""
50
return _call_scheduler('get_service_capabilities', context)
53
def update_service_capabilities(context, service_name, host, capabilities):
54
"""Send an update to all the scheduler services informing them
55
of the capabilities of this service."""
56
kwargs = dict(method='update_service_capabilities',
57
args=dict(service_name=service_name, host=host,
58
capabilities=capabilities))
59
return rpc.fanout_cast(context, 'scheduler', kwargs)
62
def live_migration(context, block_migration, disk_over_commit,
63
instance_id, dest, topic):
64
"""Migrate a server to a new host"""
65
params = {"instance_id": instance_id,
68
"block_migration": block_migration,
69
"disk_over_commit": disk_over_commit}
70
# NOTE(comstud): Call vs cast so we can get exceptions back, otherwise
71
# this call in the scheduler driver doesn't return anything.
72
_call_scheduler("live_migration", context=context, params=params)