Beispiel #1
0
def _get_infoblox(**api_opts):
    config = _get_config(**api_opts)
    # TODO: perhaps cache in __opts__
    cache_key = 'infoblox_session_{0},{1},{2}'.format(
        config['api_url'], config['api_user'], config['api_key'])
    if cache_key in cache:
        timedelta = int(time.time()) - cache[cache_key]['time']
        if cache[cache_key]['obj'] and timedelta < 60:
            return cache[cache_key]['obj']
    c = {}
    c['time'] = int(time.time())
    c['obj'] = libinfoblox.Session(api_sslverify=config['api_sslverify'], api_url=config['api_url'],
                                   api_user=config['api_user'], api_key=config['api_key'])
    cache[cache_key] = c
    return c['obj']
Beispiel #2
0
def _get_infoblox(**api_opts):
    config = _get_config(**api_opts)
    # TODO: perhaps cache in __opts__
    cache_key = "infoblox_session_{0},{1},{2}".format(
        config["api_url"], config["api_user"], config["api_key"]
    )
    if cache_key in cache:
        timedelta = int(time.time()) - cache[cache_key]["time"]
        if cache[cache_key]["obj"] and timedelta < 60:
            return cache[cache_key]["obj"]
    c = {}
    c["time"] = int(time.time())
    c["obj"] = libinfoblox.Session(
        api_sslverify=config["api_sslverify"],
        api_url=config["api_url"],
        api_user=config["api_user"],
        api_key=config["api_key"],
    )
    cache[cache_key] = c
    return c["obj"]