Skip to content
bibiak1 edited this page Dec 28, 2018 · 5 revisions

Welcome to the python-orange-funbox wiki!

  1. Let’s initialize package first:

    import funbox
    funbox = funbox.FunBox("http://192.168.1.1", "admin")
    
  2. Get some device informations

    import json
    info = funbox.DeviceInfo()
    print json.dumps(info, indent=4)
    
  3. Get some statistics

    wan = funbox.NMC.getWANStatus()
    dsl_mibs = funbox.NeMo.Intf.data.getMIBs('dsl')
    dsl0_stats = funbox.NeMo.Intf.dsl0.getDSLStats()
    wifi_stats = funbox.NMC.Wifi.getStats()
    
    for key in ['DownstreamCurrRate', 'UpstreamCurrRate']:
        print("%20s: %s" % (key, str(dsl_mibs['result']['status']['dsl']['dsl0'][key])))
    for key in ['TransmitBlocks', 'ReceiveBlocks']:
        print("%20s: %16s" % (key, str(dsl0_stats['result']['status'][key])))
    for key in ['TxBytes', 'RxBytes']:
        print("%20s: %16s" % (key, str(wifi_stats['result']['data'][key])))
  4. Show all hosts defined on Orange FunBox

    hosts = funbox.Hosts.getDevices()
    for host in hosts['result']['status']:
        name = host['hostName']
        physAddress = host['physAddress']
        if 'IPAddress' in host:
            ipAddress = host['ipAddress']
        else:
            ipAddress = ""
        print "\t%s [%s] :: %s :: %s" % (name, json.dumps(host['names'], sort_keys=True, separators=(',', ': ')), physAddress, ipAddress)
  5. Show all devices and connected hosts

    hosts = funbox.Devices.get()
    for type in hosts['result']['status']:
        print type + ' :::'
        for host in hosts['result']['status'][type]:
            name = host['Name']
            DeviceType = host['DeviceType']
            physAddress = host['PhysAddress']
            Layer2Interface = host['Layer2Interface']
            if 'IPAddress' in host:
                ipAddress = host['IPAddress']
            else:
                ipAddress = ""
            print "\t%s (%s) [%s] :: %s :: %s (%s)" % (name, DeviceType, json.dumps(host['Names'], sort_keys=True, separators=(',', ': ')), physAddress, ipAddress, Layer2Interface)
  6. Reconnect router

    funbox.reconnect()
    
  7. Restart router

    funbox.restart()
    
  8. Check for upgrades

    funbox.NMC.checkForUpgrades()
    
Clone this wiki locally