merged trunk and cleaned up test

This commit is contained in:
Vishvananda Ishaya
2010-09-02 14:14:52 -07:00
4 changed files with 6 additions and 6 deletions

View File

@@ -59,7 +59,6 @@ def daemon_get_all_compute_sorted(_context):
# FROM daemons LEFT OUTER JOIN
# (SELECT host, count(*) AS instance_count
# FROM instances GROUP BY host) AS inst_count
print 'instance', models.Instance.find(1).host
subq = session.query(models.Instance.host,
func.count('*').label('instance_count')) \
.filter_by(deleted=False) \

View File

@@ -46,6 +46,7 @@ class SimpleScheduler(driver.Scheduler):
results = db.daemon_get_all_compute_sorted(context)
for result in results:
(daemon, instance_count) = result
print daemon.host, instance_count
if instance_count >= FLAGS.max_instances:
raise driver.NoValidHost("All hosts have too many instances")
if self.daemon_is_up(daemon):

View File

@@ -44,13 +44,12 @@ flags.DEFINE_integer('report_interval', 10,
class Service(object, service.Service):
"""Base class for workers that run on hosts."""
def __init__(self, host, binary, topic, manager,
db_driver=None, *args, **kwargs):
def __init__(self, host, binary, topic, manager, *args, **kwargs):
self.host = host
self.binary = binary
self.topic = topic
manager_class = utils.import_class(manager)
self.manager = manager_class(host, db_driver)
self.manager = manager_class(host=host, *args, **kwargs)
self.model_disconnected = False
super(Service, self).__init__(*args, **kwargs)

View File

@@ -110,8 +110,9 @@ class SchedulerTestCase(test.TrialTestCase):
FLAGS.compute_manager)
instance_ids = []
for index in xrange(FLAGS.max_instances):
instance_ids.append(self._create_instance())
service1.run_instance(self.context, instance_ids[index])
instance_id = self._create_instance()
service1.run_instance(self.context, instance_id)
instance_ids.append(instance_id)
instance_id = self._create_instance()
self.assertRaises(driver.NoValidHost,
self.scheduler.driver.pick_compute_host,