Commit 0fbae49a authored by Balazs Lecz's avatar Balazs Lecz
Browse files

Add uid_pool to ssconf


Signed-off-by: default avatarBalazs Lecz <leczb@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 39b0f0c2
......@@ -43,6 +43,7 @@ from ganeti import constants
from ganeti import rpc
from ganeti import objects
from ganeti import serializer
from ganeti import uidpool
_config_lock = locking.SharedLock()
......@@ -1372,6 +1373,8 @@ class ConfigWriter:
hypervisor_list = fn(cluster.enabled_hypervisors)
uid_pool = uidpool.FormatUidPool(cluster.uid_pool, separator="\n")
return {
constants.SS_CLUSTER_NAME: cluster.cluster_name,
constants.SS_CLUSTER_TAGS: cluster_tags,
......@@ -1390,6 +1393,7 @@ class ConfigWriter:
constants.SS_RELEASE_VERSION: constants.RELEASE_VERSION,
constants.SS_HYPERVISOR_LIST: hypervisor_list,
constants.SS_MAINTAIN_NODE_HEALTH: str(cluster.maintain_node_health),
constants.SS_UID_POOL: uid_pool,
}
@locking.ssynchronized(_config_lock, shared=1)
......
......@@ -672,6 +672,7 @@ SS_INSTANCE_LIST = "instance_list"
SS_RELEASE_VERSION = "release_version"
SS_HYPERVISOR_LIST = "hypervisor_list"
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
SS_UID_POOL = "uid_pool"
# cluster wide default parameters
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
......
......@@ -284,6 +284,7 @@ class SimpleStore(object):
constants.SS_RELEASE_VERSION,
constants.SS_HYPERVISOR_LIST,
constants.SS_MAINTAIN_NODE_HEALTH,
constants.SS_UID_POOL,
)
_MAX_SIZE = 131072
......@@ -441,6 +442,19 @@ class SimpleStore(object):
# we rely on the bool serialization here
return data == "True"
def GetUidPool(self):
"""Return the user-id pool definition string.
The separator character is a newline.
The return value can be parsed using uidpool.ParseUidPool():
ss = ssconf.SimpleStore()
uid_pool = uidpool.ParseUidPool(ss.GetUidPool(), separator="\n")
"""
data = self._ReadFile(constants.SS_UID_POOL)
return data
def GetMasterAndMyself(ss=None):
"""Get the master node and my own hostname.
......
......@@ -118,17 +118,21 @@ def _FormatUidRange(lower, higher):
return "%s-%s" % (lower, higher)
def FormatUidPool(uid_pool):
def FormatUidPool(uid_pool, separator=None):
"""Convert the internal representation of the user-id pool into a string.
The output format is also accepted by ParseUidPool()
@param uid_pool: a list of integer pairs representing UID ranges
@param separator: the separator character between the uids/uid-ranges.
Defaults to ", ".
@return: a string with the formatted results
"""
return utils.CommaJoin([_FormatUidRange(lower, higher)
for lower, higher in uid_pool])
if separator is None:
separator = ", "
return separator.join([_FormatUidRange(lower, higher)
for lower, higher in uid_pool])
def CheckUidPool(uid_pool):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment