<commit_before>"""
Enable asyncronous HTTP requests.
"""
import argparse
import sys
import time

import requests

from concurrent.futures import ThreadPoolExecutor

from requests_futures.sessions import FuturesSession

from osreporter.db import data
from osreporter.db import elasticsearch
from osreporter.db import rethinkdb
from osreporter.http import headers
from osreporter.openstack import authentication


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--db', help="Select the backend to write to.")
    args = parser.parse_args()

    # Authenticate against OpenStack
    auth = authentication.Authenticate().do(version=2)
    tenant = auth["access"]["token"]["tenant"]["id"]
    token = auth["access"]["token"]["id"]

    session = FuturesSession(executor=ThreadPoolExecutor(max_workers=8))
    session.headers.update(headers.common_headers(token))

    start_time = time.time()

    # Asyncronous requests to the OpenStack API's.
    req_a = session.get("http://127.0.0.1:8774/v2/{0}/servers/detail?all_tenants=1".format(tenant))
    req_b = session.get("http://127.0.0.1:8774/v2/{0}/flavors/detail".format(tenant))
    req_c = session.get("http://127.0.0.1:35357/v2.0/tenants")
    req_d = session.get("http://127.0.0.1:35357/v2.0/users")
    req_e = session.get("http://127.0.0.1:8776/v1/{0}/volumes/detail?all_tenants=1".format(tenant))<commit_msg>config support for openstack api access<commit_after>"""
Enable asyncronous HTTP requests.
"""
import argparse
import sys
import time

import requests

from concurrent.futures import ThreadPoolExecutor

from requests_futures.sessions import FuturesSession

from osreporter.config import yaml
from osreporter.db import data
from osreporter.db import elasticsearch
from osreporter.db import rethinkdb
from osreporter.http import headers
from osreporter.openstack import authentication


def main():
    # Read config
    config = yaml.read('/etc/osreporter.yaml')
    schema = config['openstack']['schema']
    openstack_api = config['openstack']['address']

    parser = argparse.ArgumentParser()
    parser.add_argument('--db', help="Select the backend to write to.")
    args = parser.parse_args()

    # Authenticate against OpenStack
    auth = authentication.Authenticate().do(version=2)
    tenant = auth["access"]["token"]["tenant"]["id"]
    token = auth["access"]["token"]["id"]

    session = FuturesSession(executor=ThreadPoolExecutor(max_workers=8))
    session.headers.update(headers.common_headers(token))

    start_time = time.time()

    # Asyncronous requests to the OpenStack API's.
    req_a = session.get("{0}://{1}:8774/v2/{2}/servers/detail?all_tenants=1".format(schema, address, tenant))
    req_b = session.get("{0}://{1}:8774/v2/{2}/flavors/detail".format(schema, address, tenant))
    req_c = session.get("{0}://{1}:35357/v2.0/tenants".format(schema, address))
    req_d = session.get("{0}://{1}:35357/v2.0/users".format(schema, address))
    req_e = session.get("{0}://{1}:8776/v1/{2}/volumes/detail?all_tenants=1".format(schema, address, tenant))
{'fraction_non_alphanumeric': 0.1475677440417891, 'fraction_numerical': 0.03656545870062031, 'mean_word_length': 4.814041745730551, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6618370', 'n_tokens_mistral': 1028, 'n_tokens_neox': 1005, 'n_words': 192}