def run(self): #create the logger try: self._smgr_log = ServerMgrlogger() except: print "Error Creating logger object" # Connect to the cluster-servers database try: self._status_serverDb = db( self._smgr_main._args.server_manager_base_dir+self._smgr_main._args.database_name) except: self._smgr_log.log(self._smgr_log.DEBUG, "Error Connecting to Server Database %s" % (self._smgr_main._args.server_manager_base_dir+self._smgr_main._args.database_name)) exit() #set the status related handlers status_bottle_app = Bottle() status_bottle_app.route('/server_status', 'POST', self.put_server_status) status_bottle_app.route('/server_status', 'PUT', self.put_server_status) self._base_obj = self._status_thread_config['base_obj'] try: bottle.run(status_bottle_app, host=self._status_thread_config['listen_ip'], port=self._status_thread_config['listen_port']) except Exception as e: # cleanup gracefully exit()
def run(self): #create the logger try: self._smgr_log = ServerMgrlogger() except: print "Error Creating logger object" # Connect to the cluster-servers database try: self._status_serverDb = db( self._smgr_main._args.server_manager_base_dir + self._smgr_main._args.database_name) except: self._smgr_log.log( self._smgr_log.DEBUG, "Error Connecting to Server Database %s" % (self._smgr_main._args.server_manager_base_dir + self._smgr_main._args.database_name)) exit() #set the status related handlers status_bottle_app = Bottle() status_bottle_app.route('/server_status', 'POST', self.put_server_status) status_bottle_app.route('/server_status', 'PUT', self.put_server_status) self._base_obj = self._status_thread_config['base_obj'] try: bottle.run(status_bottle_app, host=self._status_thread_config['listen_ip'], port=self._status_thread_config['listen_port']) except Exception as e: # cleanup gracefully exit()
def __init__(self, serverdb=None, log_file=None): if serverdb: self._serverDb = serverdb else: self._serverDb = db(DEF_SERVER_DB_LOCATION) self._smgr_log = ServerMgrlogger()
def __init__(self, args_str=None): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument( "-t", "--translation_dict_location", help= ("The location of the Parameter Translation Dictionary," " default /opt/contrail/server_manager/client/parameter-translation-dict.json" )) parser.add_argument( "-ut", "--upgrade_translation_dict_location", help= ("The location of the Upgrade Parameter Translation Dictionary," " default /opt/contrail/server_manager/client/upgrade-parameter-translation-dict.json" )) parser.add_argument( "-d", "--db_location", help=("The location of the Server Manager Database to convert," " default /etc/contrail_smgr/smgr_data.db")) serverMgrCfg = { 'db_location': _DEF_SMGR_DB_LOCATION, 'translation_dict_location': _DEF_TRANS_DICT_LOCATION, 'upgrade_translation_dict_location': _DEF_UPGRADE_TRANS_DICT_LOCATION } parser.set_defaults(**serverMgrCfg) self._args = None self._args = parser.parse_args(args_str) try: self._serverDb = db(self._args.db_location) except Exception as e: print "Cannot find DB at: " + str(self._args.db_location) print "Error: " + str(e) exit() self.translation_dict = {} self.upgrade_translation_dict = {} try: with open(str(self._args.translation_dict_location)) as json_file: self.translation_dict = json.load(json_file) self.old_to_new_dict = self._trans_dict_convert( self.translation_dict) except Exception as e: print "Cannot find translation dictionary at: " + str( self._args.translation_dict_location) print "Error: " + str(e) exit() try: with open(str(self._args.upgrade_translation_dict_location) ) as json_file: self.upgrade_translation_dict = json.load(json_file) self.upgrade_dict = self._upgrade_trans_dict_convert( self.upgrade_translation_dict) except Exception as e: print "Cannot find translation dictionary at: " + str( self._args.translation_dict_location) print "Error: " + str(e) exit()
def __init__(self, args_str=None): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument( "-t", "--translation_dict_location", help=( "The location of the Parameter Translation Dictionary," " default /opt/contrail/server_manager/client/parameter-translation-dict.json")) parser.add_argument( "-ut", "--upgrade_translation_dict_location", help=( "The location of the Upgrade Parameter Translation Dictionary," " default /opt/contrail/server_manager/client/upgrade-parameter-translation-dict.json")) parser.add_argument( "-d", "--db_location", help=( "The location of the Server Manager Database to convert," " default /etc/contrail_smgr/smgr_data.db")) serverMgrCfg = { 'db_location': _DEF_SMGR_DB_LOCATION, 'translation_dict_location': _DEF_TRANS_DICT_LOCATION, 'upgrade_translation_dict_location': _DEF_UPGRADE_TRANS_DICT_LOCATION } parser.set_defaults(**serverMgrCfg) self._args = None self._args = parser.parse_args(args_str) try: self._serverDb = db(self._args.db_location) except Exception as e: print "Cannot find DB at: " + str(self._args.db_location) print "Error: " + str(e) exit() self.translation_dict = {} self.upgrade_translation_dict = {} try: with open(str(self._args.translation_dict_location)) as json_file: self.translation_dict = json.load(json_file) self.old_to_new_dict = self._trans_dict_convert(self.translation_dict) except Exception as e: print "Cannot find translation dictionary at: " + str(self._args.translation_dict_location) print "Error: " + str(e) exit() try: with open(str(self._args.upgrade_translation_dict_location)) as json_file: self.upgrade_translation_dict = json.load(json_file) self.upgrade_dict = self._upgrade_trans_dict_convert(self.upgrade_translation_dict) except Exception as e: print "Cannot find translation dictionary at: " + str(self._args.translation_dict_location) print "Error: " + str(e) exit()