fixes issues with ovs type using bridge netwoks 91/991/1
authortierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 19 Jan 2017 17:59:59 +0000 (18:59 +0100)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 19 Jan 2017 17:59:59 +0000 (18:59 +0100)
Change-Id: I54520f41258cc07cd8682616ecda24a723adef1a
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
httpserver.py
openvimd.cfg
openvimd.py
vim_db.py

index e5ce5cd..718758b 100644 (file)
@@ -1469,22 +1469,24 @@ def http_post_server_id(tenant_id):
             
         #look for dhcp ip address 
         r2, c2 = my.db.get_table(FROM="ports", SELECT=["mac", "net_id"], WHERE={"instance_id": new_instance})
-        if r2 >0 and config_dic.get("dhcp_server"):
+        if r2 >0:
             for iface in c2:
-                if iface["net_id"] in config_dic["dhcp_nets"]:
+                if config_dic.get("dhcp_server") and iface["net_id"] in config_dic["dhcp_nets"]:
                     #print "dhcp insert add task"
                     r,c = config_dic['dhcp_thread'].insert_task("add", iface["mac"])
                     if r < 0:
-                        print ':http_post_servers ERROR UPDATING dhcp_server !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' +  c 
-        
-    #Start server
+                        print ':http_post_servers ERROR UPDATING dhcp_server !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' +  c
+
+                #ensure compute contain the bridge for ovs networks:
+                server_net = get_network_id(iface['net_id'])
+                if server_net["network"].get('provider:physical', "")[:3] == 'OVS':
+                    vlan = str(server_net['network']['provider:vlan'])
+                    config_dic['host_threads'][server['host_id']].insert_task("create-ovs-bridge-port", vlan)
+        #Start server
         
         server['uuid'] = new_instance
-        # server_start = server.get('start', 'yes')
-        if config_dic['network_type'] == 'ovs':
-            server_net = get_network_id(c2[0]['net_id'])
-            vlan = str(server_net['network']['provider:vlan'])
-            config_dic['host_threads'][server['host_id']].insert_task("create-ovs-bridge-port", vlan)
+        server_start = server.get('start', 'yes')
+
         if server_start != 'no':
             server['paused'] = True if server_start == 'paused' else False 
             server['action'] = {"start":None}
@@ -1834,7 +1836,7 @@ def http_post_networks():
 #            if bridge_net==None:     
 #                bottle.abort(HTTP_Bad_Request, "invalid 'provider:physical', bridge '%s' is not one of the provisioned 'bridge_ifaces' in the configuration file" % bridge_net_name)
 #                return
-    elif config_dic['network_type'] == 'bridge' and net_type =='bridge_data' or net_type ==  'bridge_man' :
+    elif config_dic['network_type'] == 'bridge' and ( net_type =='bridge_data' or net_type ==  'bridge_man' ):
         #look for a free precreated nets
         for brnet in config_dic['bridge_nets']:
             if brnet[3]==None: # free
@@ -1860,7 +1862,7 @@ def http_post_networks():
         if net_vlan < 0:
             bottle.abort(HTTP_Internal_Server_Error, "Error getting an available vlan")
             return
-    if config_dic['network_type'] == 'ovs':
+    if net_provider == 'OVS':
         net_provider = 'OVS' + ":" + str(net_vlan)
 
     network['provider'] = net_provider
index bfa937a..545b739 100644 (file)
@@ -72,14 +72,14 @@ tenant_id: fc7b43b6-6bfa-11e4-84d2-5254006d6777   # Default tenant identifier fo
 network_vlan_range_start: 3000
 network_vlan_range_end:   4000
 
-# Network overlay supported by openvim compute, bsae on openvswicth or linux bridges to manage management networks for NFVs.
-# - ovs : Create a vlxan mesh between computes to handle the network overlay, no prepopulated bridges or networks is need it.
-# - bridge: Use pre-populate linux bridges by openvim configuration scripts.
-
+# Overlay network implementation. Options are:
+# - ovs :   (by default) Use a vlxan mesh between computes to handle the network overlay.
+# - bridge: Use pre-populated linux bridges with L2 conectivity at compte nodes.
 network_type : ovs
 
 #host bridge interfaces for networks
-# Openvim cannot create bridge networks automatically, in the same way as other CMS do when network type is "bridge".
+# Apply only for 'network_type: bridge'
+# Indicates the bridges at compute nodes to be used for the overlay networks
 # Bridge networks need to be pre-provisioned on each host and Openvim uses those pre-provisioned bridge networks.
 # Openvim assumes that the following bridge interfaces have been created on each host, appropriately associated to a physical port.
 # The following information needs to be provided:
index 573ce27..1651df7 100755 (executable)
@@ -30,8 +30,8 @@ and host controllers
 
 __author__="Alfonso Tierno"
 __date__ ="$10-jul-2014 12:07:15$"
-__version__="0.5.0-r506"
-version_date="Oct 2016"
+__version__="0.5.1-r518"
+version_date="Jan 2017"
 database_version="0.8"      #expected database schema version
 
 import httpserver
index dbb8ffe..386f29f 100644 (file)
--- a/vim_db.py
+++ b/vim_db.py
@@ -173,7 +173,7 @@ class vim_db():
     def __get_used_net_vlan(self):
         #get used from database if needed
         try:
-            cmd = "SELECT vlan FROM nets WHERE vlan>='%s' and (type='ptp' or type='data') ORDER BY vlan LIMIT 25" % self.net_vlan_lastused
+            cmd = "SELECT vlan FROM nets WHERE vlan>='%s' ORDER BY vlan LIMIT 25" % self.net_vlan_lastused
             with self.con:
                 self.cur = self.con.cursor()
                 self.logger.debug(cmd)