Add syntax checking of userdata YAML
This commit is contained in:
parent
0d470ae5f6
commit
42f2dedf6d
|
@ -2759,9 +2759,14 @@ def provisioner_userdata_add(name, filename):
|
|||
Add a new userdata document NAME from file FILENAME.
|
||||
"""
|
||||
|
||||
# Open the XML file
|
||||
# Open the YAML file
|
||||
userdata = filename.read()
|
||||
filename.close()
|
||||
try:
|
||||
yaml.load(userdata, Loader=yaml.FullLoader)
|
||||
except Exception as e:
|
||||
click.echo("Error: Userdata document is malformed")
|
||||
cleanup(False, e)
|
||||
|
||||
params = dict()
|
||||
params['name'] = name
|
||||
|
@ -2833,6 +2838,12 @@ def provisioner_userdata_modify(name, filename, editor):
|
|||
userdata = filename.read().strip()
|
||||
filename.close()
|
||||
|
||||
try:
|
||||
yaml.load(userdata, Loader=yaml.FullLoader)
|
||||
except Exception as e:
|
||||
click.echo("Error: Userdata document is malformed")
|
||||
cleanup(False, e)
|
||||
|
||||
params = dict()
|
||||
params['data'] = userdata
|
||||
|
||||
|
|
Loading…
Reference in New Issue