summaryrefslogtreecommitdiffstats
path: root/nova/scheduler
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-09-02 15:15:39 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-09-02 15:15:39 -0700
commit68d8f54e00c153eccd426256a25c8a70ccce2dcc (patch)
tree7fd01d58fa64ba88be43e1078a47deee243fe7f7 /nova/scheduler
parentfd2f45fb28137ddc254b6a863981bf6a3eb3b9e7 (diff)
downloadnova-68d8f54e00c153eccd426256a25c8a70ccce2dcc.tar.gz
nova-68d8f54e00c153eccd426256a25c8a70ccce2dcc.tar.xz
nova-68d8f54e00c153eccd426256a25c8a70ccce2dcc.zip
test for too many instances work
Diffstat (limited to 'nova/scheduler')
-rw-r--r--nova/scheduler/driver.py21
-rw-r--r--nova/scheduler/simple.py25
2 files changed, 23 insertions, 23 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py
index 1618342c0..830f05b13 100644
--- a/nova/scheduler/driver.py
+++ b/nova/scheduler/driver.py
@@ -28,7 +28,7 @@ from nova import exception
from nova import flags
FLAGS = flags.FLAGS
-flags.DEFINE_integer('daemon_down_time',
+flags.DEFINE_integer('service_down_time',
60,
'seconds without heartbeat that determines a '
'compute node to be down')
@@ -43,20 +43,21 @@ class Scheduler(object):
"""
@staticmethod
- def daemon_is_up(daemon):
+ def service_is_up(service):
"""
- Given a daemon, return whether the deamon is considered 'up' by
+ Given a service, return whether the service is considered 'up' by
if it's sent a heartbeat recently
"""
- elapsed = datetime.datetime.now() - daemon['updated_at']
- return elapsed < datetime.timedelta(seconds=FLAGS.daemon_down_time)
+ last_heartbeat = service['updated_at'] or service['created_at']
+ elapsed = datetime.datetime.now() - last_heartbeat
+ return elapsed < datetime.timedelta(seconds=FLAGS.service_down_time)
def hosts_up(self, context, topic):
"""
- Return the list of hosts that have a running daemon for topic
+ Return the list of hosts that have a running service for topic
"""
- daemons = db.daemon_get_all_by_topic(context, topic)
- return [daemon.host
- for daemon in daemons
- if self.daemon_is_up(daemon)]
+ services = db.service_get_all_by_topic(context, topic)
+ return [service.host
+ for service in services
+ if self.service_is_up(service)]
diff --git a/nova/scheduler/simple.py b/nova/scheduler/simple.py
index 294dc1118..832417208 100644
--- a/nova/scheduler/simple.py
+++ b/nova/scheduler/simple.py
@@ -43,14 +43,13 @@ class SimpleScheduler(driver.Scheduler):
Picks a host that is up and has the fewest running instances
"""
- results = db.daemon_get_all_compute_sorted(context)
+ results = db.service_get_all_compute_sorted(context)
for result in results:
- (daemon, instance_count) = result
- print daemon.host, instance_count
+ (service, instance_count) = result
if instance_count >= FLAGS.max_instances:
raise driver.NoValidHost("All hosts have too many instances")
- if self.daemon_is_up(daemon):
- return daemon['host']
+ if self.service_is_up(service):
+ return service['host']
raise driver.NoValidHost("No hosts found")
def pick_volume_host(self, context, volume_id, **_kwargs):
@@ -58,13 +57,13 @@ class SimpleScheduler(driver.Scheduler):
Picks a host that is up and has the fewest volumes
"""
- results = db.daemon_get_all_volume_sorted(context)
+ results = db.service_get_all_volume_sorted(context)
for result in results:
- (daemon, instance_count) = result
+ (service, instance_count) = result
if instance_count >= FLAGS.max_volumes:
raise driver.NoValidHost("All hosts have too many volumes")
- if self.daemon_is_up(daemon):
- return daemon['host']
+ if self.service_is_up(service):
+ return service['host']
raise driver.NoValidHost("No hosts found")
def pick_network_host(self, context, network_id, **_kwargs):
@@ -72,11 +71,11 @@ class SimpleScheduler(driver.Scheduler):
Picks a host that is up and has the fewest networks
"""
- results = db.daemon_get_all_network_sorted(context)
+ results = db.service_get_all_network_sorted(context)
for result in results:
- (daemon, instance_count) = result
+ (service, instance_count) = result
if instance_count >= FLAGS.max_networks:
raise driver.NoValidHost("All hosts have too many networks")
- if self.daemon_is_up(daemon):
- return daemon['host']
+ if self.service_is_up(service):
+ return service['host']
raise driver.NoValidHost("No hosts found")