Revision d3b790bb lib/uidpool.py
b/lib/uidpool.py | ||
---|---|---|
222 | 222 |
def RequestUnusedUid(all_uids): |
223 | 223 |
"""Tries to find an unused uid from the uid-pool, locks it and returns it. |
224 | 224 |
|
225 |
Usage pattern: |
|
225 |
Usage pattern |
|
226 |
============= |
|
226 | 227 |
|
227 |
1) When starting a process
|
|
228 |
1. When starting a process::
|
|
228 | 229 |
|
229 | 230 |
from ganeti import ssconf |
230 | 231 |
from ganeti import uidpool |
231 | 232 |
|
232 | 233 |
# Get list of all user-ids in the uid-pool from ssconf |
233 | 234 |
ss = ssconf.SimpleStore() |
234 |
uid_pool = uidpool.ParseUidPool(ss.GetUidPool(), separator="\n") |
|
235 |
uid_pool = uidpool.ParseUidPool(ss.GetUidPool(), separator="\\n")
|
|
235 | 236 |
all_uids = set(uidpool.ExpandUidPool(uid_pool)) |
236 | 237 |
|
237 | 238 |
uid = uidpool.RequestUnusedUid(all_uids) |
... | ... | |
243 | 244 |
# Return the UID to the pool |
244 | 245 |
uidpool.ReleaseUid(uid) |
245 | 246 |
|
246 |
2) Stopping a process
|
|
247 |
2. Stopping a process::
|
|
247 | 248 |
|
248 | 249 |
from ganeti import uidpool |
249 | 250 |
|
Also available in: Unified diff