minor change to avoid deleting a non existing element from dictionary 87/1387/3
authormontesmoreno <pablo.montesmoreno@telefonica.com>
Tue, 28 Mar 2017 13:45:02 +0000 (15:45 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Tue, 28 Mar 2017 15:40:30 +0000 (16:40 +0100)
Change-Id: Iecdd1aceda92fe5ce1cd4891be5175791c6cfab4
Signed-off-by: montesmoreno <pablo.montesmoreno@telefonica.com>
ovim.py

diff --git a/ovim.py b/ovim.py
index f896adc..3166972 100644 (file)
--- a/ovim.py
+++ b/ovim.py
@@ -900,9 +900,12 @@ class ovim():
         port_data['switch_mac'] = port_mapping_data[0]['switch_mac']
 
         # remove from compute_node, region and pci of_port_data to adapt to 'ports' structure
-        del port_data['compute_node']
-        del port_data['region']
-        del port_data['pci']
+        if 'region' in port_data:
+            del port_data['region']
+        if 'pci' in port_data:
+            del port_data['pci']
+        if 'compute_node' in port_data:
+            del port_data['compute_node']
 
         result, uuid = self.db.new_row('ports', port_data, True, True)
         if result > 0: