From: Pablo Montes Moreno Date: Mon, 27 Mar 2017 10:42:32 +0000 (+0200) Subject: Re-enabled SDN functionality X-Git-Tag: v2.0.0~23^2~8 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F1374%2F1;p=osm%2FRO.git Re-enabled SDN functionality Change-Id: Ice8af9e0f7c98045afa654b4fd443b790338e211 Signed-off-by: Pablo Montes Moreno --- diff --git a/nfvo.py b/nfvo.py index 0b7e6d0d..3708edd0 100644 --- a/nfvo.py +++ b/nfvo.py @@ -43,7 +43,7 @@ from db_base import db_base_Exception import nfvo_db from threading import Lock from time import time -#import openvim.ovim as Ovim +import openvim.ovim as Ovim global global_config global vimconn_imported @@ -133,8 +133,8 @@ def start_service(mydb): #TODO: log_level_of should not be needed. To be modified in ovim 'log_level_of': 'DEBUG' } - #ovim = Ovim.ovim(ovim_configuration) - #ovim.start_service() + ovim = Ovim.ovim(ovim_configuration) + ovim.start_service() from_= 'tenants_datacenters as td join datacenters as d on td.datacenter_id=d.uuid join datacenter_tenants as dt on td.datacenter_tenant_id=dt.uuid' select_ = ('type','d.config as config','d.uuid as datacenter_id', 'vim_url', 'vim_url_admin', 'd.name as datacenter_name', @@ -3129,25 +3129,22 @@ def vim_action_create(mydb, tenant_id, datacenter, item, descriptor): return vim_action_get(mydb, tenant_id, datacenter, item, content) def sdn_controller_create(mydb, tenant_id, sdn_controller): - #data = ovim.new_of_controller(sdn_controller) - data = [] + data = ovim.new_of_controller(sdn_controller) logger.debug('New SDN controller created with uuid {}'.format(data)) return data def sdn_controller_update(mydb, tenant_id, controller_id, sdn_controller): - #data = ovim.edit_of_controller(controller_id, sdn_controller) - data = [] + data = ovim.edit_of_controller(controller_id, sdn_controller) msg = 'SDN controller {} updated'.format(data) logger.debug(msg) return msg def sdn_controller_list(mydb, tenant_id, controller_id=None): if controller_id == None: - #data = ovim.get_of_controllers() - data = [] + data = ovim.get_of_controllers() else: - #data = ovim.show_of_controller(controller_id) - data = {'dpid': None} + data = ovim.show_of_controller(controller_id) + msg = 'SDN controller list:\n {}'.format(data) logger.debug(msg) return data @@ -3161,8 +3158,7 @@ def sdn_controller_delete(mydb, tenant_id, controller_id): if 'sdn-controller' in config and config['sdn-controller'] == controller_id: raise NfvoException("SDN controller {} is in use by datacenter {}".format(controller_id, datacenter['uuid']), HTTP_Conflict) - #data = ovim.delete_of_controller(controller_id) - data = 0 + data = ovim.delete_of_controller(controller_id) msg = 'SDN controller {} deleted'.format(data) logger.debug(msg) return msg @@ -3177,8 +3173,8 @@ def datacenter_sdn_port_mapping_set(mydb, tenant_id, datacenter_id, sdn_port_map except: raise NfvoException("The datacenter {} has not an SDN controller associated".format(datacenter_id), HTTP_Bad_Request) - #sdn_controller = ovim.show_of_controller(sdn_controller_id) - #switch_dpid = sdn_controller["dpid"] + sdn_controller = ovim.show_of_controller(sdn_controller_id) + switch_dpid = sdn_controller["dpid"] maps = list() for compute_node in sdn_port_mapping: @@ -3194,12 +3190,10 @@ def datacenter_sdn_port_mapping_set(mydb, tenant_id, datacenter_id, sdn_port_map " or 'switch_mac'", HTTP_Bad_Request) maps.append(dict(element)) - #return ovim.set_of_port_mapping(maps, ofc_id=sdn_controller_id, switch_dpid=switch_dpid, region=datacenter_id) - return [] + return ovim.set_of_port_mapping(maps, ofc_id=sdn_controller_id, switch_dpid=switch_dpid, region=datacenter_id) def datacenter_sdn_port_mapping_list(mydb, tenant_id, datacenter_id): - #maps = ovim.get_of_port_mappings(db_filter={"region": datacenter_id}) - maps = [] + maps = ovim.get_of_port_mappings(db_filter={"region": datacenter_id}) result = { "sdn-controller": None, @@ -3217,9 +3211,9 @@ def datacenter_sdn_port_mapping_list(mydb, tenant_id, datacenter_id): result["sdn-controller"] = controller_id result["dpid"] = sdn_controller["dpid"] - # if result["sdn-controller"] == None or result["dpid"] == None: - # raise NfvoException("Not all SDN controller information for datacenter {} could be found: {}".format(datacenter_id, result), - # HTTP_Internal_Server_Error) + if result["sdn-controller"] == None or result["dpid"] == None: + raise NfvoException("Not all SDN controller information for datacenter {} could be found: {}".format(datacenter_id, result), + HTTP_Internal_Server_Error) if len(maps) == 0: return result @@ -3251,5 +3245,4 @@ def datacenter_sdn_port_mapping_list(mydb, tenant_id, datacenter_id): return result def datacenter_sdn_port_mapping_delete(mydb, tenant_id, datacenter_id): - #return ovim.clear_of_port_mapping(db_filter={"region":datacenter_id}) - return 0 + return ovim.clear_of_port_mapping(db_filter={"region":datacenter_id}) \ No newline at end of file diff --git a/vim_thread.py b/vim_thread.py index 676ba207..eb740b4a 100644 --- a/vim_thread.py +++ b/vim_thread.py @@ -34,7 +34,7 @@ import Queue import logging import vimconn from db_base import db_base_Exception -#from openvim.ovim import ovimException +from openvim.ovim import ovimException # from logging import Logger @@ -159,8 +159,7 @@ class vim_thread(threading.Thread): net_type = params[1] network = None - #sdn_controller = self.vim.config.get('sdn-controller') - sdn_controller = None + sdn_controller = self.vim.config.get('sdn-controller') if sdn_controller and (net_type == "data" or net_type == "ptp"): network = {"name": net_name, "type": net_type} @@ -190,9 +189,9 @@ class vim_thread(threading.Thread): except db_base_Exception as e: self.logger.error("Error updating database %s", str(e)) return False, str(e) - # except ovimException as e: - # self.logger.error("Error creating NET in ovim, task=%s: %s", str(task_id), str(e)) - # return False, str(e) + except ovimException as e: + self.logger.error("Error creating NET in ovim, task=%s: %s", str(task_id), str(e)) + return False, str(e) def new_vm(self, task): try: @@ -253,8 +252,7 @@ class vim_thread(threading.Thread): def del_net(self, task): net_id = task["params"][0] - #sdn_net_id = task["params"][1] - sdn_net_id = None + sdn_net_id = task["params"][1] if is_task_id(net_id): try: task_create = task["depends"][net_id] @@ -274,7 +272,8 @@ class vim_thread(threading.Thread): return True, result except vimconn.vimconnException as e: return False, str(e) - # except ovimException as e: - # logging.error("Error deleting network from ovim. net_id: {}, sdn_net_id: {}".format(net_id, sdn_net_id)) - # return False, str(e) + except ovimException as e: + logging.error("Error deleting network from ovim. net_id: {}, sdn_net_id: {}".format(net_id, sdn_net_id)) + return False, str(e) +