Add placeholder for lowercase node names

Add placeholder 'r' in node.name.format cluster config option to use
only lowercase random letters for node name.

Change-Id: I49a90dc60649e01e6fead031b90f49fd29b2518e
This commit is contained in:
Duc Truong 2021-03-04 00:54:46 +00:00
parent 6dff71e13f
commit 7d6eebf5c3
1 changed files with 4 additions and 2 deletions

View File

@ -164,16 +164,18 @@ def format_node_name(fmt, cluster, index):
result = "" result = ""
last = 0 last = 0
pattern = re.compile("(\$\d{0,8}[RI])") pattern = re.compile("(\$\d{0,8}[rRI])")
for m in pattern.finditer(fmt): for m in pattern.finditer(fmt):
group = m.group() group = m.group()
t = group[-1] t = group[-1]
width = group[1:-1] width = group[1:-1]
if t == "R": # random string if t == "R" or t == "r": # random string
if width != "": if width != "":
sub = random_name(int(width)) sub = random_name(int(width))
else: else:
sub = random_name(8) sub = random_name(8)
if t == "r":
sub = sub.lower()
elif t == "I": # node index elif t == "I": # node index
if width != "": if width != "":
str_index = str(index) str_index = str(index)