Skip to content

Commit

Permalink
Check table values.
Browse files Browse the repository at this point in the history
Signed-off-by: Kurt Garloff <[email protected]>
  • Loading branch information
garloff committed Dec 8, 2023
1 parent 961d382 commit 16825a8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Tests/iaas/flavor-naming/flavor-form.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def generate_name(form):
ERROR = f"Can not find attribute {keypair[1]} in {keypair[1]}"
return None
fdesc = FLAVOR_SPEC[idx].pnames[idx2]
if val and val != "" and val != "NN" and val != "0" and not (val == "1" and fdesc[0:2] == "#:"):
if val == "NN":
val = ""
if val and val != "" and val != "0" and not (val == "1" and fdesc[0:2] == "#:"):
FLAVOR_SPEC[idx].parsed += 1
# Now parse fdesc to get the right value
if fdesc[0:2] == '##':
Expand All @@ -108,6 +110,16 @@ def generate_name(form):
val = '1'
setattr(FLAVOR_SPEC[idx], keypair[1], int(val))
# TODO: Handle boolean and tables
elif fdesc[0] == '?':
setattr(FLAVOR_SPEC[idx], keypair[1], bool(val))
elif hasattr(FLAVOR_SPEC[idx], f"tbl_{keypair[1]}"):
tbl = getattr(FLAVOR_SPEC[idx], f"tbl_{keypair[1]}")
if not val and fdesc[0] == '.':
setattr(FLAVOR_SPEC[idx], keypair[1], val)
if not val in tbl and (val or fdesc[0] != '.'):
ERROR = f'Invalid key {val} for tbl_{keypair[1]}'
return None
setattr(FLAVOR_SPEC[idx], keypair[1], val)
else:
if val == "NN":
val = ""
Expand Down

0 comments on commit 16825a8

Please sign in to comment.