#!/usr/bin/env python

from maas_common import (get_auth_ref, get_glance_client, status_err,
                         status_ok, metric)
import sys

IMAGE_ENDPOINT = 'http://127.0.0.1:9292'


def check(token):
    glance = get_glance_client(token, IMAGE_ENDPOINT)
    if glance is None:
        status_err('Unable to obtain valid glance client, cannot proceed')

    status_ok()
    metric('glance_api_local_status', 'uint32', 1)


def main():
    auth_ref = get_auth_ref()
    token = auth_ref['token']['id']
    check(token)


if __name__ == "__main__":
    main()

@@ -45,321 +45,1040 @@
 rt (
-get_auth_ref, get_glance_client, status_err,%0A                         status_ok, metric)%0Aimport sys%0A%0AIMAGE_ENDPOINT = 'http://127.0.0.1:9292'%0A%0A%0Adef check(token):%0A    glance = get_glance_client(token, IMAGE_ENDPOINT)%0A    if glance is None:%0A        status_err('Unable to obtain valid glance client, cannot proceed')
+status_ok, status_err, metric, get_keystone_client,%0A                         get_auth_ref)%0Afrom requests import Session%0Afrom requests import exceptions as exc%0A%0A%0Adef check(auth_ref):%0A    keystone = get_keystone_client(auth_ref)%0A    tenant_id = keystone.tenant_id%0A    auth_token = keystone.auth_token%0A    registry_endpoint = 'http://127.0.0.1:9292/v2'%0A%0A    api-status = 1%0A    milliseconds = 0%0A%0A    s = Session()%0A%0A    s.headers.update(%0A        %7B'Content-type': 'application/json',%0A         'x-auth-token': auth_token%7D)%0A%0A    try:%0A        # Hit something that isn't querying the glance-registry, since we%0A        # query glance-registry in separate checks%0A        r = s.get('%25s/schemas/image' %25 registry_endpoint, verify=False,%0A                  timeout=10)%0A    except (exc.ConnectionError, exc.HTTPError, exc.Timeout):%0A        api_status = 0%0A        milliseconds = -1%0A    except Exception as e:%0A        status_err(str(e))%0A    else:%0A        milliseconds = r.elapsed.total_seconds() * 1000%0A%0A        if not r.ok:%0A            api_status = 0
 %0A%0A  
@@ -1110,19 +1110,24 @@
 'glance_
-api
+registry
 _local_s
@@ -1144,17 +1144,99 @@
 int32', 
-1
+api_status)%0A    metric('glance_registry_local_response_time', 'int32', milliseconds
 )%0A%0A%0Adef 
@@ -1281,55 +1281,22 @@
     
-token = auth_ref%5B'token'%5D%5B'id'%5D%0A    check(token
+check(auth_ref
 )%0A%0A%0A

Make a direct call to glance-api using requests