def _check_neutron_api():
    neutron = utils.Neutron()
    neutron.add_argument('-w', dest='warning', type=int, default=5,
                         help='Warning timeout for neutron APIs calls')
    neutron.add_argument('-c', dest='critical', type=int, default=10,
                         help='Critical timeout for neutron APIs calls')
    options, args, client = neutron.setup()

    elapsed, networks = utils.timeit(client.list_networks)
    if not networks or len(networks.get('networks', [])) <= 0:
        utils.critical("Unable to contact neutron API.")

    if elapsed > options.critical:
        utils.critical("Get networks took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get networks took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get networks, neutron API is working: "
                 "list %d networks in %d seconds.|response_time=%d" %
                 (len(networks['networks']), elapsed, elapsed))
dataset/ETHPy150Open openstack/monitoring-for-openstack/oschecks/neutron.py/_check_neutron_api/original