#NEWLINE# def take_action( name = None , call = None , command = None , data = None , method = 'GET' , location = DEFAULT_LOCATION ) : #NEWLINE# #INDENT# "\n    take action call used by start,stop, reboot\n    :param name: name given to the machine\n    :param call: call value in this case is 'action'\n    :command: api path\n    :data: any data to be passed to the api, must be in json format\n    :method: GET,POST,or DELETE\n    :location: data center to execute the command on\n    :return: true if successful\n    " #NEWLINE# caller = inspect . stack ( ) [ 1 ] [ 3 ] #NEWLINE# if ( call != 'action' ) : #NEWLINE# #INDENT# raise SaltCloudSystemExit ( 'This action must be called with -a or --action.' ) #NEWLINE# #UNINDENT# if data : #NEWLINE# #INDENT# data = json . dumps ( data ) #NEWLINE# #UNINDENT# ret = [ ] #NEWLINE# try : #NEWLINE# #INDENT# ret = query ( command = command , data = data , method = method , location = location ) #NEWLINE# log . info ( 'Success {0} for node {1}' . format ( caller , name ) ) #NEWLINE# #UNINDENT# except Exception as exc : #NEWLINE# #INDENT# if ( 'InvalidState' in str ( exc ) ) : #NEWLINE# #INDENT# ret = [ 200 , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log . error ( 'Failed to invoke {0} node {1}: {2}' . format ( caller , name , exc ) , exc_info_on_loglevel = logging . DEBUG ) #NEWLINE# ret = [ 100 , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ] #NEWLINE# #UNINDENT# #UNINDENT# return ret