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(): """ 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()
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: tcp_server = TCPServer('127.0.0.1', '3201', message_handler)
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()