Browse Source

Merge "Use yaml.safe_load to load YAML files" into stable/train

changes/95/822395/1
Zuul 5 months ago committed by Gerrit Code Review
parent
commit
b9009e83b2
  1. 28
      tools/yaml-validate.py

28
tools/yaml-validate.py

@ -296,7 +296,7 @@ def validate_endpoint_map(base_map, env_map):
def validate_role_name(filename):
with open(filename, 'r') as f:
tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
tpl = yaml.safe_load(f.read())
role_data = tpl[0]
if role_data['name'] != os.path.basename(filename).split('.')[0]:
@ -312,7 +312,7 @@ def validate_hci_compute_services_default(env_filename, env_tpl):
roles_filename = os.path.join(os.path.dirname(env_filename),
'../roles/Compute.yaml')
with open(roles_filename, 'r') as f:
roles_tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
roles_tpl = yaml.safe_load(f.read())
for role in roles_tpl:
if role['name'] == 'Compute':
@ -328,7 +328,7 @@ def validate_hci_computehci_role(hci_role_filename, hci_role_tpl):
compute_role_filename = os.path.join(os.path.dirname(hci_role_filename),
'./Compute.yaml')
with open(compute_role_filename, 'r') as f:
compute_role_tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
compute_role_tpl = yaml.safe_load(f.read())
compute_role_services = compute_role_tpl[0]['ServicesDefault']
for role in hci_role_tpl:
@ -346,7 +346,7 @@ def validate_controller_dashboard(filename, tpl):
control_role_filename = os.path.join(os.path.dirname(filename),
'./Controller.yaml')
with open(control_role_filename, 'r') as f:
control_role_tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
control_role_tpl = yaml.safe_load(f.read())
control_role_services = control_role_tpl[0]['ServicesDefault']
for role in tpl:
@ -363,7 +363,7 @@ def validate_controller_storage_nfs(filename, tpl, exclude_service=()):
control_role_filename = os.path.join(os.path.dirname(filename),
'./Controller.yaml')
with open(control_role_filename, 'r') as f:
control_role_tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
control_role_tpl = yaml.safe_load(f.read())
control_role_services = control_role_tpl[0]['ServicesDefault']
for role in tpl:
@ -382,7 +382,7 @@ def validate_hci_role(hci_role_filename, hci_role_tpl):
compute_role_filename = \
os.path.join(os.path.dirname(hci_role_filename), './Compute.yaml')
with open(compute_role_filename, 'r') as f:
compute_role_tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
compute_role_tpl = yaml.safe_load(f.read())
compute_role_services = compute_role_tpl[0]['ServicesDefault']
for role in hci_role_tpl:
@ -421,7 +421,7 @@ def validate_ceph_role(ceph_role_filename, ceph_role_tpl):
ceph_storage_role_filename = \
os.path.join(os.path.dirname(ceph_role_filename), './CephStorage.yaml')
with open(ceph_storage_role_filename, 'r') as f:
ceph_storage_role_tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
ceph_storage_role_tpl = yaml.safe_load(f.read())
ceph_storage_role_services = ceph_storage_role_tpl[0]['ServicesDefault']
for role in ceph_role_tpl:
@ -452,7 +452,7 @@ def validate_controller_no_ceph_role(filename, tpl):
control_role_filename = os.path.join(os.path.dirname(filename),
'./Controller.yaml')
with open(control_role_filename, 'r') as f:
control_role_tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
control_role_tpl = yaml.safe_load(f.read())
control_role_services = control_role_tpl[0]['ServicesDefault']
for role in tpl:
@ -476,7 +476,7 @@ def validate_with_compute_role_services(role_filename, role_tpl, exclude_service
cmpt_filename = os.path.join(os.path.dirname(role_filename),
'./Compute.yaml')
with open(cmpt_filename, 'r') as f:
cmpt_tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
cmpt_tpl = yaml.safe_load(f.read())
cmpt_services = cmpt_tpl[0]['ServicesDefault']
cmpt_services = [x for x in cmpt_services if (x not in exclude_service)]
@ -612,8 +612,8 @@ def validate_docker_service_mysql_usage(filename, tpl):
newfilename = \
os.path.normpath(os.path.join(os.path.dirname(incfile), f))
with open(newfilename, 'r') as newfile:
newtmp = yaml.load(newfile.read(), Loader=yaml.SafeLoader)
read_all(newfile, newtmp)
newtmp = yaml.safe_load(newfile.read())
read_all(newfilename, newtmp)
read_all(filename, tpl)
if search(all_content, match_use_mysql_protocol, no_op):
@ -1052,7 +1052,7 @@ def validate(filename, param_map):
retval = 0
try:
with open(filename, 'r') as f:
tpl = yaml.load(f.read(), Loader=yaml.SafeLoader)
tpl = yaml.safe_load(f.read())
is_heat_template = 'heat_template_version' in tpl
@ -1244,11 +1244,11 @@ def validate_upgrade_tasks(upgrade_tasks):
def validate_network_data_file(data_file_path):
try:
with open(data_file_path, 'r') as data_file:
data_file = yaml.load(data_file.read(), Loader=yaml.SafeLoader)
data_file = yaml.safe_load(data_file.read())
base_file_path = os.path.dirname(data_file_path) + "/network_data.yaml"
with open(base_file_path, 'r') as base_file:
base_file = yaml.load(base_file.read(), Loader=yaml.SafeLoader)
base_file = yaml.safe_load(base_file.read())
retval = 0
for n in base_file:

Loading…
Cancel
Save