summaryrefslogtreecommitdiffstats
path: root/nova/scheduler
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2013-04-10 01:39:16 +0200
committerRussell Bryant <rbryant@redhat.com>2013-04-10 09:07:32 -0400
commit2afb205d515a906a0df28f2376e9b3042a43daf1 (patch)
treee324753ded65c1194bafa56bf2f97655c942bc86 /nova/scheduler
parenta993b2b969bad0785aad02dc2a6f04ac0c675f8d (diff)
downloadnova-2afb205d515a906a0df28f2376e9b3042a43daf1.tar.gz
nova-2afb205d515a906a0df28f2376e9b3042a43daf1.tar.xz
nova-2afb205d515a906a0df28f2376e9b3042a43daf1.zip
Simplify random host choice.
The random Python module provides a handy funcion for choosing a random element from a sequence. Use that instead of a more manual method of accomplishing the same thing. Change-Id: I1908bd5e79b6c21d0dcf7e540143e9b8de478d24
Diffstat (limited to 'nova/scheduler')
-rw-r--r--nova/scheduler/chance.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/nova/scheduler/chance.py b/nova/scheduler/chance.py
index 5bbc3ac3b..6e9688d81 100644
--- a/nova/scheduler/chance.py
+++ b/nova/scheduler/chance.py
@@ -56,7 +56,7 @@ class ChanceScheduler(driver.Scheduler):
msg = _("Could not find another compute")
raise exception.NoValidHost(reason=msg)
- return hosts[int(random.random() * len(hosts))]
+ return random.choice(hosts)
def select_hosts(self, context, request_spec, filter_properties):
"""Selects a set of random hosts."""