diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index b07172b17e..2f4e9c5eb8 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -229,7 +229,10 @@ def main(): for yaml_file in args.yaml: with open(yaml_file, 'r') as stream: - additional_data = yaml.load(stream) + if yaml.__version__ >= "5.1": + additional_data = yaml.full_load(stream) + else: + additional_data = yaml.load(stream) deep_update(data, FormatConverter.to_deserialized(additional_data)) for json_file in args.json: diff --git a/src/sonic-config-engine/sonic_device_util.py b/src/sonic-config-engine/sonic_device_util.py index c7b2528194..34877600fd 100644 --- a/src/sonic-config-engine/sonic_device_util.py +++ b/src/sonic-config-engine/sonic_device_util.py @@ -42,7 +42,10 @@ def get_sonic_version_info(): return None data = {} with open('/etc/sonic/sonic_version.yml') as stream: - data = yaml.load(stream) + if yaml.__version__ >= "5.1": + data = yaml.full_load(stream) + else: + data = yaml.load(stream) return data def valid_mac_address(mac):