Exemple #1
0
def runtests():
    """Run the dpu port status and speed tests"""

    _settings = getsettings()
    abbportal = portal.AussiePortal(_settings['username'],
                                    _settings['password'],
                                    debug=False)

    customer = abbportal.customer()

    services = []
    for service_type in customer['services']:
        for service in customer['services'][service_type]:
            service_id = service['service_id']
            services.append((service_type, service_id))

    dpu = abbportal.dpuportstatus(service_id)
    print(dpu, file=sys.stderr, flush=True)

    # run the speed test
    # os.system('docker run --rm -e TZ=Australia/Sydney abb-speedtest')
    os.system('/usr/bin/abb-speedtest')
#!/usr/bin/env python

import os
import aussiebb.portal as portal

p = portal.AussiePortal(os.environ.get('AUSSIE_USERNAME'),
                        os.environ.get('AUSSIE_PASSWORD'),
                        debug=False)
c = p.customer()

services = []
for service_type in c['services']:
    for service in c['services'][service_type]:
        service_id = service['service_id']
        services.append((service_type, service_id))

dpu = p.dpuportstatus(service_id)
print(dpu)
Exemple #3
0
def saveresults():
    """
    Get the results from AussieBB and save the locally.
    Aussie doesn't keep all of them, so it's better we do.
    """

    _settings = getsettings()
    abbportal = portal.AussiePortal(_settings['username'],
                                    _settings['password'],
                                    debug=False)

    customer = abbportal.customer()

    services = []
    for service_type in customer['services']:
        for service in customer['services'][service_type]:
            service_id = service['service_id']
            services.append((service_type, service_id))

    # get and populate all the line sync / dpu port status test results
    tests = abbportal.tests(service_id)
    results = runsql('select id from dpuportstatusresults')
    ids = []
    for i in results:
        ids.append(i[0])

    for result in tests:
        if (result['type']) == 'DPU Port Status':
            if result['id'] not in ids:
                output = abbportal.testresult(service_id, result['id'])
                linerate = output['output']['accessLineRate']
                if linerate in ('N/A', "Not Found", None):
                    lineup = 0
                    linedown = 0
                else:
                    linedown = linerate.split('/')[0].replace('>', '')
                    lineup = linerate.split('/')[1].split(' ')[0]
                # pylint: disable=line-too-long
                insertline = (
                    "insert into dpuportstatusresults values ('%s', '%s', '%s', '%s', '%s', %s, %s, '%s', '%s')"
                    # pylint: enable=line-too-long
                    % (output['id'], output['result'],
                       output['output']['syncState'],
                       output['output']['operationalState'],
                       output['output']['reversePowerState'], lineup, linedown,
                       output['completed_at'], output['status']))
                print(insertline, file=sys.stderr, flush=True)
                runsql(insertline)

    # get and populate all the spped test results
    tests = abbportal.speedtestresults(service_id)
    results = runsql('select id from speedtestresults')
    ids = []
    for i in results:
        ids.append(i[0])

    for result in tests:
        if result['id'] not in ids:
            insertline = (
                "insert into speedtestresults values ('%s', '%s', '%s', '%s', '%s', '%s')"
                % (result['id'], result['server'], result['latencyMs'],
                   result['downloadSpeedKbps'], result['uploadSpeedKbps'],
                   result['date']))
            print(insertline, file=sys.stderr, flush=True)
            runsql(insertline)