~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/scheduler/api.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2011 OpenStack, LLC.
2
 
# All Rights Reserved.
3
 
#
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
7
 
#
8
 
#         http://www.apache.org/licenses/LICENSE-2.0
9
 
#
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
14
 
#    under the License.
15
 
 
16
 
"""
17
 
Handles all requests relating to schedulers.
18
 
"""
19
 
 
20
 
from nova import flags
21
 
from nova import log as logging
22
 
from nova import rpc
23
 
 
24
 
FLAGS = flags.FLAGS
25
 
LOG = logging.getLogger(__name__)
26
 
 
27
 
 
28
 
def _call_scheduler(method, context, params=None):
29
 
    """Generic handler for RPC calls to the scheduler.
30
 
 
31
 
    :param params: Optional dictionary of arguments to be passed to the
32
 
                   scheduler worker
33
 
 
34
 
    :retval: Result returned by scheduler worker
35
 
    """
36
 
    if not params:
37
 
        params = {}
38
 
    queue = FLAGS.scheduler_topic
39
 
    kwargs = {'method': method, 'args': params}
40
 
    return rpc.call(context, queue, kwargs)
41
 
 
42
 
 
43
 
def get_host_list(context):
44
 
    """Return a list of hosts associated with this zone."""
45
 
    return _call_scheduler('get_host_list', context)
46
 
 
47
 
 
48
 
def get_service_capabilities(context):
49
 
    """Return aggregated capabilities for all services."""
50
 
    return _call_scheduler('get_service_capabilities', context)
51
 
 
52
 
 
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)
60
 
 
61
 
 
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,
66
 
              "dest": dest,
67
 
              "topic": topic,
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)