~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/scheduler/simple.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-01-20 11:54:15 UTC
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: package-import@ubuntu.com-20120120115415-h2ujma9o536o1ut6
Tags: upstream-2012.1~e3~20120120.12170
ImportĀ upstreamĀ versionĀ 2012.1~e3~20120120.12170

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from nova import exception
27
27
from nova.scheduler import driver
28
28
from nova.scheduler import chance
 
29
from nova import utils
29
30
 
30
31
FLAGS = flags.FLAGS
31
32
flags.DEFINE_integer("max_cores", 16,
57
58
 
58
59
        if host and context.is_admin:
59
60
            service = db.service_get_by_args(elevated, host, 'nova-compute')
60
 
            if not self.service_is_up(service):
 
61
            if not utils.service_is_up(service):
61
62
                raise exception.WillNotSchedule(host=host)
62
63
            return host
63
64
 
79
80
                    instance_cores + instance_opts['vcpus'] > FLAGS.max_cores:
80
81
                msg = _("Not enough allocatable CPU cores remaining")
81
82
                raise exception.NoValidHost(reason=msg)
82
 
            if self.service_is_up(service):
 
83
            if utils.service_is_up(service) and not service['disabled']:
83
84
                return service['host']
84
85
        msg = _("Is the appropriate service running?")
85
86
        raise exception.NoValidHost(reason=msg)
120
121
            zone, _x, host = availability_zone.partition(':')
121
122
        if host and context.is_admin:
122
123
            service = db.service_get_by_args(elevated, host, 'nova-volume')
123
 
            if not self.service_is_up(service):
 
124
            if not utils.service_is_up(service):
124
125
                raise exception.WillNotSchedule(host=host)
125
126
            driver.cast_to_volume_host(context, host, 'create_volume',
126
127
                    volume_id=volume_id, **_kwargs)
135
136
            if volume_gigabytes + volume_ref['size'] > FLAGS.max_gigabytes:
136
137
                msg = _("Not enough allocatable volume gigabytes remaining")
137
138
                raise exception.NoValidHost(reason=msg)
138
 
            if self.service_is_up(service):
 
139
            if utils.service_is_up(service) and not service['disabled']:
139
140
                driver.cast_to_volume_host(context, service['host'],
140
141
                        'create_volume', volume_id=volume_id, **_kwargs)
141
142
                return None
142
143
        msg = _("Is the appropriate service running?")
143
144
        raise exception.NoValidHost(reason=msg)
144
 
 
145
 
    def schedule_set_network_host(self, context, *_args, **_kwargs):
146
 
        """Picks a host that is up and has the fewest networks."""
147
 
        elevated = context.elevated()
148
 
 
149
 
        results = db.service_get_all_network_sorted(elevated)
150
 
        for result in results:
151
 
            (service, instance_count) = result
152
 
            if instance_count >= FLAGS.max_networks:
153
 
                msg = _("Not enough allocatable networks remaining")
154
 
                raise exception.NoValidHost(reason=msg)
155
 
            if self.service_is_up(service):
156
 
                driver.cast_to_network_host(context, service['host'],
157
 
                        'set_network_host', **_kwargs)
158
 
                return None
159
 
        msg = _("Is the appropriate service running?")
160
 
        raise exception.NoValidHost(reason=msg)