From: garciadeblas Date: Thu, 7 Nov 2019 08:30:30 +0000 (+0100) Subject: Replace deprecated yaml.load by yaml.safe_load X-Git-Tag: v7.0.0rc1~12 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F23%2F8123%2F1;p=osm%2Fosmclient.git Replace deprecated yaml.load by yaml.safe_load Change-Id: I215da5edd978d222d807bef49e4938eb47e3f96b Signed-off-by: garciadeblas --- diff --git a/osmclient/common/utils.py b/osmclient/common/utils.py index 937e121..43287e9 100644 --- a/osmclient/common/utils.py +++ b/osmclient/common/utils.py @@ -66,7 +66,7 @@ def get_key_val_from_pkg(descriptor_file): if yamlfile is None: return None - dict = yaml.load(tar.extractfile(yamlfile)) + dict = yaml.safe_load(tar.extractfile(yamlfile)) result = {} for k1, v1 in list(dict.items()): if not k1.endswith('-catalog'): diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 3f269bb..7b2e1a3 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -1316,7 +1316,7 @@ def pdu_create(ctx, name, pdu_type, interface, description, vim_account, descrip raise ClientException('in absence of descriptor file, option "--vim_account" is mandatory (at least once)') else: with open(descriptor_file, 'r') as df: - pdu = yaml.load(df.read()) + pdu = yaml.safe_load(df.read()) if name: pdu["name"] = name if pdu_type: pdu["type"] = pdu_type if description: pdu["description"] = description @@ -2818,7 +2818,7 @@ def ns_action(ctx, op_data['vdu_count_index'] = vdu_count op_data['primitive'] = action_name if params: - op_data['primitive_params'] = yaml.load(params) + op_data['primitive_params'] = yaml.safe_load(params) else: op_data['primitive_params'] = {} ctx.obj.ns.exec_op(ns_name, op_name='action', op_data=op_data, wait=wait) diff --git a/osmclient/sol005/ns.py b/osmclient/sol005/ns.py index a75513b..e3fe17d 100644 --- a/osmclient/sol005/ns.py +++ b/osmclient/sol005/ns.py @@ -161,7 +161,7 @@ class Ns(object): with open(pubkeyfile, 'r') as f: ns['ssh_keys'].append(f.read()) if config: - ns_config = yaml.load(config) + ns_config = yaml.safe_load(config) if "vim-network-name" in ns_config: ns_config["vld"] = ns_config.pop("vim-network-name") if "vld" in ns_config: diff --git a/osmclient/sol005/nsi.py b/osmclient/sol005/nsi.py index ab6cf0a..cf88114 100644 --- a/osmclient/sol005/nsi.py +++ b/osmclient/sol005/nsi.py @@ -155,7 +155,7 @@ class Nsi(object): with open(pubkeyfile, 'r') as f: nsi['ssh_keys'].append(f.read()) if config: - nsi_config = yaml.load(config) + nsi_config = yaml.safe_load(config) if "netslice-vld" in nsi_config: for vld in nsi_config["netslice-vld"]: if vld.get("vim-network-name"): diff --git a/osmclient/sol005/role.py b/osmclient/sol005/role.py index 6e052ba..64e84f9 100644 --- a/osmclient/sol005/role.py +++ b/osmclient/sol005/role.py @@ -49,7 +49,7 @@ class Role(object): role = {"name": name} if permissions: - role_permissions = yaml.load(permissions) + role_permissions = yaml.safe_load(permissions) if not isinstance(role_permissions, dict): raise ClientException('Role permissions should be provided in a key-value fashion') @@ -105,7 +105,7 @@ class Role(object): new_role_obj["name"] = new_name if permissions: - role_definition = yaml.load(permissions) + role_definition = yaml.safe_load(permissions) if not isinstance(role_definition, dict): raise ClientException('Role permissions should be provided in a key-value fashion') @@ -117,7 +117,7 @@ class Role(object): new_role_obj["permissions"] = role_definition else: if remove: - keys_from_remove = yaml.load(remove) + keys_from_remove = yaml.safe_load(remove) if not isinstance(keys_from_remove, list): raise ClientException('Keys should be provided in a list fashion') @@ -128,7 +128,7 @@ class Role(object): new_role_obj["permissions"][key] = None if add: - add_roles = yaml.load(add) + add_roles = yaml.safe_load(add) if not isinstance(add_roles, dict): raise ClientException('Add should be provided in a key-value fashion') diff --git a/osmclient/v1/ns.py b/osmclient/v1/ns.py index 3d638e1..e6b747f 100644 --- a/osmclient/v1/ns.py +++ b/osmclient/v1/ns.py @@ -116,7 +116,7 @@ class Ns(object): ns_config = {} if config: - ns_config = yaml.load(config) + ns_config = yaml.safe_load(config) if ns_config and 'vim-network-name' in ns_config: for network in ns_config['vim-network-name']: diff --git a/osmclient/v1/vim.py b/osmclient/v1/vim.py index 4230cd4..849f6dc 100644 --- a/osmclient/v1/vim.py +++ b/osmclient/v1/vim.py @@ -66,7 +66,7 @@ class Vim(object): vim_config = {} if 'config' in vim_access and vim_access['config'] is not None: - vim_config = yaml.load(vim_access['config']) + vim_config = yaml.safe_load(vim_access['config']) if vim_config: vim_account['datacenter']['config'] = vim_config