Replace deprecated yaml.load by yaml.safe_load 23/8123/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 7 Nov 2019 08:30:30 +0000 (09:30 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 7 Nov 2019 08:30:30 +0000 (09:30 +0100)
Change-Id: I215da5edd978d222d807bef49e4938eb47e3f96b
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/common/utils.py
osmclient/scripts/osm.py
osmclient/sol005/ns.py
osmclient/sol005/nsi.py
osmclient/sol005/role.py
osmclient/v1/ns.py
osmclient/v1/vim.py

index 937e121..43287e9 100644 (file)
@@ -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'):
index 3f269bb..7b2e1a3 100755 (executable)
@@ -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)
index a75513b..e3fe17d 100644 (file)
@@ -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:
index ab6cf0a..cf88114 100644 (file)
@@ -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"):
index 6e052ba..64e84f9 100644 (file)
@@ -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')
index 3d638e1..e6b747f 100644 (file)
@@ -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']:
index 4230cd4..849f6dc 100644 (file)
@@ -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