X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=openvimd.py;h=1651df7f56dc5b415c5179630e03907281b1eb87;hb=refs%2Fchanges%2F96%2F996%2F1;hp=5dad98b2ee055b7f777f7de9ff7ff16ec6197308;hpb=f13617a350092613d22a39997fb00afda7da209c;p=osm%2Fopenvim.git diff --git a/openvimd.py b/openvimd.py index 5dad98b..1651df7 100755 --- a/openvimd.py +++ b/openvimd.py @@ -30,9 +30,9 @@ and host controllers __author__="Alfonso Tierno" __date__ ="$10-jul-2014 12:07:15$" -__version__="0.4.8-r495" -version_date="Sep 2016" -database_version="0.7" #expected database schema version +__version__="0.5.1-r518" +version_date="Jan 2017" +database_version="0.8" #expected database schema version import httpserver import auxiliary_functions as af @@ -69,6 +69,8 @@ def load_configuration(configuration_file): 'log_level': "DEBUG", 'log_level_db': "ERROR", 'log_level_of': 'ERROR', + 'bridge_ifaces': {}, + 'network_type': 'ovs', } try: #First load configuration from configuration file @@ -119,10 +121,11 @@ def create_database_connection(config_dic): def usage(): print "Usage: ", sys.argv[0], "[options]" print " -v|--version: prints current version" - print " -c|--config [configuration_file]: loads the configuration file (default: openvimd.cfg)" + print " -c|--config FILE: loads the configuration file (default: openvimd.cfg)" print " -h|--help: shows this help" - 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 " -p|--port PORT: changes port number and overrides the port number in the configuration file (default: 908)" + print " -P|--adminport PORT: changes admin port number and overrides the port number in the configuration file (default: not listen)" + print " --dbname NAME: changes db_name and overrides the db_name in the configuration 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") @@ -142,7 +145,7 @@ if __name__=="__main__": logger = logging.getLogger('openmano') logger.setLevel(logging.DEBUG) try: - opts, args = getopt.getopt(sys.argv[1:], "hvc:p:P:", ["config=", "help", "version", "port=", "adminport=", "log-file="]) + opts, args = getopt.getopt(sys.argv[1:], "hvc:p:P:", ["config=", "help", "version", "port=", "adminport=", "log-file=", "dbname="]) except getopt.GetoptError, err: # print help information and exit: logger.error("%s. Type -h for help", err) # will print something like "option -a not recognized" @@ -153,6 +156,7 @@ if __name__=="__main__": port_admin = None config_file = 'openvimd.cfg' log_file = None + db_name = None for o, a in opts: if o in ("-v", "--version"): @@ -168,6 +172,8 @@ if __name__=="__main__": port = a elif o in ("-P", "--adminport"): port_admin = a + elif o in ("-P", "--dbname"): + db_name = a elif o == "--log-file": log_file = a else: @@ -197,8 +203,12 @@ if __name__=="__main__": logger.setLevel(getattr(logging, config_dic['log_level'])) logger.critical("Starting openvim server command: '%s'", sys.argv[0]) #override parameters obtained by command line - if port is not None: config_dic['http_port'] = port - if port_admin is not None: config_dic['http_admin_port'] = port_admin + if port: + config_dic['http_port'] = port + if port_admin: + config_dic['http_admin_port'] = port_admin + if db_name: + config_dic['db_name'] = db_name #check mode if 'mode' not in config_dic: @@ -206,7 +216,8 @@ if __name__=="__main__": #allow backward compatibility of test_mode option if 'test_mode' in config_dic and config_dic['test_mode']==True: config_dic['mode'] = 'test' - if config_dic['mode'] == 'development' and ( 'development_bridge' not in config_dic or config_dic['development_bridge'] not in config_dic.get("bridge_ifaces",None) ): + if config_dic['mode'] == 'development' and config_dic['network_type'] == 'bridge' and \ + ( 'development_bridge' not in config_dic or config_dic['development_bridge'] not in config_dic.get("bridge_ifaces",None) ): logger.error("'%s' is not a valid 'development_bridge', not one of the 'bridge_ifaces'", config_file) exit(-1)