示例#1
0
def listen_disconnect_evt(evt, rest_evt):
    global evt_thread

    while SYS.get_sys_thr_flag():
        try:
            evt.wait(1)

            if evt.is_set():
                LOG.debug_log('Get disconnect event')
                evt.clear()
                SYS.disconnect_type = 'disconnect'

                if SYS.get_sys_redraw_flag():
                    SCREEN.draw_event(SYS.disconnect_type)
                    SCREEN.get_screen().clear()
                    SCREEN.screen_exit()

                print '\nCheck monitoring server.'
                os.killpg(os.getpid(), signal.SIGKILL)
                #os.kill(os.getpid(), signal.SIGKILL)

            time.sleep(1)

            rest_evt.wait(1)

            if rest_evt.is_set():
                LOG.debug_log('Get rest error event')
                rest_evt.clear()
                SYS.disconnect_type = 'rest_warn'

                if SYS.get_sys_redraw_flag():
                    SCREEN.draw_event(SYS.disconnect_type)
                    SCREEN.get_screen().clear()
                    SCREEN.screen_exit()

                print '\nCheck client rest server.'
                os.killpg(os.getpid(), signal.SIGKILL)
                #os.kill(os.getpid(), signal.SIGKILL)

            time.sleep(1)
        except:
            LOG.exception_err_write()
示例#2
0
def check_system():
    try:
        # inquiry onos info
        res_code, sys_info = CLI.req_sys_info()

        if res_code != 200:
            SYS.disconnect_type = 'disconnect'
            SCREEN.draw_event(SYS.disconnect_type)
            LOG.debug_log(
                '[SYSTEM_CHECK_THREAD] Rest server does not respond to the request. RES_CODE = ' + str(res_code))
            return

        ret = SYS.changed_sys_info(sys_info)

        if SYS.get_sys_redraw_flag():
            if ret is True:
                SCREEN.draw_system(menu_list)
                SCREEN.draw_event(SYS.disconnect_type)
            else:
                SCREEN.draw_refresh_time(menu_list)
    except:
        LOG.exception_err_write()