If it's not passed in we'll use read it from ssconf.

Signed-off-by: Guido Trotter <[email protected]>
---
 lib/uidpool.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/uidpool.py b/lib/uidpool.py
index b1e2155..30bface 100644
--- a/lib/uidpool.py
+++ b/lib/uidpool.py
@@ -37,6 +37,7 @@ import random
 from ganeti import errors
 from ganeti import constants
 from ganeti import utils
+from ganeti import ssconf
 
 
 def ParseUidPool(value, separator=None):
@@ -222,7 +223,7 @@ class LockedUid(object):
     return "%s" % self._uid
 
 
-def RequestUnusedUid(all_uids):
+def RequestUnusedUid(all_uids=None):
   """Tries to find an unused uid from the uid-pool, locks it and returns it.
 
   Usage pattern:
@@ -254,12 +255,19 @@ def RequestUnusedUid(all_uids):
       <stop the process>
       uidpool.ReleaseUid(uid)
 
-  @param all_uids: a set containing all the user-ids in the user-id pool
+  @type all_uids: set of integers or None (default)
+  @param all_uids: a set containing all the user-ids in the user-id pool, by
+                   default the main cluster uid pool is used
   @return: a LockedUid object representing the unused uid. It's the caller's
            responsibility to unlock the uid once an instance is started with
            this uid.
 
   """
+  if all_uids is None:
+    ss = ssconf.SimpleStore()
+    uid_pool = ParseUidPool(ss.GetUidPool(), separator="\n")
+    all_uids = set(ExpandUidPool(uid_pool))
+
   # Create the lock dir if it's not yet present
   try:
     utils.EnsureDirs([(constants.UIDPOOL_LOCKDIR, 0755)])
-- 
1.7.0.3



-- 
Subscription settings: 
http://groups.google.com/group/ganeti-devel/subscribe?hl=en

Reply via email to