~rackspace-titan/nova/image-service-cleanup

« back to all changes in this revision

Viewing changes to nova/scheduler/base_scheduler.py

  • Committer: Brian Waldon
  • Date: 2011-09-08 19:40:30 UTC
  • mfrom: (1517.1.17 nova)
  • Revision ID: brian.waldon@rackspace.com-20110908194030-8k3z1un277ysngxt
merging trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
        scheduling objectives
56
56
        """
57
57
        # NOTE(sirp): The default logic is the same as the NoopCostFunction
58
 
        return [dict(weight=1, hostname=hostname, capabilities=capabilities)
59
 
                for hostname, capabilities in hosts]
 
58
        hosts = [dict(weight=1, hostname=hostname, capabilities=capabilities)
 
59
                 for hostname, capabilities in hosts]
 
60
 
 
61
        # NOTE(Vek): What we actually need to return is enough hosts
 
62
        #            for all the instances!
 
63
        num_instances = request_spec.get('num_instances', 1)
 
64
        instances = []
 
65
        while num_instances > len(hosts):
 
66
            instances.extend(hosts)
 
67
            num_instances -= len(hosts)
 
68
        if num_instances > 0:
 
69
            instances.extend(hosts[:num_instances])
 
70
 
 
71
        return instances