import nfvo_db
from threading import Lock
from time import time
-import openvim.ovim as Ovim
+import ovim as ovim_module
global global_config
global vimconn_imported
# TODO: Avoid static configuration by adding new parameters to openmanod.cfg
# TODO: review ovim.py to delete not needed configuration
ovim_configuration = {
- 'logger_name': 'openvim',
+ 'logger_name': 'openmano.ovim',
'network_vlan_range_start': 1000,
'network_vlan_range_end': 4096,
- 'log_level_db': 'DEBUG',
- 'db_name': 'mano_vim_db',
- 'db_host': 'localhost',
- 'db_user': 'vim',
- 'db_passwd': 'vimpw',
- 'database_version': '0.15',
+ 'db_name': global_config["db_ovim_name"],
+ 'db_host': global_config["db_ovim_host"],
+ 'db_user': global_config["db_ovim_user"],
+ 'db_passwd': global_config["db_ovim_passwd"],
'bridge_ifaces': {},
'mode': 'normal',
- 'of_controller_nets_with_same_vlan': True,
'network_type': 'bridge',
#TODO: log_level_of should not be needed. To be modified in ovim
'log_level_of': 'DEBUG'
}
- ovim = Ovim.ovim(ovim_configuration)
+ ovim = ovim_module.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'
return result
def datacenter_sdn_port_mapping_delete(mydb, tenant_id, datacenter_id):
- return ovim.clear_of_port_mapping(db_filter={"region":datacenter_id})
\ No newline at end of file
+ return ovim.clear_of_port_mapping(db_filter={"region":datacenter_id})
"db_user": nameshort_schema,
"db_passwd": {"type":"string"},
"db_name": nameshort_schema,
+ "db_ovim_host": nameshort_schema,
+ "db_ovim_user": nameshort_schema,
+ "db_ovim_passwd": {"type":"string"},
+ "db_ovim_name": nameshort_schema,
# Next fields will disappear once the MANO API includes appropriate primitives
"vim_url": http_schema,
"vim_url_admin": http_schema,
"log_level_nfvo": log_level_schema,
"log_level_http": log_level_schema,
"log_level_console": log_level_schema,
+ "log_level_ovim": log_level_schema,
"log_file_db": path_schema,
"log_file_vim": path_schema,
"log_file_nfvo": path_schema,
"log_file_http": path_schema,
"log_file_console": path_schema,
+ "log_file_ovim": path_schema,
"log_socket_host": nameshort_schema,
"log_socket_port": port_schema,
"log_file": path_schema,
},
- "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
+ "required": ['db_user', 'db_passwd', 'db_name'],
"additionalProperties": False
}
db_user: mano # DB user
db_passwd: manopw # DB password
db_name: mano_db # Name of the MANO DB
+# Database ovim parameters
+db_ovim_host: localhost # by default localhost
+db_ovim_user: mano # DB user
+db_ovim_passwd: manopw # DB password
+db_ovim_name: mano_vim_db # Name of the OVIM MANO DB
+
#other MANO parameters
# Folder where the VNF descriptors will be stored
#log_file_http: /opt/openmano/logs/openmano_http.log
#log_level_console: DEBUG #proxy console log levels
#log_file_console: /opt/openmano/logs/openmano_console.log
+#log_level_ovim: DEBUG #ovim library log levels
+#log_file_ovim: /opt/openmano/logs/openmano_ovim.log
#Uncomment to send logs via IP to an external host
#log_socket_host: localhost
pass
def load_configuration(configuration_file):
- default_tokens ={'http_port':9090,
- 'http_host':'localhost',
- 'http_console_proxy': True,
- 'http_console_host': None,
- 'log_level': 'DEBUG',
- 'log_socket_port': 9022,
- 'auto_push_VNF_to_VIMs': True
- }
+ default_tokens = {'http_port':9090,
+ 'http_host':'localhost',
+ 'http_console_proxy': True,
+ 'http_console_host': None,
+ 'log_level': 'DEBUG',
+ 'log_socket_port': 9022,
+ 'auto_push_VNF_to_VIMs': True,
+ 'db_host': 'localhost',
+ 'db_ovim_host': 'localhost'
+ }
try:
#Check config file exists
with open(configuration_file, 'r') as f:
logger.critical("Starting openmano server version: '%s %s' command: '%s'",
__version__, version_date, " ".join(sys.argv))
- for log_module in ("nfvo", "http", "vim", "db", "console"):
+ for log_module in ("nfvo", "http", "vim", "db", "console", "ovim"):
log_level_module = "log_level_" + log_module
log_file_module = "log_file_" + log_module
logger_module = logging.getLogger('openmano.' + log_module)
import logging
import vimconn
from db_base import db_base_Exception
-from openvim.ovim import ovimException
+from ovim import ovimException
# from logging import Logger
SELECT=("ii.uuid as iface_id", "ine.uuid as net_id", "iv.uuid as vm_id", "sdn_net_id"),
WHERE=where_)
if len(db_ifaces)>1:
- self.logger.error("Refresing interfaces. "
+ self.logger.critical("Refresing interfaces. "
"Found more than one interface at database for '{}'".format(where_))
elif len(db_ifaces)==0:
- self.logger.error("Refresing interfaces. "
+ self.logger.critical("Refresing interfaces. "
"Not found any interface at database for '{}'".format(where_))
+ continue
else:
db_iface = db_ifaces[0]
if db_iface.get("sdn_net_id") and interface.get("compute_node") and interface.get("pci"):
SELECT=("uuid as net_id", "sdn_net_id"),
WHERE=where_)
if len(db_nets) > 1:
- self.logger.error("Refresing networks. "
+ self.logger.critical("Refresing networks. "
"Found more than one instance-networks at database for '{}'".format(where_))
elif len(db_nets) == 0:
- self.logger.error("Refresing networks. "
+ self.logger.critical("Refresing networks. "
"Not found any instance-network at database for '{}'".format(where_))
+ continue
else:
db_net = db_nets[0]
if db_net.get("sdn_net_id"):
while True:
#TODO reload service
while True:
- if not self.task_queue.empty():
- task = self.task_queue.get()
- self.task_lock.acquire()
- if task["status"] == "deleted":
+ try:
+ if not self.task_queue.empty():
+ task = self.task_queue.get()
+ self.task_lock.acquire()
+ if task["status"] == "deleted":
+ self.task_lock.release()
+ continue
+ task["status"] = "processing"
self.task_lock.release()
+ else:
+ self._refres_elements()
continue
- task["status"] = "processing"
- self.task_lock.release()
- else:
- self._refres_elements()
- continue
- self.logger.debug("processing task id={} name={} params={}".format(task["id"], task["name"],
- str(task["params"])))
- if task["name"] == 'exit' or task["name"] == 'reload':
- result, content = self.terminate(task)
- elif task["name"] == 'new-vm':
- result, content = self.new_vm(task)
- elif task["name"] == 'del-vm':
- result, content = self.del_vm(task)
- elif task["name"] == 'new-net':
- result, content = self.new_net(task)
- elif task["name"] == 'del-net':
- result, content = self.del_net(task)
- else:
- error_text = "unknown task {}".format(task["name"])
- self.logger.error(error_text)
- result = False
- content = error_text
- self.logger.debug("task id={} name={} result={}:{} params={}".format(task["id"], task["name"],
- result, content,
- str(task["params"])))
-
- with self.task_lock:
- task["status"] = "done" if result else "error"
- task["result"] = content
- self.task_queue.task_done()
-
- if task["name"] == 'exit':
- return 0
- elif task["name"] == 'reload':
- break
+ self.logger.debug("processing task id={} name={} params={}".format(task["id"], task["name"],
+ str(task["params"])))
+ if task["name"] == 'exit' or task["name"] == 'reload':
+ result, content = self.terminate(task)
+ elif task["name"] == 'new-vm':
+ result, content = self.new_vm(task)
+ elif task["name"] == 'del-vm':
+ result, content = self.del_vm(task)
+ elif task["name"] == 'new-net':
+ result, content = self.new_net(task)
+ elif task["name"] == 'del-net':
+ result, content = self.del_net(task)
+ else:
+ error_text = "unknown task {}".format(task["name"])
+ self.logger.error(error_text)
+ result = False
+ content = error_text
+ self.logger.debug("task id={} name={} result={}:{} params={}".format(task["id"], task["name"],
+ result, content,
+ str(task["params"])))
+
+ with self.task_lock:
+ task["status"] = "done" if result else "error"
+ task["result"] = content
+ self.task_queue.task_done()
+
+ if task["name"] == 'exit':
+ return 0
+ elif task["name"] == 'reload':
+ break
+ except Exception as e:
+ self.logger.critical("Unexpected exception at run: " + str(e), exc_info=True)
self.logger.debug("Finishing")
def terminate(self, task):
return True, None
- def _format_vim_error_msg(self, error_text, len=1024):
- if error_text and len(error_text) >= len:
- return error_text[:len//2-3] + " ... " + error_text[-len//2+3:]
+ def _format_vim_error_msg(self, error_text, max_length=1024):
+ if error_text and len(error_text) >= max_length:
+ return error_text[:max_length//2-3] + " ... " + error_text[-max_length//2+3:]
return error_text
def new_net(self, task):
except Exception as e:
return False, "Error trying to get task_id='{}':".format(net_id, str(e))
try:
- self._remove_refresh("get-vm", net_id)
+ self._remove_refresh("get-net", net_id)
result = self.vim.delete_network(net_id)
if sdn_net_id:
with self.db_lock: