def test_find_resources():
    client = ResourceManagerClient()
    field = 'some_field'
    value = 'some_value'
    url = client.endpoint
    response_body = "{\"_items\":[]}"
    httpretty.register_uri(httpretty.GET, url, body=response_body)
    client.find_resources(field, value)
def test_find_resources():
    client = ResourceManagerClient()
    field = 'some_field'
    value = 'some_value'
    url = client.endpoint
    response_body = "{\"_items\":[]}"
    httpretty.register_uri(httpretty.GET, url, body=response_body)
    client.find_resources(field, value)
def test_find_resources():
    client = ResourceManagerClient()
    field = 'some_field'
    value = 'some_value'
    url = client.endpoint + "?where=" + field + "==" + urllib.quote("\"" + value + "\"")
    response_body = "{}"
    httpretty.register_uri(httpretty.GET, url, body=response_body)
    client.find_resources(field, value)
Beispiel #4
0
def test_find_resources():
    client = ResourceManagerClient()
    field = 'some_field'
    value = 'some_value'
    url = client.endpoint + "?where=" + field + "==" + urllib.quote("\"" +
                                                                    value +
                                                                    "\"")
    response_body = "{}"
    httpretty.register_uri(httpretty.GET, url, body=response_body)
    client.find_resources(field, value)
Beispiel #5
0
def addresses():

    state = request.args.get('state')
    ip_type = request.args.get('type')

    if not ip_type:
        ip_type = "public-addresses"
    if ip_type not in ['public-addresses', 'private-addresses']:
        ip_type = "public-addresses"

    if not state:
        state = "all"

    client = ResourceManagerClient(endpoint=RM_ENDPOINT,
                                   resource_type=ip_type)
    all_ips = client.get_all_resources()
    available_ips = client.find_resources(field="owner", value="")

    jobs = get_current_jobs()
    zombie_ips = []

    for ip in all_ips:
        if ip['owner'] and ip['owner'] not in jobs:
            ip.update({'temp_state': 'zombie'})
            zombie_ips.append(ip)

    if state == "zombie":
        ips = zombie_ips
    else:
        ips = all_ips

    zombie_query_string = "type=" + ip_type + "&state=zombie"

    return render_template("general/ipaddresses.html",
                           total_pub_ips=len(all_ips),
                           available_ips=len(available_ips),
                           zombie_ips=len(zombie_ips),
                           zombie_query_string=zombie_query_string,
                           ips=ips, ip_type=ip_type)