~cbehrens/nova/create-num-instances

« back to all changes in this revision

Viewing changes to nova/scheduler/zone_aware_scheduler.py

  • Committer: Chris Behrens
  • Date: 2011-06-21 21:22:46 UTC
  • Revision ID: cbehrens@codestud.com-20110621212246-2uvh208cctttiwli
more work for building x instances at once

Show diffs side-by-side

added added

removed removed

Lines of Context:
254
254
        weighted.sort(key=operator.itemgetter('weight'))
255
255
        return weighted
256
256
 
257
 
    def filter_hosts(self, num, request_spec):
 
257
    def filter_hosts(self, num_instances, request_spec):
258
258
        """Derived classes must override this method and return
259
259
           a list of hosts in [(hostname, capability_dict)] format.
260
260
        """
263
263
        return [(host, services)
264
264
                for host, services in service_states.iteritems()]
265
265
 
266
 
    def weigh_hosts(self, num, request_spec, hosts):
 
266
    def weigh_hosts(self, num_instances, request_spec, hosts):
267
267
        """Derived classes may override this to provide more sophisticated
268
268
        scheduling objectives
269
269
        """
 
270
 
270
271
        # NOTE(sirp): The default logic is the same as the NoopCostFunction
271
 
        return [dict(weight=1, hostname=host) for host, caps in hosts]
 
272
        weighted = []
 
273
        num_hosts = len(hosts)
 
274
        if not num_hosts:
 
275
            return []
 
276
        for i in xrange(num_instances):
 
277
            # We'll just cycle through the hosts if we request more
 
278
            # instances than there are hosts.
 
279
            host, caps = hosts[i % num_hosts]
 
280
            weighted.append(dict(weight=1, hostname=host))
 
281
        return weighted