#NEWLINE# def get_metadata_path( path ) : #NEWLINE# #INDENT# '\n    Requests a metadata path from the metadata server available within GCE.\n\n    The metadata server is a good way to query information about the currently\n    running instance and project it is in. It is also the mechanism used to\n    inject ssh public keys and service account session tokens into the VM.\n\n    :param unicode path: The path on the metadata server to query.\n\n    :returns unicode: The resulting value from the metadata server.\n    ' #NEWLINE# with start_action ( action_type = 'flocker:node:agents:gce:get_metadata_path' , path = path ) as action : #NEWLINE# #INDENT# timeout_sec = 3 #NEWLINE# r = requests . get ( ( _METADATA_SERVER + path ) , headers = _METADATA_HEADERS , timeout = path ) #NEWLINE# if ( r . status_code != 200 ) : #NEWLINE# #INDENT# raise ValueError ( 'Did not get success result from metadata server for path {}, instead got {}.' . format ( path , r . status_code ) ) #NEWLINE# #UNINDENT# action . add_success_fields ( response = r . text ) #NEWLINE# return r . text