global url_base
global logger
url_base="/openmano"
+logger = None
HTTP_Bad_Request = 400
HTTP_Unauthorized = 401
global mydb
global logger
#initialization
- logger = logging.getLogger('openmano.http')
+ if not logger:
+ logger = logging.getLogger('openmano.http')
threading.Thread.__init__(self)
self.host = host
self.port = port #Port where the listen service must be started
global global_config
global vimconn_imported
+global logger
vimconn_imported={} #dictionary with VIM type as key, loaded module as value
-logger = logging.getLogger('mano.nfvo')
+logger = logging.getLogger('openmano.nfvo')
class NfvoException(Exception):
def __init__(self, message, http_code):
"log_level": log_level_schema,
"log_socket_level": log_level_schema,
"log_level_db": log_level_schema,
- "log_level_vimconn": log_level_schema,
+ "log_level_vim": log_level_schema,
"log_level_nfvo": log_level_schema,
+ "log_level_http": log_level_schema,
+ "log_file_db": path_schema,
+ "log_file_vim": path_schema,
+ "log_file_nfvo": path_schema,
+ "log_file_http": path_schema,
"log_socket_host": nameshort_schema,
"log_socket_port": port_schema,
"log_file": path_schema,
#logging parameters for internal file stororage
#choose among: DEBUG, INFO, WARNING, ERROR, CRITICAL
log_level: DEBUG #general log levels for internal logging
-log_level_db: DEBUG #database log levels
-log_level_vimconn: DEBUG #VIM connection log levels
-log_level_nfvo: DEBUG #Main engine log levels
#standard output is used unless 'log_file' is specify
#log_file: /var/log/openmano/openmano.log
+#individual loggin settings
+#log_level_db: DEBUG #database log levels
+#log_file_db: /var/log/openmano/openmano_db.log
+#log_level_vim: DEBUG #VIM connection log levels
+#log_file_vim: /var/log/openmano/openmano_vimconn.log
+#log_level_nfvo: DEBUG #Main engine log levels
+#log_file_nfvo: /var/log/openmano/openmano_nfvo.log
+#log_level_http: DEBUG #Main engine log levels
+#log_file_http: /var/log/openmano/openmano_http.log
+
#Uncomment to send logs via IP to an external host
#log_socket_host: localhost
log_socket_port: 9022
'''
__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ ="$26-aug-2014 11:09:29$"
-__version__="0.4.51-r493"
+__version__="0.4.52-r494"
version_date="Sep 2016"
database_version="0.13" #expected database schema version
print( " -p|--port [port_number]: changes port number and overrides the port number in the configuration file (default: 9090)")
print( " -P|--adminport [port_number]: changes admin port number and overrides the port number in the configuration file (default: 9095)")
#print( " -V|--vnf-repository: changes the path of the vnf-repository and overrides the path in the configuration file")
- print( " --log-socket-host: send logs to this host")
- print( " --log-socket-port: send logs using this port (default: 9022)")
- print( " --log-file: send logs to this file")
+ print( " --log-socket-host HOST: send logs to this host")
+ print( " --log-socket-port PORT: send logs using this port (default: 9022)")
+ print( " --log-file FILE: send logs to this file")
return
if __name__=="__main__":
# Read parameters and configuration file
try:
#load parameters and configuration
- opts, args = getopt.getopt(sys.argv[1:], "hvc:V:p:P:", ["config", "help", "version", "port", "vnf-repository", "adminport", "log-socket-host=", "log-socket-port=", "log-file="])
+ opts, args = getopt.getopt(sys.argv[1:], "hvc:V:p:P:", ["config=", "help", "version", "port=", "vnf-repository=", "adminport=", "log-socket-host=", "log-socket-port=", "log-file="])
port=None
port_admin = None
config_file = 'openmanod.cfg'
logger.setLevel(getattr(logging, global_config['log_level']))
logger.critical("Starting openmano server command: '%s'", sys.argv[0])
+ for log_module in ("nfvo", "http", "vim", "db"):
+ log_level_module = "log_level_" + log_module
+ log_file_module = "log_file_" + log_module
+ logger_module = logging.getLogger('openmano.' + log_module)
+ if log_level_module in global_config:
+ logger_module.setLevel(global_config[log_level_module])
+ if log_file_module in global_config:
+ try:
+ file_handler= logging.handlers.RotatingFileHandler(global_config[log_file_module], maxBytes=100e6, backupCount=9, delay=0)
+ file_handler.setFormatter(log_formatter_simple)
+ logger_module.addHandler(file_handler)
+ except IOError as e:
+ raise LoadConfigurationException("Cannot open logging file '{}': {}. Check folder exist and permissions".format(global_config[log_file_module], str(e)) )
+ global_config["logger_"+log_module] = logger_module
+ #httpserver.logger = global_config["logger_http"]
+ #nfvo.logger = global_config["logger_nfvo"]
+
# Initialize DB connection
mydb = nfvo_db.nfvo_db(log_level=global_config["log_level_db"]);
if mydb.connect(global_config['db_host'], global_config['db_user'], global_config['db_passwd'], global_config['db_name']) == -1:
self.user = user
self.passwd = passwd
self.config = config
- self.logger = logging.getLogger('mano.vim')
+ self.logger = logging.getLogger('openmano.vim')
self.logger.setLevel( getattr(logging, log_level) )
if not self.url_admin: #try to use normal url
self.url_admin = self.url
self.k_creds['password'] = passwd
self.n_creds['api_key'] = passwd
self.reload_client = True
- self.logger = logging.getLogger('mano.vim.openstack')
+ self.logger = logging.getLogger('openmano.vim.openstack')
def __setitem__(self,index, value):
'''Set individuals parameters
vimconn.vimconnector.__init__(self, uuid, name, tenant_id, tenant_name, url, url_admin, user, passwd, log_level, config)
self.tenant = None
self.headers_req = {'content-type': 'application/json'}
- self.logger = logging.getLogger('mano.vim.openvim')
+ self.logger = logging.getLogger('openmano.vim.openvim')
if tenant_id:
self.tenant = tenant_id
self.user = user
self.passwd = passwd
self.config = config
- self.logger = logging.getLogger('mano.vim.vmware')
-
- formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
- ch = logging.StreamHandler()
- ch.setLevel(log_level)
- ch.setFormatter(formatter)
- self.logger.addHandler(ch)
- self.logger.setLevel( getattr(logging, log_level))
+ self.logger = logging.getLogger('openmano.vim.vmware')
+
+# formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+# ch = logging.StreamHandler()
+# ch.setLevel(log_level)
+# ch.setFormatter(formatter)
+# self.logger.addHandler(ch)
+# self.logger.setLevel( getattr(logging, log_level))
# self.logger = logging.getLogger('mano.vim.vmware')