fix a race condition using database connection db_of at ovim.start without using... 74/1274/2
authortierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 10 Mar 2017 12:57:24 +0000 (13:57 +0100)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 10 Mar 2017 15:06:13 +0000 (16:06 +0100)
Change-Id: I3858a117f547be2931995a160e17d0b5a7e69a04
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
ovim.py

diff --git a/ovim.py b/ovim.py
index 14bc50d..9fef4f9 100644 (file)
--- a/ovim.py
+++ b/ovim.py
@@ -180,7 +180,7 @@ class ovim():
         # check if this bridge is already used (present at database) for a network)
         used_bridge_nets = []
         for brnet in self.config['bridge_nets']:
-            r, nets = self.db_of.get_table(SELECT=('uuid',), FROM='nets', WHERE={'provider': "bridge:" + brnet[0]})
+            r, nets = self.db.get_table(SELECT=('uuid',), FROM='nets', WHERE={'provider': "bridge:" + brnet[0]})
             if r > 0:
                 brnet[3] = nets[0]['uuid']
                 used_bridge_nets.append(brnet[0])
@@ -192,7 +192,7 @@ class ovim():
         # get nets used by dhcp
         if self.config.get("dhcp_server"):
             for net in self.config["dhcp_server"].get("nets", ()):
-                r, nets = self.db_of.get_table(SELECT=('uuid',), FROM='nets', WHERE={'name': net})
+                r, nets = self.db.get_table(SELECT=('uuid',), FROM='nets', WHERE={'name': net})
                 if r > 0:
                     self.config['dhcp_nets'].append(nets[0]['uuid'])
 
@@ -217,7 +217,7 @@ class ovim():
         host_develop_bridge_iface = self.config.get('development_bridge', None)
 
         # get host list from data base before starting threads
-        r, hosts = self.db_of.get_table(SELECT=('name', 'ip_name', 'user', 'uuid'), FROM='hosts', WHERE={'status': 'ok'})
+        r, hosts = self.db.get_table(SELECT=('name', 'ip_name', 'user', 'uuid'), FROM='hosts', WHERE={'status': 'ok'})
         if r < 0:
             raise ovimException("Cannot get hosts from database {}".format(hosts))
 
@@ -1213,8 +1213,8 @@ class ovim():
         host_develop_mode = True if self.config['mode'] == 'development' else False
 
         dhcp_host = ht.host_thread(name='openvim_controller', user=ovs_controller_user, host=controller_ip,
-                                   db=self.config['db'],
-                                   db_lock=self.config['db_lock'], test=host_test_mode,
+                                   db=self.db_of,
+                                   db_lock=self.db_lock, test=host_test_mode,
                                    image_path=self.config['image_path'], version=self.config['version'],
                                    host_id='openvim_controller', develop_mode=host_develop_mode,
                                    develop_bridge_iface=bridge_ifaces)