From d1982a50561f7b35ffc76ce5d45aaec11e76a23c Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Tue, 10 Aug 2010 18:48:33 -0500 Subject: more pylint fixes --- nova/scheduler/base.py | 23 +++++++++++++++++++---- nova/scheduler/bestfit.py | 4 ++++ nova/scheduler/chance.py | 4 ++++ nova/scheduler/service.py | 3 ++- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/nova/scheduler/base.py b/nova/scheduler/base.py index 5c359943e..2872ae6fe 100644 --- a/nova/scheduler/base.py +++ b/nova/scheduler/base.py @@ -35,13 +35,23 @@ class Scheduler(object): The base class that all Scheduler clases should inherit from """ - @property - def compute_nodes(self): + @staticmethod + def compute_nodes(): + """ + Return a list of compute nodes + """ + return [identifier.split(':')[0] for identifier in Redis.instance().smembers("daemons") if (identifier.split(':')[1] == "nova-compute")] - def compute_node_is_up(self, node): + @staticmethod + def compute_node_is_up(node): + """ + Given a node name, return whether the node is considered 'up' by + if it's sent a heartbeat recently + """ + time_str = Redis.instance().hget('%s:%s:%s' % ('daemon', node, 'nova-compute'), 'updated_at') @@ -57,9 +67,14 @@ class Scheduler(object): return (time.time() - epoch_time) < FLAGS.node_down_time def compute_nodes_up(self): - return [node for node in self.compute_nodes + """ + Return the list of compute nodes that are considered 'up' + """ + + return [node for node in self.compute_nodes() if self.compute_node_is_up(node)] def pick_node(self, instance_id, **_kwargs): """You DEFINITELY want to define this in your subclass""" + raise NotImplementedError("Your subclass should define pick_node") diff --git a/nova/scheduler/bestfit.py b/nova/scheduler/bestfit.py index 1bd24456a..bdd4fcbdc 100644 --- a/nova/scheduler/bestfit.py +++ b/nova/scheduler/bestfit.py @@ -27,4 +27,8 @@ class BestFitScheduler(Scheduler): """ def pick_node(self, instance_id, **_kwargs): + """ + Picks a node that is up and is a best fit for the new instance + """ + raise NotImplementedError("BestFitScheduler is not done yet") diff --git a/nova/scheduler/chance.py b/nova/scheduler/chance.py index c57c346f5..719c37674 100644 --- a/nova/scheduler/chance.py +++ b/nova/scheduler/chance.py @@ -29,5 +29,9 @@ class ChanceScheduler(Scheduler): """ def pick_node(self, instance_id, **_kwargs): + """ + Picks a node that is up at random + """ + nodes = self.compute_nodes_up() return nodes[int(random.random() * len(nodes))] diff --git a/nova/scheduler/service.py b/nova/scheduler/service.py index 44b30ecb5..136f262c2 100644 --- a/nova/scheduler/service.py +++ b/nova/scheduler/service.py @@ -49,7 +49,8 @@ class SchedulerService(service.Service): FLAGS.scheduler_type) self._scheduler_class = SCHEDULER_CLASSES[FLAGS.scheduler_type] - def noop(self): + @staticmethod + def noop(): """ simple test of an AMQP message call """ return defer.succeed('PONG') -- cgit