示例#1
0
    srv_chk_cnt = 0
    while cps.enabled(nas_comm.yang.get_value('fp_key', 'keys_id')) == False:
        if srv_chk_cnt % srv_chk_rate == 0:
            nas_if.log_info('MAC address config: Front panel port service is not ready')
        time.sleep(1)
        srv_chk_cnt += 1
    nas_if.log_info('Front panel port service is ready after checking %d times' % srv_chk_cnt)

    # Register MAc address allocation handler
    get_mac_hdl = cps.obj_init()

    d = {}
    d['transaction'] = get_mac_cb
    cps.obj_register(get_mac_hdl, nas_comm.yang.get_value('get_mac_key', 'keys_id'), d)

    fp_cache = nas_if.FpPortCache()
    fp_thread = fpMonitorThread(1, 'Front panel port monitor thread')
    fp_thread.daemon = True
    fp_thread.start()

    # Lock to protect front panel port cache updated by thread
    fp_lock = threading.Lock()

    # Wait until a signal is received
    while False == shutdwn:
        signal.pause()

    systemd.daemon.notify("STOPPING=1")
    #Cleanup code here

    # No need to specifically call sys.exit(0).
            str(ifobj.get_attr_data('if/interfaces/interface/name')))
        return

    # create the object
    ch = {'operation': 'rpc', 'change': ifobj.get()}
    cps.transaction([ch])
    nas_if.log_info("Interface Created : " +
                    str(ifobj.get_attr_data('if/interfaces/interface/name')))


if __name__ == '__main__':

    while cps.enabled(nas_comm.yang.get_tbl('keys_id')['fp_key']) == False:
        nas_if.log_err('fetch front panel port info  not ready ')
        time.sleep(1)  #in seconds
    front_panel_ports = nas_if.FpPortCache()
    if front_panel_ports.len() == 0:
        nas_if.log_err('front panel port info  not present')

    while cps.enabled(
            nas_comm.yang.get_tbl('keys_id')['physical_key']) == False:
        nas_if.log_err('physical port info  not ready ')
        time.sleep(1)  #in seconds
    port_cache = nas_if.PhyPortCache()
    if port_cache.len() == 0:
        nas_if.log_err('physical port info  not present')

    if_cache = nas_if.IfCache()

    # walk through the list of physical ports
    for port in port_cache.get_port_list():