def process_initialize(): """ Virtual Infrastructure Manager - Initialize """ init_complete = True debug.debug_initialize(config.CONF['debug'], 'VIM') profiler.profiler_initialize() selobj.selobj_initialize() timers.timers_initialize(PROCESS_TICK_INTERVAL_IN_MS, PROCESS_TICK_MAX_DELAY_IN_MS, PROCESS_TICK_DELAY_DEBOUNCE_IN_MS) schedule.schedule_initialize() event_log.event_log_initialize(config.CONF['event-log']) alarm.alarm_initialize(config.CONF['alarm']) if not nfvi.nfvi_initialize(config.CONF['nfvi']): DLOG.info("nfvi_initialize failed") init_complete = False database.database_initialize(config.CONF['database']) database.database_migrate_data() tables.tables_initialize() directors.directors_initialize() events.events_initialize() audits.audits_initialize() dor.dor_initialize() network_rebalance.nr_initialize() return init_complete
def process_initialize(): """ Test - Process Initialize """ utf8_writer = codecs.getwriter('utf8') sys.stdout = utf8_writer(sys.stdout) debug.debug_initialize(config.CONF['debug'], 'NFV-TEST') forensic.forensic_initialize()
def process_initialize(): """ Virtual Infrastructure Manager Web Server - Initialize """ debug.debug_initialize(config.CONF['debug'], 'VIM-WEB') selobj.selobj_initialize() timers.timers_initialize(PROCESS_TICK_INTERVAL_IN_MS, PROCESS_TICK_MAX_DELAY_IN_MS, PROCESS_TICK_DELAY_DEBOUNCE_IN_MS) database.database_initialize(config.CONF['database']) tables.tables_initialize()
def process_initialize(): """ Virtual Infrastructure Manager API - Initialize """ debug.debug_initialize(config.CONF['debug'], 'VIM-API') selobj.selobj_initialize() timers.timers_initialize(PROCESS_TICK_INTERVAL_IN_MS, PROCESS_TICK_MAX_DELAY_IN_MS, PROCESS_TICK_DELAY_DEBOUNCE_IN_MS) ip = config.CONF['vim-api']['host'] port = int(config.CONF['vim-api']['port']) # In order to support IPv6, set the address family before creating the server. simple_server.WSGIServer.address_family = get_address_family(ip) wsgi = simple_server.make_server(ip, port, Application(), handler_class=get_handler_cls()) selobj.selobj_add_read_obj(wsgi, process_event_handler, wsgi)
def process_initialize(): """ Virtual Infrastructure Manager - Initialize """ debug.debug_initialize(config.CONF['debug'], 'VIM') profiler.profiler_initialize() selobj.selobj_initialize() timers.timers_initialize(PROCESS_TICK_INTERVAL_IN_MS, PROCESS_TICK_MAX_DELAY_IN_MS, PROCESS_TICK_DELAY_DEBOUNCE_IN_MS) schedule.schedule_initialize() event_log.event_log_initialize(config.CONF['event-log']) alarm.alarm_initialize(config.CONF['alarm']) nfvi.nfvi_initialize(config.CONF['nfvi']) database.database_initialize(config.CONF['database']) database.database_migrate_data() tables.tables_initialize() directors.directors_initialize() events.events_initialize() audits.audits_initialize() dor.dor_initialize()
from nfv_common.tcp._tcp_connection import TCPConnection from nfv_common.tcp._tcp_server import TCPServer def message_handler(client_connection, msg): print("Received Message: %s" % msg) if __name__ == '__main__': CONF = dict() CONF['debug'] = dict() CONF['debug']['config_file'] = '/etc/nfv/vim/debug.ini' CONF['debug']['handlers'] = 'stdout' debug.debug_initialize(CONF['debug']) selobj.selobj_initialize() timers.timers_initialize(500, 1000, 1000) parser = argparse.ArgumentParser() parser.add_argument('-s', '--server', help='server-side', action="store_true") parser.add_argument('-c', '--client', help='client-side', action="store_true") args = parser.parse_args() if args.server:
def _thread_main(thread_name, progress_marker, debug_config, thread_worker, work_queue): """ Main loop for the thread """ from ctypes import util PR_SET_PDEATHSIG = 1 PR_SET_NAME = 15 PR_SIGKILL = 9 libc = ctypes.cdll.LoadLibrary(util.find_library("c")) result = libc.prctl(PR_SET_NAME, thread_name) if 0 != result: DLOG.error("PRCTL set-name failed with error=%s." % result) sys.exit(200) result = libc.prctl(PR_SET_PDEATHSIG, PR_SIGKILL) if 0 != result: DLOG.error("PRCTL set-parent-death-signal failed with error=%s." % result) sys.exit(201) signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGHUP, signal.SIG_IGN) signal.signal(signal.SIGUSR1, signal.SIG_IGN) signal.signal(signal.SIGUSR2, signal.SIG_IGN) try: thread_state = ThreadState() debug.debug_initialize(debug_config, thread_name=thread_name) selobj.selobj_initialize() timers.timers_initialize(thread_worker.tick_interval_in_ms, thread_worker.tick_max_delay_in_ms, thread_worker.tick_delay_debounce_in_ms) DLOG.debug("Thread %s: initializing." % thread_name) thread_worker.initialize() selobj.selobj_add_read_obj(work_queue.selobj, _thread_dispatch_work, thread_state, thread_worker, work_queue) DLOG.debug("Thread %s: started." % thread_name) while thread_state.stay_on: progress_marker.increment() selobj.selobj_dispatch(thread_worker.tick_interval_in_ms) timers.timers_schedule() if not timers.timers_scheduling_on_time(): DLOG.info("Thread %s: not scheduling on time" % thread_name) if thread_state.debug_reload: debug.debug_reload_config() thread_state.debug_reload = False except KeyboardInterrupt: print("Keyboard Interrupt received.") pass except Exception as e: DLOG.exception("%s" % e) sys.exit(202) finally: DLOG.info("Thread %s: shutting down." % thread_name) thread_worker.finalize() timers.timers_finalize() selobj.selobj_finalize() DLOG.info("Thread %s: shutdown." % thread_name) debug.debug_finalize()
callback=_task_coroutine_callback()) return _test_result @unit_test('CO-ROUTINE_FUNCTION_TIMER_CALL') def test_coroutine_timer_function_call(self): self._scheduler.add_task(_task_coroutine_with_timer, 'arg1', callback=_task_coroutine_callback()) return _test_result def run(self): six.print_("TASKS UNIT TESTS", end='\n') six.print_("================", end='\n') self.test_normal_function_call() self.test_coroutine_function_call() self.test_coroutine_timer_function_call() if __name__ == '__main__': debug.debug_initialize(config.CONF['debug']) selobj.selobj_initialize() timers.timers_initialize(500, 1000, 1000) unit_test = UnitTest() unit_test.run() timers.timers_finalize() selobj.selobj_finalize() debug.debug_finalize()
def process_main(): """ Virtual Infrastructure Manager Manage - Main """ try: parser = argparse.ArgumentParser( usage=('nfv-vim-manage <command> [<args>] \n' + ' where command is one of \n' + ' db-dump-data dump data from database \n' + ' db-load-data load data into database \n')) parser.add_argument('command', help='command to be run') args = parser.parse_args(sys.argv[1:2]) debug.debug_initialize(None, 'VIM-DB') if 'db-dump-data' == args.command: parser = argparse.ArgumentParser( description='Dump data from database') parser.add_argument('-d', '--database', help='database directory', required=True) parser.add_argument('-f', '--filename', help='dump data to file', required=True) args = parser.parse_args(sys.argv[2:]) if args.database is None or args.filename is None: parser.print_help() database_config = dict() database_config['database_dir'] = args.database database.database_initialize(database_config) database.database_dump_data(args.filename) database.database_finalize() print("Database data dump....... [complete]") elif 'db-load-data' == args.command: parser = argparse.ArgumentParser( description='Load data into database') parser.add_argument('-d', '--database', help='database directory', required=True) parser.add_argument('-f', '--filename', help='load data from file', required=True) args = parser.parse_args(sys.argv[2:]) if args.database is None or args.filename is None: parser.print_help() database_config = dict() database_config['database_dir'] = args.database database.database_initialize(database_config) database.database_load_data(args.filename) database.database_finalize() print("Database data load....... [complete]") else: parser.print_help() except KeyboardInterrupt: print("Keyboard Interrupt received.") pass except Exception as e: print(e) sys.exit(1) finally: debug.debug_finalize()