Revision 0fbae49a
b/lib/config.py | ||
---|---|---|
43 | 43 |
from ganeti import rpc |
44 | 44 |
from ganeti import objects |
45 | 45 |
from ganeti import serializer |
46 |
from ganeti import uidpool |
|
46 | 47 |
|
47 | 48 |
|
48 | 49 |
_config_lock = locking.SharedLock() |
... | ... | |
1372 | 1373 |
|
1373 | 1374 |
hypervisor_list = fn(cluster.enabled_hypervisors) |
1374 | 1375 |
|
1376 |
uid_pool = uidpool.FormatUidPool(cluster.uid_pool, separator="\n") |
|
1377 |
|
|
1375 | 1378 |
return { |
1376 | 1379 |
constants.SS_CLUSTER_NAME: cluster.cluster_name, |
1377 | 1380 |
constants.SS_CLUSTER_TAGS: cluster_tags, |
... | ... | |
1390 | 1393 |
constants.SS_RELEASE_VERSION: constants.RELEASE_VERSION, |
1391 | 1394 |
constants.SS_HYPERVISOR_LIST: hypervisor_list, |
1392 | 1395 |
constants.SS_MAINTAIN_NODE_HEALTH: str(cluster.maintain_node_health), |
1396 |
constants.SS_UID_POOL: uid_pool, |
|
1393 | 1397 |
} |
1394 | 1398 |
|
1395 | 1399 |
@locking.ssynchronized(_config_lock, shared=1) |
b/lib/constants.py | ||
---|---|---|
672 | 672 |
SS_RELEASE_VERSION = "release_version" |
673 | 673 |
SS_HYPERVISOR_LIST = "hypervisor_list" |
674 | 674 |
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health" |
675 |
SS_UID_POOL = "uid_pool" |
|
675 | 676 |
|
676 | 677 |
# cluster wide default parameters |
677 | 678 |
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM |
b/lib/ssconf.py | ||
---|---|---|
284 | 284 |
constants.SS_RELEASE_VERSION, |
285 | 285 |
constants.SS_HYPERVISOR_LIST, |
286 | 286 |
constants.SS_MAINTAIN_NODE_HEALTH, |
287 |
constants.SS_UID_POOL, |
|
287 | 288 |
) |
288 | 289 |
_MAX_SIZE = 131072 |
289 | 290 |
|
... | ... | |
441 | 442 |
# we rely on the bool serialization here |
442 | 443 |
return data == "True" |
443 | 444 |
|
445 |
def GetUidPool(self): |
|
446 |
"""Return the user-id pool definition string. |
|
447 |
|
|
448 |
The separator character is a newline. |
|
449 |
|
|
450 |
The return value can be parsed using uidpool.ParseUidPool(): |
|
451 |
ss = ssconf.SimpleStore() |
|
452 |
uid_pool = uidpool.ParseUidPool(ss.GetUidPool(), separator="\n") |
|
453 |
|
|
454 |
""" |
|
455 |
data = self._ReadFile(constants.SS_UID_POOL) |
|
456 |
return data |
|
457 |
|
|
444 | 458 |
|
445 | 459 |
def GetMasterAndMyself(ss=None): |
446 | 460 |
"""Get the master node and my own hostname. |
b/lib/uidpool.py | ||
---|---|---|
118 | 118 |
return "%s-%s" % (lower, higher) |
119 | 119 |
|
120 | 120 |
|
121 |
def FormatUidPool(uid_pool): |
|
121 |
def FormatUidPool(uid_pool, separator=None):
|
|
122 | 122 |
"""Convert the internal representation of the user-id pool into a string. |
123 | 123 |
|
124 | 124 |
The output format is also accepted by ParseUidPool() |
125 | 125 |
|
126 | 126 |
@param uid_pool: a list of integer pairs representing UID ranges |
127 |
@param separator: the separator character between the uids/uid-ranges. |
|
128 |
Defaults to ", ". |
|
127 | 129 |
@return: a string with the formatted results |
128 | 130 |
|
129 | 131 |
""" |
130 |
return utils.CommaJoin([_FormatUidRange(lower, higher) |
|
131 |
for lower, higher in uid_pool]) |
|
132 |
if separator is None: |
|
133 |
separator = ", " |
|
134 |
return separator.join([_FormatUidRange(lower, higher) |
|
135 |
for lower, higher in uid_pool]) |
|
132 | 136 |
|
133 | 137 |
|
134 | 138 |
def CheckUidPool(uid_pool): |
Also available in: Unified diff