~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/scheduler/driver.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from nova.compute import vm_states
31
31
from nova import db
32
32
from nova import exception
33
 
from nova import flags
34
33
from nova import notifications
35
34
from nova.openstack.common import cfg
36
35
from nova.openstack.common import importutils
52
51
               help='Maximum number of attempts to schedule an instance'),
53
52
    ]
54
53
 
55
 
FLAGS = flags.FLAGS
56
 
FLAGS.register_opts(scheduler_driver_opts)
57
 
 
58
 
flags.DECLARE('instances_path', 'nova.compute.manager')
59
 
flags.DECLARE('libvirt_type', 'nova.virt.libvirt.driver')
 
54
CONF = cfg.CONF
 
55
CONF.register_opts(scheduler_driver_opts)
 
56
CONF.import_opt('compute_topic', 'nova.config')
 
57
CONF.import_opt('instances_path', 'nova.compute.manager')
 
58
CONF.import_opt('libvirt_type', 'nova.virt.libvirt.driver')
60
59
 
61
60
 
62
61
def handle_schedule_error(context, ex, instance_uuid, request_spec):
87
86
                    'scheduler.run_instance', notifier.ERROR, payload)
88
87
 
89
88
 
90
 
def cast_to_volume_host(context, host, method, **kwargs):
91
 
    """Cast request to a volume host queue"""
92
 
 
93
 
    volume_id = kwargs.get('volume_id', None)
94
 
    if volume_id is not None:
95
 
        now = timeutils.utcnow()
96
 
        db.volume_update(context, volume_id,
97
 
                {'host': host, 'scheduled_at': now})
98
 
    rpc.cast(context,
99
 
             rpc.queue_get_for(context, 'volume', host),
100
 
             {"method": method, "args": kwargs})
101
 
    LOG.debug(_("Casted '%(method)s' to volume '%(host)s'") % locals())
102
 
 
103
 
 
104
 
def instance_update_db(context, instance_uuid, host):
105
 
    '''Set the host and scheduled_at fields of an Instance.
 
89
def instance_update_db(context, instance_uuid):
 
90
    '''Clear the host and set the scheduled_at field of an Instance.
106
91
 
107
92
    :returns: An Instance with the updated fields set properly.
108
93
    '''
109
94
    now = timeutils.utcnow()
110
 
    values = {'host': host, 'scheduled_at': now}
 
95
    values = {'host': None, 'scheduled_at': now}
 
96
    return db.instance_update(context, instance_uuid, values)
 
97
 
 
98
 
 
99
def db_instance_node_set(context, instance_uuid, node):
 
100
    '''Set the node field of an Instance.
 
101
 
 
102
    :returns: An Instance with the updated fields set properly.
 
103
    '''
 
104
    values = {'node': node}
111
105
    return db.instance_update(context, instance_uuid, values)
112
106
 
113
107
 
116
110
 
117
111
    instance_uuid = kwargs.get('instance_uuid', None)
118
112
    if instance_uuid:
119
 
        instance_update_db(context, instance_uuid, host)
 
113
        instance_update_db(context, instance_uuid)
120
114
 
121
115
    rpc.cast(context,
122
 
             rpc.queue_get_for(context, 'compute', host),
 
116
             rpc.queue_get_for(context, CONF.compute_topic, host),
123
117
             {"method": method, "args": kwargs})
124
118
    LOG.debug(_("Casted '%(method)s' to compute '%(host)s'") % locals())
125
119
 
126
120
 
127
 
def cast_to_network_host(context, host, method, **kwargs):
128
 
    """Cast request to a network host queue"""
129
 
 
130
 
    rpc.cast(context,
131
 
             rpc.queue_get_for(context, 'network', host),
132
 
             {"method": method, "args": kwargs})
133
 
    LOG.debug(_("Casted '%(method)s' to network '%(host)s'") % locals())
134
 
 
135
 
 
136
121
def cast_to_host(context, topic, host, method, **kwargs):
137
122
    """Generic cast to host"""
138
123
 
139
 
    topic_mapping = {
140
 
            "compute": cast_to_compute_host,
141
 
            "volume": cast_to_volume_host,
142
 
            'network': cast_to_network_host}
 
124
    topic_mapping = {CONF.compute_topic: cast_to_compute_host}
143
125
 
144
126
    func = topic_mapping.get(topic)
145
127
    if func:
146
 
        func(context, host, method, **kwargs)
 
128
        cast_to_compute_host(context, host, method, **kwargs)
147
129
    else:
148
130
        rpc.cast(context,
149
131
                 rpc.queue_get_for(context, topic, host),
175
157
 
176
158
    def __init__(self):
177
159
        self.host_manager = importutils.import_object(
178
 
                FLAGS.scheduler_host_manager)
 
160
                CONF.scheduler_host_manager)
179
161
        self.compute_api = compute_api.API()
180
162
        self.compute_rpcapi = compute_rpcapi.ComputeAPI()
181
163
 
207
189
        msg = _("Driver must implement schedule_run_instance")
208
190
        raise NotImplementedError(msg)
209
191
 
210
 
    def schedule_create_volume(self, context, volume_id, snapshot_id,
211
 
                               image_id):
212
 
        msg = _("Driver must implement schedule_create_volune")
213
 
        raise NotImplementedError(msg)
214
 
 
215
192
    def schedule_live_migration(self, context, instance, dest,
216
193
                                block_migration, disk_over_commit):
217
194
        """Live migration scheduling method.
339
316
 
340
317
        mem_inst = instance_ref['memory_mb']
341
318
        avail = avail - used
342
 
        if avail <= mem_inst:
 
319
        if not mem_inst or avail <= mem_inst:
343
320
            instance_uuid = instance_ref['uuid']
344
321
            reason = _("Unable to migrate %(instance_uuid)s to %(dest)s: "
345
322
                       "Lack of memory(host:%(avail)s <= "