Revision fdad8c4d lib/uidpool.py

b/lib/uidpool.py
78 78
  return ranges
79 79

  
80 80

  
81
def AddToUidPool(uid_pool, add_uids):
82
  """Add a list of user-ids/user-id ranges to a user-id pool.
83

  
84
  @param uid_pool: a user-id pool (list of integer tuples)
85
  @param add_uids: user-id ranges to be added to the pool
86
                   (list of integer tuples)
87

  
88
  """
89
  for uid_range in add_uids:
90
    if uid_range not in uid_pool:
91
      uid_pool.append(uid_range)
92
  uid_pool.sort()
93

  
94

  
95
def RemoveFromUidPool(uid_pool, remove_uids):
96
  """Remove a list of user-ids/user-id ranges from a user-id pool.
97

  
98
  @param uid_pool: a user-id pool (list of integer tuples)
99
  @param remove_uids: user-id ranges to be removed from the pool
100
                      (list of integer tuples)
101

  
102
  """
103
  for uid_range in remove_uids:
104
    if uid_range not in uid_pool:
105
      raise errors.OpPrereqError(
106
          "User-id range to be removed is not found in the current"
107
          " user-id pool: %s" % uid_range, errors.ECODE_INVAL)
108
    uid_pool.remove(uid_range)
109

  
110

  
81 111
def CheckUidPool(uid_pool):
82 112
  """Sanity check user-id pool range definition values.
83 113

  

Also available in: Unified diff