Beispiel #1
0
def process_finalize():
    """
    Virtual Infrastructure Manager API - Finalize
    """
    timers.timers_finalize()
    selobj.selobj_finalize()
    debug.debug_finalize()
Beispiel #2
0
def process_finalize():
    """
    Virtual Infrastructure Manager Web Server - Finalize
    """
    tables.tables_finalize()
    database.database_finalize()
    timers.timers_finalize()
    selobj.selobj_finalize()
    debug.debug_finalize()
Beispiel #3
0
def process_finalize():
    """
    Virtual Infrastructure Manager - Finalize
    """
    dor.dor_finalize()
    audits.audits_finalize()
    events.events_finalize()
    directors.directors_finalize()
    tables.tables_finalize()
    database.database_finalize()
    nfvi.nfvi_finalize()
    alarm.alarm_finalize()
    event_log.event_log_finalize()
    schedule.schedule_finalize()
    timers.timers_finalize()
    selobj.selobj_finalize()
    profiler.profiler_finalize()
    debug.debug_finalize()
Beispiel #4
0
    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)

        while True:
            selobj.selobj_dispatch(5000)

    else:
        tcp_connection = TCPConnection('127.0.0.1', '3202')
        tcp_connection.connect('127.0.0.1', '3201')

        while True:
            tcp_connection.send("HI")
            time.sleep(5)

    timers.timers_finalize()
    selobj.selobj_finalize()
    debug.debug_finalize()
Beispiel #5
0
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()