'''
__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ ="$26-aug-2014 11:09:29$"
-__version__="0.4.44-r482"
-version_date="Jul 2016"
-database_version="0.11" #expected database schema version
+__version__="0.4.58-r501"
+version_date="Sep 2016"
+database_version="0.14" #expected database schema version
import httpserver
import time
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_level_db': 'ERROR',
- 'log_level_vimconn': 'DEBUG',
- 'log_level_nfvo': 'DEBUG',
'log_socket_port': 9022,
}
try:
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'
global_config["console_port_iterator"] = console_port_iterator
global_config["console_thread"]={}
global_config["console_ports"]={}
+ if not global_config["http_console_host"]:
+ global_config["http_console_host"] = global_config["http_host"]
+ if global_config["http_host"]=="0.0.0.0":
+ global_config["http_console_host"] = socket.gethostname()
#Configure logging STEP 2
if "log_host" in global_config:
file_handler= logging.handlers.RotatingFileHandler(global_config["log_file"], maxBytes=100e6, backupCount=9, delay=0)
file_handler.setFormatter(log_formatter_simple)
logger.addHandler(file_handler)
- logger.debug("moving logs to '%s'", global_config["log_file"])
- #remove initial strema handler
+ #logger.debug("moving logs to '%s'", global_config["log_file"])
+ #remove initial stream handler
logging.root.removeHandler(logging.root.handlers[0])
+ print ("logging on '{}'".format(global_config["log_file"]))
except IOError as e:
raise LoadConfigurationException("Cannot open logging file '{}': {}. Check folder exist and permissions".format(global_config["log_file"], str(e)) )
#logging.basicConfig(level = getattr(logging, global_config.get('log_level',"debug")))
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"]);
+ mydb = nfvo_db.nfvo_db();
if mydb.connect(global_config['db_host'], global_config['db_user'], global_config['db_passwd'], global_config['db_name']) == -1:
logger.critical("Cannot connect to database %s at %s@%s", global_config['db_name'], global_config['db_user'], global_config['db_host'])
exit(-1)