[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lnst-developers
Subject:    [PATCH 4/4] SlavePool: sort machines in matching algorithm
From:       Jiri Prochazka <jprochaz () redhat ! com>
Date:       2016-01-28 16:53:39
Message-ID: 1454000019-5736-4-git-send-email-jprochaz () redhat ! com
[Download RAW message or body]

We want to have matching algorithm deterministic. For that we need to
secure, that data are entered in the same order each time. This patch
adds sorting of machines by their id's before they enter matching algorithm
so it shouldn't happen that for same setup, machines are mapped differently
in more runs

Signed-off-by: Jiri Prochazka <jprochaz@redhat.com>
---
 lnst/Controller/SlavePool.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index 21dd3e7..53ad362 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -402,7 +402,7 @@ class SetupMapper(object):
     def reset_match_state(self):
         self._net_label_mapping = {}
         self._machine_stack = []
-        self._unmatched_req_machines = self._mreqs.keys()
+        self._unmatched_req_machines = sorted(self._mreqs.keys())
 
         self._pool_stack = list(self._pools.keys())
         if len(self._pool_stack) > 0:
@@ -410,7 +410,7 @@ class SetupMapper(object):
             self._pool = self._pools[self._pool_name]
 
         self._unmatched_pool_machines = []
-        for p_id, p_machine in self._pool.iteritems():
+        for p_id, p_machine in sorted(self._pool.iteritems()):
             if self._virtual_matching:
                 if "libvirt_domain" in p_machine["params"]:
                     self._unmatched_pool_machines.append(p_id)
@@ -475,7 +475,7 @@ class SetupMapper(object):
                                      self._pool_name)
 
                         self._unmatched_pool_machines = []
-                        for p_id, p_machine in self._pool.iteritems():
+                        for p_id, p_machine in sorted(self._pool.iteritems()):
                             if self._virtual_matching:
                                 if "libvirt_domain" in p_machine["params"]:
                                     self._unmatched_pool_machines.append(p_id)
-- 
2.4.3
_______________________________________________
LNST-developers mailing list
lnst-developers@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/lnst-developers@lists.fedorahosted.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic