Correct YAML load warning

The use of `yaml.load` is deprecated and considered unsafe.

The warning notice:

> /usr/lib/python3.6/site-packages/tripleoclient/utils.py:2349:
  YAMLLoadWarning: calling yaml.load() without Loader=...
  is deprecated, as the default Loader is unsafe. Please read
  https://msg.pyyaml.org/load for full details.

This change removes the use of the deprecated function, which
corrects the issue.

Change-Id: I7b747fd124880f55a30f75e5efb27c22c57ac10c
Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
Kevin Carter 2020-03-16 15:05:44 -05:00
parent 026e98012a
commit 7cfe4d4f12
No known key found for this signature in database
GPG Key ID: CE94BD890A47B20A
5 changed files with 8 additions and 8 deletions

View File

@ -41,7 +41,7 @@ def export_passwords(swift, stack, excludes=True):
"file from swift: %s", str(e))
sys.exit(1)
data = yaml.load(content)["passwords"]
data = yaml.safe_load(content)["passwords"]
if excludes:
excluded_passwords = []
for k in data:

View File

@ -59,7 +59,7 @@ class TestFFWDUpgradePrepare(fakes.TestFFWDUpgradePrepare):
@mock.patch('tripleoclient.workflows.package_update.update',
autospec=True)
@mock.patch('os.path.abspath')
@mock.patch('yaml.load')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
@ -119,7 +119,7 @@ class TestFFWDUpgradePrepare(fakes.TestFFWDUpgradePrepare):
autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('os.path.abspath')
@mock.patch('yaml.load')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_tripleo_heat_templates', autospec=True)

View File

@ -46,7 +46,7 @@ class TestOvercloudUpdatePrepare(fakes.TestOvercloudUpdatePrepare):
@mock.patch('tripleoclient.workflows.package_update.update',
autospec=True)
@mock.patch('os.path.abspath')
@mock.patch('yaml.load')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
@ -83,7 +83,7 @@ class TestOvercloudUpdatePrepare(fakes.TestOvercloudUpdatePrepare):
autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('os.path.abspath')
@mock.patch('yaml.load')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_tripleo_heat_templates', autospec=True)

View File

@ -53,7 +53,7 @@ class TestOvercloudUpgradePrepare(fakes.TestOvercloudUpgradePrepare):
@mock.patch('tripleoclient.workflows.package_update.update',
autospec=True)
@mock.patch('os.path.abspath')
@mock.patch('yaml.load')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
@ -118,7 +118,7 @@ class TestOvercloudUpgradePrepare(fakes.TestOvercloudUpgradePrepare):
autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('os.path.abspath')
@mock.patch('yaml.load')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_tripleo_heat_templates', autospec=True)

View File

@ -2346,7 +2346,7 @@ def check_file_for_enabled_service(env_file):
"""
if os.path.exists(env_file):
with open(env_file, "r") as f:
content = yaml.load(f)
content = yaml.safe_load(f)
deprecated_services_enabled = []
for service in constants.DEPRECATED_SERVICES.keys():
try: