#NEWLINE# def _check_glance_api( ) : #NEWLINE# #INDENT# glance = utils . Glance ( ) #NEWLINE# glance . add_argument ( '-w' , dest = 'warning' , type = int , default = 5 , help = 'Warning timeout for Glance APIs calls' ) #NEWLINE# glance . add_argument ( '-c' , dest = 'critical' , type = int , default = 10 , help = 'Critical timeout for Glance APIs calls' ) #NEWLINE# ( options , args , client ) = glance . setup ( ) #NEWLINE# def images_list( ) : #NEWLINE# #INDENT# return list ( client . images . list ( ) ) #NEWLINE# #UNINDENT# ( elapsed , images ) = utils . timeit ( images_list ) #NEWLINE# if ( not images ) : #NEWLINE# #INDENT# utils . critical ( 'Unable to contact Glance API.' ) #NEWLINE# #UNINDENT# if ( elapsed > options . critical ) : #NEWLINE# #INDENT# utils . critical ( ( "Get images took more than %d seconds, it's too long.|response_time=%d" % ( options . critical , elapsed ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( elapsed > options . warning ) : #NEWLINE# #INDENT# utils . warning ( ( "Get images took more than %d seconds, it's too long.|response_time=%d" % ( args . warning , elapsed ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# utils . ok ( ( 'Get images, Glance API is working: list %d images in %d seconds.|response_time=%d' % ( len ( images ) , elapsed , elapsed ) ) )