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
#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',
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
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
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:
" 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,
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
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
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
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}
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:
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]
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)
+